Skip to content

Commit 987bbcd

Browse files
HarithaIBMgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3a7362e commit 987bbcd

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ include shared.mak
385385
# supports calling _NSGetExecutablePath to retrieve the path of the running
386386
# executable.
387387
#
388+
# When using RUNTIME_PREFIX, define HAVE_ZOS_GET_EXECUTABLE_PATH if your platform
389+
# supports calling __getprogramdir and getprogname to retrieve the path of the
390+
# running executable.
391+
#
388392
# When using RUNTIME_PREFIX, define HAVE_WPGMPTR if your platform offers
389393
# the global variable _wpgmptr containing the absolute path of the current
390394
# executable (this is the case on Windows).
@@ -2155,6 +2159,10 @@ ifdef HAVE_NS_GET_EXECUTABLE_PATH
21552159
BASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH
21562160
endif
21572161

2162+
ifdef HAVE_ZOS_GET_EXECUTABLE_PATH
2163+
BASIC_CFLAGS += -DHAVE_ZOS_GET_EXECUTABLE_PATH
2164+
endif
2165+
21582166
ifdef HAVE_WPGMPTR
21592167
BASIC_CFLAGS += -DHAVE_WPGMPTR
21602168
endif

config.mak.uname

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ ifeq ($(uname_S),OS/390)
648648
NO_GECOS_IN_PWENT = YesPlease
649649
HAVE_STRINGS_H = YesPlease
650650
NEEDS_MODE_TRANSLATION = YesPlease
651+
HAVE_ZOS_GET_EXECUTABLE_PATH = YesPlease
651652
endif
652653
ifeq ($(uname_S),MINGW)
653654
ifeq ($(shell expr "$(uname_R)" : '1\.'),2)

exec-cmd.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,25 @@ static int git_get_exec_path_darwin(struct strbuf *buf)
150150
}
151151
#endif /* HAVE_NS_GET_EXECUTABLE_PATH */
152152

153+
#ifdef HAVE_ZOS_GET_EXECUTABLE_PATH
154+
/*
155+
* Resolves the executable path from current program's directory and name.
156+
*
157+
* Returns 0 on success, -1 on failure.
158+
*/
159+
static int git_get_exec_path_zos(struct strbuf *buf)
160+
{
161+
char *dir = __getprogramdir();
162+
char *exe = getprogname();
163+
if (dir && exe) {
164+
strbuf_addf(buf, "%s/%s", dir, exe);
165+
return 0;
166+
}
167+
return -1;
168+
}
169+
170+
#endif /* HAVE_ZOS_GET_EXECUTABLE_PATH */
171+
153172
#ifdef HAVE_WPGMPTR
154173
/*
155174
* 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)
206225
git_get_exec_path_wpgmptr(buf) &&
207226
#endif /* HAVE_WPGMPTR */
208227

228+
#ifdef HAVE_ZOS_GET_EXECUTABLE_PATH
229+
git_get_exec_path_zos(buf) &&
230+
#endif /*HAVE_ZOS_GET_EXECUTABLE_PATH */
231+
209232
git_get_exec_path_from_argv0(buf, argv0)) {
210233
return -1;
211234
}

0 commit comments

Comments
 (0)