* fstat64/lstat64/stat64 in Linux 2.3.34-2
@ 1999-12-18 3:01 Andreas Jaeger
0 siblings, 0 replies; only message in thread
From: Andreas Jaeger @ 1999-12-18 3:01 UTC (permalink / raw)
To: GNU libc hacker
Here's a patch for glibc 2.2 to implement the fstat64/lstat64/stat64
syscalls from Linux 2.3.34-2.
Please note that currently only i386 is supported, the syscalls are
also available for arm and m68k but struct stat64 is not supported for
arm and m68k, yet. I hope the kernel maintainers finish the support
for their platforms.
Andreas
1999-12-18 Andreas Jaeger <aj@suse.de>
* sysdeps/unix/sysv/linux/fxstat64.c: Rewrite to use fstat64
syscall if available.
* sysdeps/unix/sysv/linux/lxstat64.c: Likewise for lstat64.
* sysdeps/unix/sysv/linux/xstat64.c: Likewise for stat64.
* sysdeps/unix/sysv/linux/kernel-features.h
(__ASSUME_STAT64_SYSCALL): New.
============================================================
Index: sysdeps/unix/sysv/linux/fxstat64.c
--- sysdeps/unix/sysv/linux/fxstat64.c 1998/10/21 15:08:36 1.2
+++ sysdeps/unix/sysv/linux/fxstat64.c 1999/12/18 10:45:06
@@ -1,5 +1,5 @@
/* fxstat64 using old-style Unix fstat system call.
- Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,20 +25,46 @@
#include <sysdep.h>
#include <sys/syscall.h>
-#include <xstatconv.c>
+#if __ASSUME_STAT64_SYSCALL == 0
+# include <xstatconv.c>
+#endif
extern int __syscall_fstat (int, struct kernel_stat *);
+#ifdef __NR_fstat64
+extern int __syscall_fstat64 (int, struct stat64 *);
+# if __ASSUME_STAT64_SYSCALL == 0
+/* The variable is shared between all wrappers around *stat64 calls. */
+extern int have_no_stat64;
+# endif
+#endif
+
/* Get information about the file FD in BUF. */
int
__fxstat64 (int vers, int fd, struct stat64 *buf)
{
- struct kernel_stat kbuf;
+#if __ASSUME_STAT64_SYSCALL > 0
+ return INLINE_SYSCALL (fstat64, 2, fd, &buf);
+#else
int result;
-
+ struct kernel_stat kbuf;
+# if defined __NR_fstat64
+ if (! have_no_stat64)
+ {
+ int saved_errno = errno;
+ result = INLINE_SYSCALL (fstat64, 2, fd, &buf);
+
+ if (result != -1 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ have_no_stat64 = 1;
+ }
+# endif
result = INLINE_SYSCALL (fstat, 2, fd, &kbuf);
if (result == 0)
result = xstat64_conv (vers, &kbuf, buf);
return result;
+#endif
}
============================================================
Index: sysdeps/unix/sysv/linux/lxstat64.c
--- sysdeps/unix/sysv/linux/lxstat64.c 1998/10/21 15:10:59 1.2
+++ sysdeps/unix/sysv/linux/lxstat64.c 1999/12/18 10:45:06
@@ -1,5 +1,5 @@
/* lxstat64 using old-style Unix lstat system call.
- Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,20 +25,46 @@
#include <sysdep.h>
#include <sys/syscall.h>
-#include <xstatconv.c>
+#if __ASSUME_STAT64_SYSCALL == 0
+# include <xstatconv.c>
+#endif
extern int __syscall_lstat (const char *, struct kernel_stat *);
+#ifdef __NR_lstat64
+extern int __syscall_lstat64 (const char *, struct stat64 *);
+# if __ASSUME_STAT64_SYSCALL == 0
+/* The variable is shared between all wrappers around *stat64 calls. */
+extern int have_no_stat64;
+# endif
+#endif
+
/* Get information about the file NAME in BUF. */
int
__lxstat64 (int vers, const char *name, struct stat64 *buf)
{
+#ifdef __ASSUME_STAT64_SYSCALL
+ return INLINE_SYSCALL (lstat64, 2, name, &buf);
+#else
struct kernel_stat kbuf;
int result;
-
+# ifdef __NR_lstat64
+ if (! have_no_stat64)
+ {
+ int saved_errno = errno;
+ result = INLINE_SYSCALL (lstat64, 2, name, &kbuf);
+
+ if (result != -1 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ have_no_stat64 = 1;
+ }
+# endif
result = INLINE_SYSCALL (lstat, 2, name, &kbuf);
if (result == 0)
result = xstat64_conv (vers, &kbuf, buf);
return result;
+#endif
}
============================================================
Index: sysdeps/unix/sysv/linux/xstat64.c
--- sysdeps/unix/sysv/linux/xstat64.c 1998/10/21 15:11:23 1.2
+++ sysdeps/unix/sysv/linux/xstat64.c 1999/12/18 10:45:06
@@ -1,5 +1,5 @@
/* xstat64 using old-style Unix stat system call.
- Copyright (C) 1991, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,20 +25,49 @@
#include <sysdep.h>
#include <sys/syscall.h>
-#include <xstatconv.c>
+#if __ASSUME_STAT64_SYSCALL == 0
+# include <xstatconv.c>
+#endif
extern int __syscall_stat (const char *, struct kernel_stat *);
+#ifdef __NR_stat64
+extern int __syscall_fstat64 (int, struct stat64 *);
+# if __ASSUME_STAT64_SYSCALL == 0
+/* The variable is shared between all wrappers around *stat64 calls.
+ This is the definition. */
+int have_no_stat64;
+# endif
+#endif
+
/* Get information about the file NAME in BUF. */
+
int
__xstat64 (int vers, const char *name, struct stat64 *buf)
{
+#if __ASSUME_STAT64_SYSCALL > 0
+ return INLINE_SYSCALL (stat64, 2, name, &buf);
+#else
struct kernel_stat kbuf;
int result;
-
+# if defined __NR_stat64
+ if (! have_no_stat64)
+ {
+ int saved_errno = errno;
+ result = INLINE_SYSCALL (stat64, 2, name, &buf);
+
+ if (result != -1 || errno != ENOSYS)
+ return result;
+
+ __set_errno (saved_errno);
+ have_no_stat64 = 1;
+ }
+# endif
+
result = INLINE_SYSCALL (stat, 2, name, &kbuf);
if (result == 0)
result = xstat64_conv (vers, &kbuf, buf);
return result;
+#endif
}
============================================================
Index: sysdeps/unix/sysv/linux/kernel-features.h
--- sysdeps/unix/sysv/linux/kernel-features.h 1999/12/08 23:45:47 1.5
+++ sysdeps/unix/sysv/linux/kernel-features.h 1999/12/18 10:45:06
@@ -85,7 +85,12 @@
# define __ASSUME_TRUNCATE64_SYSCALL 1
#endif
-/* On x86 the truncate64/ftruncate64 syscalls were introduced in 2.3.31. */
+/* On x86 the mmap2 syscall was introduced in 2.3.31. */
#if __LINUX_KERNEL_VERSION >= 131871 && defined __i386__
# define __ASSUME_MMAP2_SYSCALL 1
+#endif
+
+/* On x86 the stat64/lstat64/fstat64 syscalls were introduced in 2.3.34. */
+#if __LINUX_KERNEL_VERSION >= 131874 && defined __i386__
+# define __ASSUME_STAT64_SYSCALL 1
#endif
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.rhein-neckar.de
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1999-12-18 3:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-18 3:01 fstat64/lstat64/stat64 in Linux 2.3.34-2 Andreas Jaeger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).