[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: detection of functional openat() for usage inside getcwd.c
From: |
Jim Meyering |
Subject: |
Re: detection of functional openat() for usage inside getcwd.c |
Date: |
Fri, 14 Dec 2007 19:46:15 +0100 |
Petr Salinger <address@hidden> wrote:
> getcwd.c uses *at() function family iff AT_FDCWD is defined.
> This approach does not work on GNU/kFreeBSD - FreeBSD kernel + GNU libc.
> The kernel does not provide needed interfaces, and therefore glibc
> provides only stub version for function from *at() family.
> But the AT_FDCWD is declared and getwdc.c uses only native i.e. openat().
>
> Please, could you change detection whether really use *at() function
> family in getcwd.
Here's an untested patch.
Please test it.
Port to GNU/kFreeBSD - FreeBSD kernel + GNU libc,
which has no openat syscall, yet <fcntl.h> does define AT_FDCWD.
* lib/getcwd.c: Undef AT_FDCWD if there is no openat function.
* modules/getcwd (Depends-on): Add openat.
Reported by Petr Salinger.
diff --git a/lib/getcwd.c b/lib/getcwd.c
index b8e9989..98df8bf 100644
--- a/lib/getcwd.c
+++ b/lib/getcwd.c
@@ -29,6 +29,11 @@
#include <fcntl.h> /* For AT_FDCWD on Solaris 9. */
+/* On a system without the openat function, undefine AT_FDCWD. */
+#if ! HAVE_OPENAT
+# undef AT_FDCWD
+#endif
+
#ifndef __set_errno
# define __set_errno(val) (errno = (val))
#endif
diff --git a/modules/getcwd b/modules/getcwd
index 17687e7..46ecb03 100644
--- a/modules/getcwd
+++ b/modules/getcwd
@@ -12,6 +12,7 @@ mempcpy
d-ino
dirfd
extensions
+openat
stdbool
unistd
malloc-posix