Re: Bug#573940: coreutils: rm -r doesn't work on kfreebsd-i386
* Petr Salinger <Petr.Salinger@seznam.cz>, 2010-03-18, 19:05:
Also, it might be interesting that:
- Despite fstatat() being not detected at configure time, rm uses
the __fxstatat symbol.
This seems to be the key point.
The FreeBSD 7.x kernel does not have the *at syscalls, only limited
emulation is available in our glibc in this case.
Under 8.x kernel *at syscalls are native and are used directly,
we have runtime detection in our glibc.
As we still want to support both kernel versions (7.x and 8.x) for
now, all *at syscalls are marked as stubs in glibc (see i.e.
<gnu/stubs-32.h>). Therefore the coreutils (and any gnulib user)
should not use them at all.
Unfortunately the *stat{,at} functions are in glibc implemented via
*xstat{,at} and the *stat{,at} functions are inline's which calls
*xstat{,at},
see * <sys/stat.h> on any glibc system :-(
I think this issue could be worked around, though in a ugly way.
Wouldn't the attached patch do the trick? (Sorry, no time to test it
properly myself.)
--
Jakub Wilk
diff -Nru coreutils-8.4/lib/fstatat.c coreutils-8.4/lib/fstatat.c
--- coreutils-8.4/lib/fstatat.c 2010-01-04 16:19:05.000000000 +0000
+++ coreutils-8.4/lib/fstatat.c 2010-03-18 19:21:08.000000000 +0000
@@ -107,4 +107,15 @@
# undef AT_FUNC_POST_FILE_PARAM_DECLS
# undef AT_FUNC_POST_FILE_ARGS
+#ifdef __FreeBSD_kernel__
+
+int __fxstatat(int version, int fd, const char *file, struct stat *st, int flag)
+{
+ typedef int (*tp)(int, const char *, struct stat *, int);
+ volatile tp f = fstatat;
+ return f(fd, file, st, flag);
+}
+
+#endif
+
#endif /* !HAVE_FSTATAT */
Reply to: