[uClibc-cvs] svn commit: trunk/uClibc/libc/sysdeps/linux/common
andersen at uclibc.org
andersen at uclibc.org
Mon Aug 15 22:18:27 UTC 2005
Author: andersen
Date: 2005-08-15 16:18:26 -0600 (Mon, 15 Aug 2005)
New Revision: 11165
Log:
For current kernels, we just use the getcwd() syscall. For old 2.0 linux
kernels, we need this bit to make the non-syscall version that recurses up the
directory path work properly. Thanks go to Harald Kuethe for sorting this out.
Modified:
trunk/uClibc/libc/sysdeps/linux/common/getcwd.c
Changeset:
Modified: trunk/uClibc/libc/sysdeps/linux/common/getcwd.c
===================================================================
--- trunk/uClibc/libc/sysdeps/linux/common/getcwd.c 2005-08-15 22:13:21 UTC (rev 11164)
+++ trunk/uClibc/libc/sysdeps/linux/common/getcwd.c 2005-08-15 22:18:26 UTC (rev 11165)
@@ -10,7 +10,7 @@
#ifdef __NR_getcwd
#define __NR___syscall_getcwd __NR_getcwd
-static inline
+static inline
_syscall2(int, __syscall_getcwd, char *, buf, unsigned long, size);
#else
@@ -134,6 +134,15 @@
olderrno = errno;
len = -1;
+
+ /* get stat for root to have a valid parameters for the terminating condition */
+ if (stat("/", &st) < 0) {
+ /* root dir not found! */
+ return -1;
+ }
+ /* start with actual dir */
+ if (buf) strncpy(buf, ".", size);
+
cwd = recurser(buf, size, st.st_dev, st.st_ino);
if (cwd) {
len = strlen(buf);
More information about the uClibc-cvs
mailing list