summaryrefslogtreecommitdiff
path: root/exec-cmd.c
diff options
context:
space:
mode:
authorD Harithamma <harithamma.d@ibm.com>2024-08-22 13:52:12 +0000
committerJunio C Hamano <gitster@pobox.com>2024-08-22 08:58:46 -0700
commit987bbcd088fc6274e21b4fac36e58a66c4ded460 (patch)
treee5b2c9d10469bf2986c69cdb94ac7b740a432a09 /exec-cmd.c
parent3a7362eb9fad0c4838f5cfaa95ed3c51a4c18d93 (diff)
exec_cmd: RUNTIME_PREFIX on z/OS systems
Enable Git to resolve its own binary location using __getprogramdir and getprogname. Since /proc is not a mandatory filesystem on z/OS, we cannot rely on the git_get_exec_path_procfs method to determine Git's executable path. To address this, we have implemented git_get_exec_path_zos, which resolves the executable path by extracting it from the current program's directory and filename. Signed-off-by: D Harithamma <harithamma.d@ibm.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'exec-cmd.c')
-rw-r--r--exec-cmd.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/exec-cmd.c b/exec-cmd.c
index 909777f61f..507e67d528 100644
--- a/exec-cmd.c
+++ b/exec-cmd.c
@@ -150,6 +150,25 @@ static int git_get_exec_path_darwin(struct strbuf *buf)
}
#endif /* HAVE_NS_GET_EXECUTABLE_PATH */
+#ifdef HAVE_ZOS_GET_EXECUTABLE_PATH
+/*
+ * Resolves the executable path from current program's directory and name.
+ *
+ * Returns 0 on success, -1 on failure.
+ */
+static int git_get_exec_path_zos(struct strbuf *buf)
+{
+ char *dir = __getprogramdir();
+ char *exe = getprogname();
+ if (dir && exe) {
+ strbuf_addf(buf, "%s/%s", dir, exe);
+ return 0;
+ }
+ return -1;
+}
+
+#endif /* HAVE_ZOS_GET_EXECUTABLE_PATH */
+
#ifdef HAVE_WPGMPTR
/*
* Resolves the executable path by using the global variable _wpgmptr.
@@ -206,6 +225,10 @@ static int git_get_exec_path(struct strbuf *buf, const char *argv0)
git_get_exec_path_wpgmptr(buf) &&
#endif /* HAVE_WPGMPTR */
+#ifdef HAVE_ZOS_GET_EXECUTABLE_PATH
+ git_get_exec_path_zos(buf) &&
+#endif /*HAVE_ZOS_GET_EXECUTABLE_PATH */
+
git_get_exec_path_from_argv0(buf, argv0)) {
return -1;
}