diff options
Diffstat (limited to 'sysdeps/unix/sysv/linux')
| -rw-r--r-- | sysdeps/unix/sysv/linux/Dist | 1 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/Makefile | 4 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/alpha/xstatconv.c | 10 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/fpathconf.c | 6 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/fxstat.c | 6 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/fxstat64.c | 6 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/i386/fxstat.c | 10 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/i386/lxstat.c | 10 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/i386/xstat.c | 10 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/ifreq.c | 93 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/ifreq.h | 74 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/lxstat.c | 6 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/lxstat64.c | 6 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/pathconf.c | 137 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/pathconf.h | 125 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/xstat.c | 7 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/xstat64.c | 6 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/xstatconv.c | 20 | ||||
| -rw-r--r-- | sysdeps/unix/sysv/linux/xstatconv.h | 25 |
19 files changed, 319 insertions, 243 deletions
diff --git a/sysdeps/unix/sysv/linux/Dist b/sysdeps/unix/sysv/linux/Dist index f9f6a1a5f8..1cd482c1ff 100644 --- a/sysdeps/unix/sysv/linux/Dist +++ b/sysdeps/unix/sysv/linux/Dist @@ -78,6 +78,7 @@ sys/ultrasound.h sys/user.h sys/vt.h xstatconv.c +xstatconv.h getdents64.c umount.S umount2.S diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 90671e404e..1085fe0d81 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -133,6 +133,10 @@ ifeq ($(subdir),nis) CFLAGS-ypclnt.c = -DUSE_BINDINGDIR=1 endif +ifeq ($(subdir),io) +sysdep_routines += xstatconv +endif + ifeq ($(subdir),elf) sysdep-rtld-routines += dl-brk dl-sbrk diff --git a/sysdeps/unix/sysv/linux/alpha/xstatconv.c b/sysdeps/unix/sysv/linux/alpha/xstatconv.c index 31fe7a52ec..1084049dbe 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 Free Software Foundation, Inc. + Copyright (C) 1997, 2003 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 @@ -17,11 +17,15 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include <errno.h> #include <string.h> +#include <sys/stat.h> +#include <xstatconv.h> -static inline int -xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf) + +int +__xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf) { switch (vers) { diff --git a/sysdeps/unix/sysv/linux/fpathconf.c b/sysdeps/unix/sysv/linux/fpathconf.c index 9eca7175cc..c1cdb1b899 100644 --- a/sysdeps/unix/sysv/linux/fpathconf.c +++ b/sysdeps/unix/sysv/linux/fpathconf.c @@ -37,13 +37,13 @@ __fpathconf (fd, name) switch (name) { case _PC_LINK_MAX: - return statfs_link_max (__fstatfs (fd, &fsbuf), &fsbuf); + return __statfs_link_max (__fstatfs (fd, &fsbuf), &fsbuf); case _PC_FILESIZEBITS: - return statfs_filesize_max (__fstatfs (fd, &fsbuf), &fsbuf); + return __statfs_filesize_max (__fstatfs (fd, &fsbuf), &fsbuf); case _PC_2_SYMLINKS: - return statfs_symlinks (__fstatfs (fd, &fsbuf), &fsbuf); + return __statfs_symlinks (__fstatfs (fd, &fsbuf), &fsbuf); default: return posix_fpathconf (fd, name); diff --git a/sysdeps/unix/sysv/linux/fxstat.c b/sysdeps/unix/sysv/linux/fxstat.c index b19450598d..6acafa261b 100644 --- a/sysdeps/unix/sysv/linux/fxstat.c +++ b/sysdeps/unix/sysv/linux/fxstat.c @@ -1,5 +1,5 @@ /* fxstat using old-style Unix fstat system call. - Copyright (C) 1991,1995-1998,2000,2002 Free Software Foundation, Inc. + Copyright (C) 1991,1995-1998,2000,2002,2003 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 @@ -31,7 +31,7 @@ #include <sys/syscall.h> #include <bp-checks.h> -#include <xstatconv.c> +#include <xstatconv.h> extern int __syscall_fstat (int, struct kernel_stat *__unbounded); @@ -51,7 +51,7 @@ __fxstat (int vers, int fd, struct stat *buf) result = INLINE_SYSCALL (fstat, 2, fd, __ptrvalue (&kbuf)); if (result == 0) - result = xstat_conv (vers, &kbuf, buf); + result = __xstat_conv (vers, &kbuf, buf); return result; #endif diff --git a/sysdeps/unix/sysv/linux/fxstat64.c b/sysdeps/unix/sysv/linux/fxstat64.c index f5e16050b6..27e8ac2711 100644 --- a/sysdeps/unix/sysv/linux/fxstat64.c +++ b/sysdeps/unix/sysv/linux/fxstat64.c @@ -1,5 +1,5 @@ /* fxstat64 using old-style Unix fstat system call. - Copyright (C) 1997,1998,1999,2000,2001,2002 Free Software Foundation, Inc. + Copyright (C) 1997-2002, 2003 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 @@ -29,7 +29,7 @@ #include "kernel-features.h" #if __ASSUME_STAT64_SYSCALL == 0 -# include <xstatconv.c> +# include <xstatconv.h> #endif extern int __syscall_fstat (int, struct kernel_stat *__unbounded); @@ -78,7 +78,7 @@ ___fxstat64 (int vers, int fd, struct stat64 *buf) # endif result = INLINE_SYSCALL (fstat, 2, fd, __ptrvalue (&kbuf)); if (result == 0) - result = xstat64_conv (vers, &kbuf, buf); + result = __xstat64_conv (vers, &kbuf, buf); return result; #endif diff --git a/sysdeps/unix/sysv/linux/i386/fxstat.c b/sysdeps/unix/sysv/linux/i386/fxstat.c index 86dbd71175..13a3bc77b7 100644 --- a/sysdeps/unix/sysv/linux/i386/fxstat.c +++ b/sysdeps/unix/sysv/linux/i386/fxstat.c @@ -1,5 +1,5 @@ /* fxstat using old-style Unix fstat system call. - Copyright (C) 1991,95,96,97,98,2000,2002 Free Software Foundation, Inc. + Copyright (C) 1991,1995-1998,2000,2002,2003 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 @@ -32,7 +32,7 @@ #include "kernel-features.h" -#include <xstatconv.c> +#include <xstatconv.h> extern int __syscall_fstat (int, struct kernel_stat *__unbounded); @@ -62,7 +62,7 @@ __fxstat (int vers, int fd, struct stat *buf) result = INLINE_SYSCALL (fstat64, 2, fd, __ptrvalue (&buf64)); if (result == 0) - result = xstat32_conv (vers, &buf64, buf); + result = __xstat32_conv (vers, &buf64, buf); return result; } #else @@ -77,7 +77,7 @@ __fxstat (int vers, int fd, struct stat *buf) result = INLINE_SYSCALL (fstat64, 2, fd, __ptrvalue (&buf64)); if (result == 0) - result = xstat32_conv (vers, &buf64, buf); + result = __xstat32_conv (vers, &buf64, buf); if (result != -1 || errno != ENOSYS) return result; @@ -88,7 +88,7 @@ __fxstat (int vers, int fd, struct stat *buf) result = INLINE_SYSCALL (fstat, 2, fd, __ptrvalue (&kbuf)); if (result == 0) - result = xstat_conv (vers, &kbuf, buf); + result = __xstat_conv (vers, &kbuf, buf); return result; #endif /* __ASSUME_STAT64_SYSCALL */ diff --git a/sysdeps/unix/sysv/linux/i386/lxstat.c b/sysdeps/unix/sysv/linux/i386/lxstat.c index 0da6312fa4..adf55dc5e8 100644 --- a/sysdeps/unix/sysv/linux/i386/lxstat.c +++ b/sysdeps/unix/sysv/linux/i386/lxstat.c @@ -1,5 +1,5 @@ /* lxstat using old-style Unix lstat system call. - Copyright (C) 1991,95,96,97,98,2000,2002 Free Software Foundation, Inc. + Copyright (C) 1991,95,96,97,98,2000,2002,2003 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 @@ -32,7 +32,7 @@ #include "kernel-features.h" -#include <xstatconv.c> +#include <xstatconv.h> extern int __syscall_lstat (const char *__unbounded, struct kernel_stat *__unbounded); @@ -65,7 +65,7 @@ __lxstat (int vers, const char *name, struct stat *buf) result = INLINE_SYSCALL (lstat64, 2, CHECK_STRING (name), __ptrvalue (&buf64)); if (result == 0) - result = xstat32_conv (vers, &buf64, buf); + result = __xstat32_conv (vers, &buf64, buf); return result; } #else @@ -79,7 +79,7 @@ __lxstat (int vers, const char *name, struct stat *buf) result = INLINE_SYSCALL (lstat64, 2, CHECK_STRING (name), __ptrvalue (&buf64)); if (result == 0) - result = xstat32_conv (vers, &buf64, buf); + result = __xstat32_conv (vers, &buf64, buf); if (result != -1 || errno != ENOSYS) return result; @@ -90,7 +90,7 @@ __lxstat (int vers, const char *name, struct stat *buf) result = INLINE_SYSCALL (lstat, 2, CHECK_STRING (name), __ptrvalue (&kbuf)); if (result == 0) - result = xstat_conv (vers, &kbuf, buf); + result = __xstat_conv (vers, &kbuf, buf); return result; #endif diff --git a/sysdeps/unix/sysv/linux/i386/xstat.c b/sysdeps/unix/sysv/linux/i386/xstat.c index cc383ec2fb..5442fc42b6 100644 --- a/sysdeps/unix/sysv/linux/i386/xstat.c +++ b/sysdeps/unix/sysv/linux/i386/xstat.c @@ -1,5 +1,5 @@ /* xstat using old-style Unix stat system call. - Copyright (C) 1991,95,96,97,98,2000,2002 Free Software Foundation, Inc. + Copyright (C) 1991,95,96,97,98,2000,2002,2003 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 @@ -32,7 +32,7 @@ #include "kernel-features.h" -#include <xstatconv.c> +#include <xstatconv.h> extern int __syscall_stat (const char *__unbounded, struct kernel_stat *__unbounded); @@ -65,7 +65,7 @@ __xstat (int vers, const char *name, struct stat *buf) result = INLINE_SYSCALL (stat64, 2, CHECK_STRING (name), __ptrvalue (&buf64)); if (result == 0) - result = xstat32_conv (vers, &buf64, buf); + result = __xstat32_conv (vers, &buf64, buf); return result; } #else @@ -79,7 +79,7 @@ __xstat (int vers, const char *name, struct stat *buf) result = INLINE_SYSCALL (stat64, 2, CHECK_STRING (name), __ptrvalue (&buf64)); if (result == 0) - result = xstat32_conv (vers, &buf64, buf); + result = __xstat32_conv (vers, &buf64, buf); if (result != -1 || errno != ENOSYS) return result; @@ -89,7 +89,7 @@ __xstat (int vers, const char *name, struct stat *buf) # endif result = INLINE_SYSCALL (stat, 2, CHECK_STRING (name), __ptrvalue (&kbuf)); if (result == 0) - result = xstat_conv (vers, &kbuf, buf); + result = __xstat_conv (vers, &kbuf, buf); return result; #endif /* __ASSUME_STAT64_SYSCALL */ diff --git a/sysdeps/unix/sysv/linux/ifreq.c b/sysdeps/unix/sysv/linux/ifreq.c new file mode 100644 index 0000000000..ad408df070 --- /dev/null +++ b/sysdeps/unix/sysv/linux/ifreq.c @@ -0,0 +1,93 @@ +/* Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Jaeger <aj@suse.de>. + + 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 "ifreq.h" + + +void +__ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd) +{ + int fd = sockfd; + struct ifconf ifc; + int rq_len; + int nifs; +# define RQ_IFS 4 + + if (fd < 0) + fd = __opensock (); + if (fd < 0) + { + *num_ifs = 0; + *ifreqs = NULL; + return; + } + + ifc.ifc_buf = NULL; + + /* We may be able to get the needed buffer size directly, rather than + guessing. */ + if (! old_siocgifconf) + { + ifc.ifc_buf = NULL; + ifc.ifc_len = 0; + if (__ioctl (fd, SIOCGIFCONF, &ifc) < 0 || ifc.ifc_len == 0) + { +# if __ASSUME_SIOCGIFNAME == 0 + old_siocgifconf = 1; +# endif + rq_len = RQ_IFS * sizeof (struct ifreq); + } + else + rq_len = ifc.ifc_len; + } + else + rq_len = RQ_IFS * sizeof (struct ifreq); + + /* Read all the interfaces out of the kernel. */ + while (1) + { + ifc.ifc_len = rq_len; + ifc.ifc_buf = realloc (ifc.ifc_buf, ifc.ifc_len); + if (ifc.ifc_buf == NULL || __ioctl (fd, SIOCGIFCONF, &ifc) < 0) + { + if (ifc.ifc_buf) + free (ifc.ifc_buf); + + if (fd != sockfd) + __close (fd); + + *num_ifs = 0; + *ifreqs = NULL; + return; + } + + if (!old_siocgifconf || ifc.ifc_len < rq_len) + break; + + rq_len *= 2; + } + + nifs = ifc.ifc_len / sizeof (struct ifreq); + + if (fd != sockfd) + __close (fd); + + *num_ifs = nifs; + *ifreqs = realloc (ifc.ifc_buf, nifs * sizeof (struct ifreq)); +} diff --git a/sysdeps/unix/sysv/linux/ifreq.h b/sysdeps/unix/sysv/linux/ifreq.h index f498e5c32a..9e4f6622e9 100644 --- a/sysdeps/unix/sysv/linux/ifreq.h +++ b/sysdeps/unix/sysv/linux/ifreq.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1999,2002 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger <aj@suse.de>. @@ -33,77 +33,7 @@ static int old_siocgifconf; #endif -static inline void -__ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd) -{ - int fd = sockfd; - struct ifconf ifc; - int rq_len; - int nifs; -# define RQ_IFS 4 - - if (fd < 0) - fd = __opensock (); - if (fd < 0) - { - *num_ifs = 0; - *ifreqs = NULL; - return; - } - - ifc.ifc_buf = NULL; - - /* We may be able to get the needed buffer size directly, rather than - guessing. */ - if (! old_siocgifconf) - { - ifc.ifc_buf = NULL; - ifc.ifc_len = 0; - if (__ioctl (fd, SIOCGIFCONF, &ifc) < 0 || ifc.ifc_len == 0) - { -# if __ASSUME_SIOCGIFNAME == 0 - old_siocgifconf = 1; -# endif - rq_len = RQ_IFS * sizeof (struct ifreq); - } - else - rq_len = ifc.ifc_len; - } - else - rq_len = RQ_IFS * sizeof (struct ifreq); - - /* Read all the interfaces out of the kernel. */ - while (1) - { - ifc.ifc_len = rq_len; - ifc.ifc_buf = realloc (ifc.ifc_buf, ifc.ifc_len); - if (ifc.ifc_buf == NULL || __ioctl (fd, SIOCGIFCONF, &ifc) < 0) - { - if (ifc.ifc_buf) - free (ifc.ifc_buf); - - if (fd != sockfd) - __close (fd); - - *num_ifs = 0; - *ifreqs = NULL; - return; - } - - if (!old_siocgifconf || ifc.ifc_len < rq_len) - break; - - rq_len *= 2; - } - - nifs = ifc.ifc_len / sizeof (struct ifreq); - - if (fd != sockfd) - __close (fd); - - *num_ifs = nifs; - *ifreqs = realloc (ifc.ifc_buf, nifs * sizeof (struct ifreq)); -} +extern void __ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd); static inline struct ifreq * __if_nextreq (struct ifreq *ifr) diff --git a/sysdeps/unix/sysv/linux/lxstat.c b/sysdeps/unix/sysv/linux/lxstat.c index ece1a85f30..156850330e 100644 --- a/sysdeps/unix/sysv/linux/lxstat.c +++ b/sysdeps/unix/sysv/linux/lxstat.c @@ -1,5 +1,5 @@ /* lxstat using old-style Unix lstat system call. - Copyright (C) 1991,1995-1998,2000,2002 Free Software Foundation, Inc. + Copyright (C) 1991,1995-1998,2000,2002,2003 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 @@ -30,7 +30,7 @@ #include <sys/syscall.h> #include <bp-checks.h> -#include <xstatconv.c> +#include <xstatconv.h> extern int __syscall_lstat (const char *__unbounded, struct kernel_stat *__unbounded); @@ -52,7 +52,7 @@ __lxstat (int vers, const char *name, struct stat *buf) result = INLINE_SYSCALL (lstat, 2, CHECK_STRING (name), __ptrvalue (&kbuf)); if (result == 0) - result = xstat_conv (vers, &kbuf, buf); + result = __xstat_conv (vers, &kbuf, buf); return result; #endif diff --git a/sysdeps/unix/sysv/linux/lxstat64.c b/sysdeps/unix/sysv/linux/lxstat64.c index e7f488848c..58ff6fff61 100644 --- a/sysdeps/unix/sysv/linux/lxstat64.c +++ b/sysdeps/unix/sysv/linux/lxstat64.c @@ -1,5 +1,5 @@ /* lxstat64 using old-style Unix lstat system call. - Copyright (C) 1997,1998,1999,2000,2001,2002 Free Software Foundation, Inc. + Copyright (C) 1997-2002,2003 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 @@ -29,7 +29,7 @@ #include "kernel-features.h" #if __ASSUME_STAT64_SYSCALL == 0 -# include <xstatconv.c> +# include <xstatconv.h> #endif extern int __syscall_lstat (const char *__unbounded, @@ -79,7 +79,7 @@ ___lxstat64 (int vers, const char *name, struct stat64 *buf) # endif result = INLINE_SYSCALL (lstat, 2, CHECK_STRING (name), __ptrvalue (&kbuf)); if (result == 0) - result = xstat64_conv (vers, &kbuf, buf); + result = __xstat64_conv (vers, &kbuf, buf); return result; #endif diff --git a/sysdeps/unix/sysv/linux/pathconf.c b/sysdeps/unix/sysv/linux/pathconf.c index b4886158f3..d4159753a6 100644 --- a/sysdeps/unix/sysv/linux/pathconf.c +++ b/sysdeps/unix/sysv/linux/pathconf.c @@ -17,7 +17,10 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include <unistd.h> +#include <errno.h> #include "pathconf.h" +#include "linux_fsinfo.h" static long int posix_pathconf (const char *file, int name); @@ -35,15 +38,143 @@ __pathconf (const char *file, int name) switch (name) { case _PC_LINK_MAX: - return statfs_link_max (__statfs (file, &fsbuf), &fsbuf); + return __statfs_link_max (__statfs (file, &fsbuf), &fsbuf); case _PC_FILESIZEBITS: - return statfs_filesize_max (__statfs (file, &fsbuf), &fsbuf); + return __statfs_filesize_max (__statfs (file, &fsbuf), &fsbuf); case _PC_2_SYMLINKS: - return statfs_symlinks (__statfs (file, &fsbuf), &fsbuf); + return __statfs_symlinks (__statfs (file, &fsbuf), &fsbuf); default: return posix_pathconf (file, name); } } + + +/* Used like: return statfs_link_max (__statfs (name, &buf), &buf); */ +long int +__statfs_link_max (int result, const struct statfs *fsbuf) +{ + if (result < 0) |
