From 12599eafe54ff7dffb654c23c7a6d821d1fb2f27 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 30 Jan 2023 12:30:21 +0100 Subject: [PATCH] at-internal: Add support for z/OS. Reported and draft patch by Igor Todorovski . * lib/openat-proc.c [z/OS]: Include . (openat_proc_name): For z/OS, use an approach similar to kLIBC, with 3 lines of z/OS specific code by Igor Todorovski . --- ChangeLog | 8 ++++++++ lib/openat-proc.c | 21 ++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6063762004..31248afabe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2023-01-30 Bruno Haible + + at-internal: Add support for z/OS. + Reported and draft patch by Igor Todorovski . + * lib/openat-proc.c [z/OS]: Include . + (openat_proc_name): For z/OS, use an approach similar to kLIBC, with + 3 lines of z/OS specific code by Igor Todorovski . + 2023-01-29 Bruno Haible Fix compilation errors with CC="clang -D_FORTIFY_SOURCE=2" on Android. diff --git a/lib/openat-proc.c b/lib/openat-proc.c index 3bacf7dbd1..6419a8cf5f 100644 --- a/lib/openat-proc.c +++ b/lib/openat-proc.c @@ -1,6 +1,6 @@ /* Create /proc/self/fd-related names for subfiles of open directories. - Copyright (C) 2006, 2009-2022 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2023 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,9 +30,12 @@ #include #include -#ifdef __KLIBC__ +#ifdef __KLIBC__ /* OS/2 */ # include #endif +#ifdef __MVS__ /* z/OS */ +# include +#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 */ -- 2.39.5