From: "Haritha via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Haritha <harithamma.d@ibm.com>, D Harithamma <harithamma.d@ibm.com>
Subject: [PATCH] exec_cmd: RUNTIME_PREFIX on z/OS systems
Date: Thu, 22 Aug 2024 13:52:12 +0000 [thread overview]
Message-ID: <pull.1769.git.git.1724334732249.gitgitgadget@gmail.com> (raw)
From: D Harithamma <harithamma.d@ibm.com>
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>
---
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.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1769%2FHarithaIBM%2FexecmdFix-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1769/HarithaIBM/execmdFix-v1
Pull-Request: https://github.com/git/git/pull/1769
Makefile | 8 ++++++++
config.mak.uname | 1 +
exec-cmd.c | 23 +++++++++++++++++++++++
3 files changed, 32 insertions(+)
diff --git a/Makefile b/Makefile
index a87e18b317d..bdc68234823 100644
--- a/Makefile
+++ b/Makefile
@@ -385,6 +385,10 @@ include shared.mak
# supports calling _NSGetExecutablePath to retrieve the path of the running
# executable.
#
+# When using RUNTIME_PREFIX, define HAVE_ZOS_GET_EXECUTABLE_PATH if your platform
+# supports calling __getprogramdir and getprogname to retrieve the path of the
+# running executable.
+#
# When using RUNTIME_PREFIX, define HAVE_WPGMPTR if your platform offers
# the global variable _wpgmptr containing the absolute path of the current
# executable (this is the case on Windows).
@@ -2155,6 +2159,10 @@ ifdef HAVE_NS_GET_EXECUTABLE_PATH
BASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH
endif
+ifdef HAVE_ZOS_GET_EXECUTABLE_PATH
+ BASIC_CFLAGS += -DHAVE_ZOS_GET_EXECUTABLE_PATH
+endif
+
ifdef HAVE_WPGMPTR
BASIC_CFLAGS += -DHAVE_WPGMPTR
endif
diff --git a/config.mak.uname b/config.mak.uname
index aa0fd26bd53..904bcf35987 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -648,6 +648,7 @@ ifeq ($(uname_S),OS/390)
NO_GECOS_IN_PWENT = YesPlease
HAVE_STRINGS_H = YesPlease
NEEDS_MODE_TRANSLATION = YesPlease
+ HAVE_ZOS_GET_EXECUTABLE_PATH = YesPlease
endif
ifeq ($(uname_S),MINGW)
ifeq ($(shell expr "$(uname_R)" : '1\.'),2)
diff --git a/exec-cmd.c b/exec-cmd.c
index 909777f61f4..507e67d528b 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;
}
base-commit: 3a7362eb9fad0c4838f5cfaa95ed3c51a4c18d93
--
gitgitgadget
next reply other threads:[~2024-08-22 13:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-22 13:52 Haritha via GitGitGadget [this message]
2024-08-22 15:58 ` [PATCH] exec_cmd: RUNTIME_PREFIX on z/OS systems Junio C Hamano
2024-08-23 16:57 ` Junio C Hamano
2024-08-27 6:18 ` Haritha D
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.1769.git.git.1724334732249.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=harithamma.d@ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.