[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 08/11] openat_proc_name: port to OS/2 kLIBC
From: |
KO Myung-Hun |
Subject: |
[PATCH 08/11] openat_proc_name: port to OS/2 kLIBC |
Date: |
Sat, 7 Nov 2015 11:45:53 +0900 |
OS/2 kLIBC provides a function to retrive a path from a fd. Use it
instead of /proc/self/fd.
* lib/openat-proc.c (openat_proc_name): Port to OS/2 kLIBC with
__libc_Back_ioFHToPath().
---
ChangeLog | 9 +++++++++
lib/openat-proc.c | 29 +++++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 15f50bc..c55fce2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2015-11-07 KO Myung-Hun <address@hidden>
+ openat_proc_name: port to OS/2 kLIBC
+ OS/2 kLIBC provides a function to retrive a path from a fd. Use it
+ instead of /proc/self/fd.
+
+ * lib/openat-proc.c (openat_proc_name): Port to OS/2 kLIBC with
+ __libc_Back_ioFHToPath().
+
+2015-11-07 KO Myung-Hun <address@hidden>
+
dup, dup2, fcntl: support a directory fd on OS/2 kLIBC
On OS/2 kLIBC, dup(), dup2() and fcntl() do not work on a directory
fd.
diff --git a/lib/openat-proc.c b/lib/openat-proc.c
index 4e1d341..275a48f 100644
--- a/lib/openat-proc.c
+++ b/lib/openat-proc.c
@@ -30,6 +30,10 @@
#include <string.h>
#include <unistd.h>
+#ifdef __KLIBC__
+# include <InnoTekLIBC/backend.h>
+#endif
+
#include "intprops.h"
#define PROC_SELF_FD_FORMAT "/proc/self/fd/%d/%s"
@@ -56,6 +60,7 @@ openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char
const *file)
return buf;
}
+#ifndef __KLIBC__
if (! proc_status)
{
/* Set PROC_STATUS to a positive value if /proc/self/fd is
@@ -99,4 +104,28 @@ openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd,
char const *file)
sprintf (result, PROC_SELF_FD_FORMAT, fd, file);
return result;
}
+#else
+ /* OS/2 kLIBC provides a function to retrieve a path from a fd. Use it. */
+ {
+ char path[_MAX_PATH];
+ size_t bufsize;
+ char *result = buf;
+
+ /* Get a path from a fd */
+ if (__libc_Back_ioFHToPath (fd, path, sizeof (path)))
+ return NULL;
+
+ bufsize = strlen (path) + 1 + strlen (file) + 1; /* 1 for '/', 1 for null
*/
+ if (OPENAT_BUFFER_SIZE < bufsize)
+ {
+ result = malloc (bufsize);
+ if (! result)
+ return NULL;
+ }
+
+ sprintf (result, "%s/%s", path, file);
+
+ return result;
+ }
+#endif
}
--
2.6.0
- [PATCH] OS/2 patches, KO Myung-Hun, 2015/11/06
- [PATCH 01/11] stdint: check _INTPTR_T_DECLARED before defining intptr_t and uintptr_t, KO Myung-Hun, 2015/11/06
- [PATCH 02/11] binary-io: don't put fd in binary mode if it is a console on EMX, KO Myung-Hun, 2015/11/06
- [PATCH 03/11] pipe-filter-aux: undefine HAVE_SELECT on KLIBC, KO Myung-Hun, 2015/11/06
- [PATCH 04/11] w32spawn: clear SHELL_SPECIAL_CHARS and SHELL_SPACE_CHAR on OS/2 kLIBC, KO Myung-Hun, 2015/11/06
- [PATCH 05/11] wchar: fix 'conflicting types' error for `__wcwidth' on OS/2 kLIBC, KO Myung-Hun, 2015/11/06
- [PATCH 07/11] dup, dup2, fcntl: support a directory fd on OS/2 kLIBC, KO Myung-Hun, 2015/11/06
- [PATCH 06/11] pipe_filter_ii_execute: port to OS/2 kLIBC, KO Myung-Hun, 2015/11/06
- [PATCH 08/11] openat_proc_name: port to OS/2 kLIBC,
KO Myung-Hun <=
- [PATCH 10/11] utimes: detect utimes() correctly on OS/2 kLIBC, KO Myung-Hun, 2015/11/06
- [PATCH 09/11] opendir, closedir, dirfd, fdopendir: port to OS/2 kLIBC, KO Myung-Hun, 2015/11/06
- [PATCH 11/11] gnulib-tool: fall back into copy if symbolic link is not supported, KO Myung-Hun, 2015/11/06