summaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/alpha
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2004-03-11 02:58:44 +0000
committerRichard Henderson <rth@redhat.com>2004-03-11 02:58:44 +0000
commitc72aaf4396e559936453a2ff3e8ffb31815d7874 (patch)
tree9bcdceb07f5b284925044875a34f025fd435c1c1 /sysdeps/unix/sysv/linux/alpha
parent73b4ce64cc07a2732d691a4e3432cdc082d10567 (diff)
* sysdeps/unix/sysv/linux/alpha/kernel_stat.h (kernel_stat64): New. (glibc21_stat): New. * sysdeps/unix/sysv/linux/alpha/fxstat.c: New file. * sysdeps/unix/sysv/linux/alpha/lxstat.c: New file. * sysdeps/unix/sysv/linux/alpha/xstat.c: New file. * sysdeps/unix/sysv/linux/alpha/xstatconv.c (__xstat_conv): Add code for _STAT_VER_GLIBC2_3_4. (__libc_missing_axp_stat64): New. * sysdeps/unix/sysv/linux/alpha/xstatconv.h: New file. * sysdeps/unix/sysv/linux/alpha/bits/stat.h (__ST_TIME): New. (_STAT_VER_GLIBC2_3_4, _STAT_VER_KERNEL64): New. (struct stat, struct stat64): Update to new format. (_STATBUF_ST_NSEC): New.
2004-03-11 Richard Henderson <rth@redhat.com> * sysdeps/unix/sysv/linux/alpha/kernel_stat.h (kernel_stat64): New. (glibc21_stat): New. * sysdeps/unix/sysv/linux/alpha/fxstat.c: New file. * sysdeps/unix/sysv/linux/alpha/lxstat.c: New file. * sysdeps/unix/sysv/linux/alpha/xstat.c: New file. * sysdeps/unix/sysv/linux/alpha/xstatconv.c (__xstat_conv): Add code for _STAT_VER_GLIBC2_3_4. (__libc_missing_axp_stat64): New. * sysdeps/unix/sysv/linux/alpha/xstatconv.h: New file. * sysdeps/unix/sysv/linux/alpha/bits/stat.h (__ST_TIME): New. (_STAT_VER_GLIBC2_3_4, _STAT_VER_KERNEL64): New. (struct stat, struct stat64): Update to new format. (_STATBUF_ST_NSEC): New.
Diffstat (limited to 'sysdeps/unix/sysv/linux/alpha')
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/stat.h86
-rw-r--r--sysdeps/unix/sysv/linux/alpha/fxstat.c64
-rw-r--r--sysdeps/unix/sysv/linux/alpha/kernel_stat.h47
-rw-r--r--sysdeps/unix/sysv/linux/alpha/lxstat.c64
-rw-r--r--sysdeps/unix/sysv/linux/alpha/xstat.c64
-rw-r--r--sysdeps/unix/sysv/linux/alpha/xstatconv.c39
-rw-r--r--sysdeps/unix/sysv/linux/alpha/xstatconv.h24
7 files changed, 357 insertions, 31 deletions
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/stat.h b/sysdeps/unix/sysv/linux/alpha/bits/stat.h
index 921283a511..40b6853430 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/stat.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/stat.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1996,1997,1998,1999,2000,2001,2004
+ 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
@@ -24,11 +25,45 @@
#define _STAT_VER_KERNEL 0
#define _STAT_VER_GLIBC2 1
#define _STAT_VER_GLIBC2_1 2
-#define _STAT_VER _STAT_VER_GLIBC2_1
+#define _STAT_VER_KERNEL64 3
+#define _STAT_VER_GLIBC2_3_4 3
+#define _STAT_VER _STAT_VER_GLIBC2_3_4
/* Versions of the `xmknod' interface. */
#define _MKNOD_VER_LINUX 0
+
+/* Nanosecond resolution timestamps are stored in a format equivalent to
+ 'struct timespec'. This is the type used whenever possible but the
+ Unix namespace rules do not allow the identifier 'timespec' to appear
+ in the <sys/stat.h> header. Therefore we have to handle the use of
+ this header in strictly standard-compliant sources special.
+
+ Use neat tidy anonymous unions and structures when possible. */
+
+#ifdef __USE_MISC
+# if __GNUC_PREREQ(3,3)
+# define __ST_TIME(X) \
+ __extension__ union { \
+ struct timespec st_##X##tim; \
+ struct { \
+ __time_t st_##X##time; \
+ unsigned long st_##X##timensec; \
+ }; \
+ }
+# else
+# define __ST_TIME(X) struct timespec st_##X##tim
+# define st_atime st_atim.tv_sec
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+# endif
+#else
+# define __ST_TIME(X) \
+ __time_t st_##X##time; \
+ unsigned long st_##X##timensec
+#endif
+
+
struct stat
{
__dev_t st_dev; /* Device. */
@@ -36,28 +71,26 @@ struct stat
__ino64_t st_ino; /* File serial number. */
#else
__ino_t st_ino; /* File serial number. */
- int __pad1;
+ int __pad0; /* 64-bit st_ino. */
#endif
- __mode_t st_mode; /* File mode. */
- __nlink_t st_nlink; /* Link count. */
- __uid_t st_uid; /* User ID of the file's owner. */
- __gid_t st_gid; /* Group ID of the file's group.*/
__dev_t st_rdev; /* Device number, if device. */
__off_t st_size; /* Size of file, in bytes. */
- __time_t st_atime; /* Time of last access. */
- __time_t st_mtime; /* Time of last modification. */
- __time_t st_ctime; /* Time of last status change. */
#ifdef __USE_FILE_OFFSET64
__blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
#else
__blkcnt_t st_blocks; /* Nr. 512-byte blocks allocated. */
- int __pad2;
+ int __pad1; /* 64-bit st_blocks. */
#endif
+ __mode_t st_mode; /* File mode. */
+ __uid_t st_uid; /* User ID of the file's owner. */
+ __gid_t st_gid; /* Group ID of the file's group.*/
__blksize_t st_blksize; /* Optimal block size for I/O. */
- unsigned int st_flags;
- unsigned int st_gen;
- int __pad3;
- long __unused[4];
+ __nlink_t st_nlink; /* Link count. */
+ int __pad2; /* Real padding. */
+ __ST_TIME(a); /* Time of last access. */
+ __ST_TIME(m); /* Time of last modification. */
+ __ST_TIME(c); /* Time of last status change. */
+ long __unused[3];
};
#ifdef __USE_LARGEFILE64
@@ -66,27 +99,28 @@ struct stat64
{
__dev_t st_dev; /* Device. */
__ino64_t st_ino; /* File serial number. */
- __mode_t st_mode; /* File mode. */
- __nlink_t st_nlink; /* Link count. */
- __uid_t st_uid; /* User ID of the file's owner. */
- __gid_t st_gid; /* Group ID of the file's group.*/
__dev_t st_rdev; /* Device number, if device. */
__off_t st_size; /* Size of file, in bytes. */
- __time_t st_atime; /* Time of last access. */
- __time_t st_mtime; /* Time of last modification. */
- __time_t st_ctime; /* Time of last status change. */
__blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
+ __mode_t st_mode; /* File mode. */
+ __uid_t st_uid; /* User ID of the file's owner. */
+ __gid_t st_gid; /* Group ID of the file's group.*/
__blksize_t st_blksize; /* Optimal block size for I/O. */
- unsigned int st_flags;
- unsigned int st_gen;
- int __pad3;
- long __unused[4];
+ __nlink_t st_nlink; /* Link count. */
+ int __pad0; /* Real padding. */
+ __ST_TIME(a); /* Time of last access. */
+ __ST_TIME(m); /* Time of last modification. */
+ __ST_TIME(c); /* Time of last status change. */
+ long __unused[3];
};
#endif
+#undef __ST_TIME
+
/* Tell code we have these members. */
#define _STATBUF_ST_BLKSIZE
#define _STATBUF_ST_RDEV
+#define _STATBUF_ST_NSEC
/* Encoding of the file mode. */
diff --git a/sysdeps/unix/sysv/linux/alpha/fxstat.c b/sysdeps/unix/sysv/linux/alpha/fxstat.c
new file mode 100644
index 0000000000..40e08fd86e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/fxstat.c
@@ -0,0 +1,64 @@
+/* fxstat using old-style Unix stat system call.
+ Copyright (C) 2004 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define __fxstat64 __fxstat64_disable
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <kernel_stat.h>
+#include <sysdep.h>
+#include <sys/syscall.h>
+#include <xstatconv.h>
+
+#undef __fxstat64
+
+
+/* Get information about the file NAME in BUF. */
+int
+__fxstat (int vers, int fd, struct stat *buf)
+{
+ INTERNAL_SYSCALL_DECL (err);
+ int result, errno_out;
+ struct kernel_stat kbuf;
+
+ if (vers == _STAT_VER_KERNEL64 && !__libc_missing_axp_stat64)
+ {
+ result = INTERNAL_SYSCALL (fstat64, err, 2, fd, buf);
+ if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+ return result;
+ errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
+ if (errno_out != ENOSYS)
+ goto fail;
+ __libc_missing_axp_stat64 = 1;
+ }
+
+ result = INTERNAL_SYSCALL (fstat, err, 2, fd, &kbuf);
+ if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+ return __xstat_conv (vers, &kbuf, buf);
+ errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
+
+ fail:
+ __set_errno (errno_out);
+ return -1;
+}
+hidden_def (__fxstat)
+weak_alias (__fxstat, _fxstat);
+strong_alias (__fxstat, __fxstat64);
+hidden_ver (__fxstat, __fxstat64)
diff --git a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
index 75540c0a6d..a1d012ab01 100644
--- a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
+++ b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
@@ -18,6 +18,31 @@ struct kernel_stat
unsigned int st_gen;
};
+/* Definition of `struct stat64' used in the kernel. */
+struct kernel_stat64
+ {
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned long st_rdev;
+ long st_size;
+ unsigned long st_blocks;
+
+ unsigned int st_mode;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int st_blksize;
+ unsigned int st_nlink;
+ unsigned int __pad0;
+
+ unsigned long st_atime;
+ unsigned long st_atimensec;
+ unsigned long st_mtime;
+ unsigned long st_mtimensec;
+ unsigned long st_ctime;
+ unsigned long st_ctimensec;
+ long __unused[3];
+ };
+
/* Definition of `struct stat' used by glibc 2.0. */
struct glibc2_stat
{
@@ -38,4 +63,26 @@ struct glibc2_stat
unsigned int st_gen;
};
+/* Definition of `struct stat' used by glibc 2.1. */
+struct glibc21_stat
+ {
+ __dev_t st_dev;
+ __ino64_t st_ino;
+ __mode_t st_mode;
+ __nlink_t st_nlink;
+ __uid_t st_uid;
+ __gid_t st_gid;
+ __dev_t st_rdev;
+ __off_t st_size;
+ __time_t st_atime;
+ __time_t st_mtime;
+ __time_t st_ctime;
+ __blkcnt64_t st_blocks;
+ __blksize_t st_blksize;
+ unsigned int st_flags;
+ unsigned int st_gen;
+ int __pad3;
+ long __unused[4];
+ };
+
#define XSTAT_IS_XSTAT64 1
diff --git a/sysdeps/unix/sysv/linux/alpha/lxstat.c b/sysdeps/unix/sysv/linux/alpha/lxstat.c
new file mode 100644
index 0000000000..38fac2e2b2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/lxstat.c
@@ -0,0 +1,64 @@
+/* lxstat using old-style Unix stat system call.
+ Copyright (C) 2004 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define __lxstat64 __lxstat64_disable
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <kernel_stat.h>
+#include <sysdep.h>
+#include <sys/syscall.h>
+#include <xstatconv.h>
+
+#undef __lxstat64
+
+
+/* Get information about the file NAME in BUF. */
+int
+__lxstat (int vers, const char *name, struct stat *buf)
+{
+ INTERNAL_SYSCALL_DECL (err);
+ int result, errno_out;
+ struct kernel_stat kbuf;
+
+ if (vers == _STAT_VER_KERNEL64 && !__libc_missing_axp_stat64)
+ {
+ result = INTERNAL_SYSCALL (lstat64, err, 2, name, buf);
+ if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+ return result;
+ errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
+ if (errno_out != ENOSYS)
+ goto fail;
+ __libc_missing_axp_stat64 = 1;
+ }
+
+ result = INTERNAL_SYSCALL (lstat, err, 2, name, &kbuf);
+ if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+ return __xstat_conv (vers, &kbuf, buf);
+ errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
+
+ fail:
+ __set_errno (errno_out);
+ return -1;
+}
+hidden_def (__lxstat)
+weak_alias (__lxstat, _lxstat);
+strong_alias (__lxstat, __lxstat64);
+hidden_ver (__lxstat, __lxstat64)
diff --git a/sysdeps/unix/sysv/linux/alpha/xstat.c b/sysdeps/unix/sysv/linux/alpha/xstat.c
new file mode 100644
index 0000000000..b7488e425c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/xstat.c
@@ -0,0 +1,64 @@
+/* xstat using old-style Unix stat system call.
+ Copyright (C) 2004 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define __xstat64 __xstat64_disable
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <kernel_stat.h>
+#include <sysdep.h>
+#include <sys/syscall.h>
+#include <xstatconv.h>
+
+#undef __xstat64
+
+
+/* Get information about the file NAME in BUF. */
+int
+__xstat (int vers, const char *name, struct stat *buf)
+{
+ INTERNAL_SYSCALL_DECL (err);
+ int result, errno_out;
+ struct kernel_stat kbuf;
+
+ if (vers == _STAT_VER_KERNEL64 && !__libc_missing_axp_stat64)
+ {
+ result = INTERNAL_SYSCALL (stat64, err, 2, name, buf);
+ if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+ return result;
+ errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
+ if (errno_out != ENOSYS)
+ goto fail;
+ __libc_missing_axp_stat64 = 1;
+ }
+
+ result = INTERNAL_SYSCALL (stat, err, 2, name, &kbuf);
+ if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+ return __xstat_conv (vers, &kbuf, buf);
+ errno_out = INTERNAL_SYSCALL_ERRNO (result, err);
+
+ fail:
+ __set_errno (errno_out);
+ return -1;
+}
+hidden_def (__xstat)
+weak_alias (__xstat, _xstat);
+strong_alias (__xstat, __xstat64);
+hidden_ver (__xstat, __xstat64)
diff --git a/sysdeps/unix/sysv/linux/alpha/xstatconv.c b/sysdeps/unix/sysv/linux/alpha/xstatconv.c
index 3f15dfef2e..a193b62ad1 100644
--- a/sysdeps/unix/sysv/linux/alpha/xstatconv.c
+++ b/sysdeps/unix/sysv/linux/alpha/xstatconv.c
@@ -1,5 +1,5 @@
/* Convert between the kernel's `struct stat' format, and libc's.
- Copyright (C) 1997, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2003, 2004 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
@@ -24,15 +24,14 @@
#include <xstatconv.h>
+int __libc_missing_axp_stat64;
+
int
__xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
{
switch (vers)
{
case _STAT_VER_KERNEL:
- /* Nothing to do. The struct is in the form the kernel expects.
- We should have short-circuted before we got here, but for
- completeness... */
*(struct kernel_stat *) ubuf = *kbuf;
break;
@@ -60,7 +59,7 @@ __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
case _STAT_VER_GLIBC2_1:
{
- struct stat64 *buf = ubuf;
+ struct glibc21_stat *buf = ubuf;
buf->st_dev = kbuf->st_dev;
buf->st_ino = kbuf->st_ino;
@@ -85,6 +84,36 @@ __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
}
break;
+ case _STAT_VER_GLIBC2_3_4:
+ {
+ struct stat64 *buf = ubuf;
+
+ buf->st_dev = kbuf->st_dev;
+ buf->st_ino = kbuf->st_ino;
+ buf->st_rdev = kbuf->st_rdev;
+ buf->st_size = kbuf->st_size;
+ buf->st_blocks = kbuf->st_blocks;
+
+ buf->st_mode = kbuf->st_mode;
+ buf->st_uid = kbuf->st_uid;
+ buf->st_gid = kbuf->st_gid;
+ buf->st_blksize = kbuf->st_blksize;
+ buf->st_nlink = kbuf->st_nlink;
+ buf->__pad0 = 0;
+
+ buf->st_atime = kbuf->st_atime;
+ buf->st_atimensec = 0;
+ buf->st_mtime = kbuf->st_mtime;
+ buf->st_mtimensec = 0;
+ buf->st_ctime = kbuf->st_ctime;
+ buf->st_ctimensec = 0;
+
+ buf->__unused[0] = 0;
+ buf->__unused[1] = 0;
+ buf->__unused[2] = 0;
+ }
+ break;
+
default:
__set_errno (EINVAL);
return -1;
diff --git a/sysdeps/unix/sysv/linux/alpha/xstatconv.h b/sysdeps/unix/sysv/linux/alpha/xstatconv.h
new file mode 100644
index 0000000000..846bb02994
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/xstatconv.h
@@ -0,0 +1,24 @@
+/* Convert between the kernel's `struct stat' format, and libc's.
+ Copyright (C) 2004 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "kernel-features.h"
+
+extern int __libc_missing_axp_stat64 attribute_hidden;
+extern int __xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
+ attribute_hidden;