From: Andreas Jaeger <aj@suse.de>
To: GNU libc hacker <libc-hacker@sourceware.cygnus.com>
Subject: fstat64/lstat64/stat64 in Linux 2.3.34-2
Date: Sat, 18 Dec 1999 03:01:00 -0000 [thread overview]
Message-ID: <u81z8kectl.fsf@gromit.rhein-neckar.de> (raw)
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
reply other threads:[~1999-12-18 3:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=u81z8kectl.fsf@gromit.rhein-neckar.de \
--to=aj@suse.de \
--cc=libc-hacker@sourceware.cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).