diff options
author | Bruno Haible <bruno@clisp.org> | 2023-01-30 12:30:21 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2023-01-30 12:47:02 +0100 |
commit | b91daecd7b83a890712df3f02cf3bfa7d123ec33 (patch) | |
tree | 947a154ec8ef80091fc12fe9ea297858b549dd81 /lib | |
parent | 8e0ac7371de57a294375d5dc678bbc0da4caa825 (diff) | |
download | gnulib-b91daecd7b83a890712df3f02cf3bfa7d123ec33.tar.gz |
at-internal: Add support for z/OS.
Reported and draft patch by Igor Todorovski <itodorov@ca.ibm.com>.
* lib/openat-proc.c [z/OS]: Include <termios.h>.
(openat_proc_name): For z/OS, use an approach similar to kLIBC, with
3 lines of z/OS specific code by Igor Todorovski <itodorov@ca.ibm.com>.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/openat-proc.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/openat-proc.c b/lib/openat-proc.c index 2a6a85f069..6419a8cf5f 100644 --- a/lib/openat-proc.c +++ b/lib/openat-proc.c @@ -30,9 +30,12 @@ #include <string.h> #include <unistd.h> -#ifdef __KLIBC__ +#ifdef __KLIBC__ /* OS/2 */ # include <InnoTekLIBC/backend.h> #endif +#ifdef __MVS__ /* z/OS */ +# include <termios.h> +#endif #include "intprops.h" @@ -53,7 +56,8 @@ openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file) return buf; } -#ifndef __KLIBC__ +#if !(defined __KLIBC__ || defined __MVS__) + /* Generic code for Linux, Solaris, and similar platforms. */ # define PROC_SELF_FD_FORMAT "/proc/self/fd/%d/" { enum { @@ -107,14 +111,21 @@ openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file) dirlen = sprintf (result, PROC_SELF_FD_FORMAT, fd); } } -#else +#else /* (defined __KLIBC__ || defined __MVS__), i.e. OS/2 or z/OS */ /* OS/2 kLIBC provides a function to retrieve a path from a fd. */ { - char dir[_MAX_PATH]; size_t bufsize; +# ifdef __KLIBC__ + char dir[_MAX_PATH]; if (__libc_Back_ioFHToPath (fd, dir, sizeof dir)) return NULL; +# endif +# ifdef __MVS__ + char dir[_XOPEN_PATH_MAX]; + if (w_ioctl (fd, _IOCC_GPN, sizeof dir, dir) == 0) + __e2a_l (dir, sizeof dir); +# endif dirlen = strlen (dir); bufsize = dirlen + 1 + strlen (file) + 1; /* 1 for '/', 1 for null */ |