]> Savannah Git Hosting - gnulib.git/commitdiff
at-internal: Add support for z/OS.
authorBruno Haible <bruno@clisp.org>
Mon, 30 Jan 2023 11:30:21 +0000 (12:30 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 10 Feb 2023 03:01:41 +0000 (04:01 +0100)
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>.

ChangeLog
lib/openat-proc.c

index 6063762004bdfdb8c1efe7cb4cb433832e71a6a2..31248afabe1a871e10784f32a340114dc722b77d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-01-30  Bruno Haible  <bruno@clisp.org>
+
+       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>.
+
 2023-01-29  Bruno Haible  <bruno@clisp.org>
 
        Fix compilation errors with CC="clang -D_FORTIFY_SOURCE=2" on Android.
index 3bacf7dbd13d7065ce399e2b046f7a3eb1eb15f6..6419a8cf5fb70c96f260c0a9972435d3fdc70bc7 100644 (file)
@@ -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
 #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 */