Re: [dev] Re: [9base] Failure to link against uClibc: undefined references

From: Paul Onyschuk <blink_AT_bojary.koba.pl>
Date: Tue, 28 Feb 2012 23:51:31 +0100

uClibc doesn't provide wrappers for getdents() syscall either. The
proper solution would be to use readdir()/scandir() instead I guess.
Till then people interested can use this ad-hoc patch, which uses
getdents() syscall directly. It shouldn't be applied to main repository
I think.

Also join has some issues, I removed its entry from Makefile just to
check if ls/du commands works.


--- lib9/dirread.c.orig 2012-02-28 23:09:24.000000000 +0100
+++ lib9/dirread.c 2012-02-28 23:22:48.000000000 +0100
_AT_@ -4,9 +4,25 @@
 #include <sys/stat.h>
 #include <dirent.h>
 
+#if defined(__UCLIBC__)
+# include <sys/syscall.h>
+# if defined(__USE_LARGEFILE64)
+# define getdents SYS_getdents64
+# else
+# define getdents SYS_getdents
+# endif
+#endif
+
 extern int _p9dir(struct stat*, struct stat*, char*, Dir*, char**,
char*);
 #if defined(__linux__)
+# if defined(__UCLIBC__)
+static int
+mygetdents(int fd, struct dirent *buf, int n)
+{
+ return syscall(getdents, fd, (void*)buf, n);
+}
+# else
 static int
 mygetdents(int fd, struct dirent *buf, int n)
 {
_AT_@ -18,6 +34,7 @@ mygetdents(int fd, struct dirent *buf, i
         nn = getdirentries(fd, (void*)buf, n, &off);
         return nn;
 }
+# endif
 #elif defined(__APPLE__) || defined(__FreeBSD__)
 static int
 mygetdents(int fd, struct dirent *buf, int n)
Received on Tue Feb 28 2012 - 23:51:31 CET

This archive was generated by hypermail 2.3.0 : Wed Feb 29 2012 - 00:00:20 CET