diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-11-15 08:22:03 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2005-11-15 08:22:03 +0000 |
commit | 22d7fbdbae4032639461a7a081762a05deee0529 (patch) | |
tree | ff70bd4613f1f05823b2417b2687449d73ac45b0 /sysdeps/generic | |
parent | 1beea155aecf2e7d6bfa1399b7c0f4f53dde408c (diff) | |
download | glibc-22d7fbdbae4032639461a7a081762a05deee0529.tar glibc-22d7fbdbae4032639461a7a081762a05deee0529.tar.gz glibc-22d7fbdbae4032639461a7a081762a05deee0529.tar.bz2 glibc-22d7fbdbae4032639461a7a081762a05deee0529.zip |
Updated to fedora-glibc-20051115T0809
Diffstat (limited to 'sysdeps/generic')
-rw-r--r-- | sysdeps/generic/check_fds.c | 32 | ||||
-rw-r--r-- | sysdeps/generic/errlist.c | 6 | ||||
-rw-r--r-- | sysdeps/generic/fchownat.c | 51 | ||||
-rw-r--r-- | sysdeps/generic/futimesat.c | 52 | ||||
-rw-r--r-- | sysdeps/generic/fxstatat.c | 49 | ||||
-rw-r--r-- | sysdeps/generic/fxstatat64.c | 50 | ||||
-rw-r--r-- | sysdeps/generic/getenv.c | 5 | ||||
-rw-r--r-- | sysdeps/generic/getgroups.c | 4 | ||||
-rw-r--r-- | sysdeps/generic/init-posix.c | 28 | ||||
-rw-r--r-- | sysdeps/generic/libc-tls.c | 5 | ||||
-rw-r--r-- | sysdeps/generic/openat.c | 69 | ||||
-rw-r--r-- | sysdeps/generic/openat64.c | 69 | ||||
-rw-r--r-- | sysdeps/generic/renameat.c | 50 | ||||
-rw-r--r-- | sysdeps/generic/unlinkat.c | 49 |
14 files changed, 469 insertions, 50 deletions
diff --git a/sysdeps/generic/check_fds.c b/sysdeps/generic/check_fds.c index 5ae3feee3e..10ba3da395 100644 --- a/sysdeps/generic/check_fds.c +++ b/sysdeps/generic/check_fds.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2002, 2003, 2005 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 @@ -44,12 +44,26 @@ check_one_fd (int fd, int mode) if (__builtin_expect (__libc_fcntl (fd, F_GETFD), 0) == -1 && errno == EBADF) { - struct stat64 st; + const char *name; + dev_t dev; + + /* For writable descriptors we use /dev/full. */ + if ((mode & O_ACCMODE) == O_WRONLY) + { + name = _PATH_DEV "full"; + dev = makedev (DEV_FULL_MAJOR, DEV_FULL_MINOR); + } + else + { + name = _PATH_DEVNULL; + dev = makedev (DEV_NULL_MAJOR, DEV_NULL_MINOR); + } /* Something is wrong with this descriptor, it's probably not opened. Open /dev/null so that the SUID program we are about to start does not accidently use this descriptor. */ - int nullfd = open_not_cancel (_PATH_DEVNULL, mode, 0); + int nullfd = open_not_cancel (name, mode, 0); + /* We are very paranoid here. With all means we try to ensure that we are actually opening the /dev/null device and nothing else. @@ -57,13 +71,11 @@ check_one_fd (int fd, int mode) Note that the following code assumes that STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO are the three lowest file decsriptor numbers, in this order. */ + struct stat64 st; if (__builtin_expect (nullfd != fd, 0) || __builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) != 0 || __builtin_expect (S_ISCHR (st.st_mode), 1) == 0 -#if defined DEV_NULL_MAJOR && defined DEV_NULL_MINOR - || st.st_rdev != makedev (DEV_NULL_MAJOR, DEV_NULL_MINOR) -#endif - ) + || st.st_rdev != dev) /* We cannot even give an error message here since it would run into the same problems. */ while (1) @@ -84,7 +96,7 @@ __libc_check_standard_fds (void) # define O_NOFOLLOW 0 #endif /* Check all three standard file descriptors. */ - check_one_fd (STDIN_FILENO, O_RDONLY | O_NOFOLLOW); - check_one_fd (STDOUT_FILENO, O_RDWR | O_NOFOLLOW); - check_one_fd (STDERR_FILENO, O_RDWR | O_NOFOLLOW); + check_one_fd (STDIN_FILENO, O_WRONLY | O_NOFOLLOW); + check_one_fd (STDOUT_FILENO, O_RDONLY | O_NOFOLLOW); + check_one_fd (STDERR_FILENO, O_RDONLY | O_NOFOLLOW); } diff --git a/sysdeps/generic/errlist.c b/sysdeps/generic/errlist.c index 6b459ee40a..6a834fc329 100644 --- a/sysdeps/generic/errlist.c +++ b/sysdeps/generic/errlist.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1994, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994, 1997, 2005 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 @@ -18,10 +18,6 @@ #include <stddef.h> -#ifndef HAVE_GNU_LD -#define _sys_errlist sys_errlist -#define _sys_nerr sys_nerr -#endif const char *const _sys_errlist[] = { diff --git a/sysdeps/generic/fchownat.c b/sysdeps/generic/fchownat.c new file mode 100644 index 0000000000..f6921c9012 --- /dev/null +++ b/sysdeps/generic/fchownat.c @@ -0,0 +1,51 @@ +/* Copyright (C) 2005 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 <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <unistd.h> +#include <sys/types.h> + +/* Change the owner and group of FILE. */ +int +fchownat (fd, file, owner, group, flag) + int fd; + const char *file; + uid_t owner; + gid_t group; + int flag; +{ + if (file == NULL || (flag & ~AT_SYMLINK_NOFOLLOW) != 0) + { + __set_errno (EINVAL); + return -1; + } + + if (fd < 0 && fd != AT_FDCWD) + { + __set_errno (EBADF); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (fchownat) + +#include <stub-tag.h> diff --git a/sysdeps/generic/futimesat.c b/sysdeps/generic/futimesat.c new file mode 100644 index 0000000000..33d170862a --- /dev/null +++ b/sysdeps/generic/futimesat.c @@ -0,0 +1,52 @@ +/* Copyright (C) 2005 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 <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <sys/time.h> + + +/* Change the access time of FILE relative to FD to TVP[0] and + the modification time of FILE to TVP[1]. */ +int +futimesat (fd, file, tvp) + int fd; + const char *file; + const struct timeval tvp[2]; +{ + if (fd < 0 && fd != AT_FDCWD) + { + __set_errno (EBADF); + return -1; + } + + if (file == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} + +weak_alias (__utimes, utimes) + +stub_warning (utimes) +#include <stub-tag.h> diff --git a/sysdeps/generic/fxstatat.c b/sysdeps/generic/fxstatat.c new file mode 100644 index 0000000000..62f7fe3efb --- /dev/null +++ b/sysdeps/generic/fxstatat.c @@ -0,0 +1,49 @@ +/* Copyright (C) 2005 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 <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <sys/stat.h> + +/* Get information about the file descriptor FD in BUF. */ +int +__fxstatat (int vers, int fd, const char *filename, struct stat *buf, int flag) +{ + if (vers != _STAT_VER) + { + __set_errno (EINVAL); + return -1; + } + + if (fd < 0 && fd != AT_FDCWD) + { + __set_errno (EBADF); + return -1; + } + if (buf == NULL || (flag & ~AT_SYMLINK_NOFOLLOW) != 0) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (fstatat) +#include <stub-tag.h> diff --git a/sysdeps/generic/fxstatat64.c b/sysdeps/generic/fxstatat64.c new file mode 100644 index 0000000000..ba95b73e81 --- /dev/null +++ b/sysdeps/generic/fxstatat64.c @@ -0,0 +1,50 @@ +/* Copyright (C) 2005 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 <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <sys/stat.h> + +/* Get information about the file descriptor FD in BUF. */ +int +__fxstatat64 (int vers, int fd, const char *filename, struct stat64 *buf, + int flag) +{ + if (vers != _STAT_VER) + { + __set_errno (EINVAL); + return -1; + } + + if (fd < 0 && fd != AT_FDCWD) + { + __set_errno (EBADF); + return -1; + } + if (buf == NULL || (flag & ~AT_SYMLINK_NOFOLLOW) != 0) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (fstatat64) +#include <stub-tag.h> diff --git a/sysdeps/generic/getenv.c b/sysdeps/generic/getenv.c index d659f66022..6cdfe2b266 100644 --- a/sysdeps/generic/getenv.c +++ b/sysdeps/generic/getenv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,94,96,98,99,2002 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,94,96,98,99,2002,2005 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 @@ -23,9 +23,6 @@ #include <string.h> #include <unistd.h> -#ifndef HAVE_GNU_LD -#define __environ environ -#endif /* Return the value of the environment variable NAME. This implementation is tuned a bit in that it assumes no environment variable has an empty diff --git a/sysdeps/generic/getgroups.c b/sysdeps/generic/getgroups.c index d9970f0e6d..d5868cc1b8 100644 --- a/sysdeps/generic/getgroups.c +++ b/sysdeps/generic/getgroups.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991,1992,1995,1996,1997,2005 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 @@ -40,7 +40,7 @@ __getgroups (size, list) return -1; } -#if defined (HAVE_GNU_LD) && !(defined (NGROUPS_MAX) && NGROUPS_MAX == 0) +#if !(defined (NGROUPS_MAX) && NGROUPS_MAX == 0) stub_warning (getgroups); #endif diff --git a/sysdeps/generic/init-posix.c b/sysdeps/generic/init-posix.c index ae9e1075d1..0c2b717e6d 100644 --- a/sysdeps/generic/init-posix.c +++ b/sysdeps/generic/init-posix.c @@ -1,27 +1 @@ -/* Copyright (C) 1991, 1995, 1997 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. */ - -#ifndef HAVE_GNU_LD - -void -__init_posix (void) -{ - return; -} - -#endif +/* Nothing to do. */ diff --git a/sysdeps/generic/libc-tls.c b/sysdeps/generic/libc-tls.c index bfb6de0f73..3544e396da 100644 --- a/sysdeps/generic/libc-tls.c +++ b/sysdeps/generic/libc-tls.c @@ -60,8 +60,9 @@ bool _dl_tls_dtv_gaps; struct dtv_slotinfo_list *_dl_tls_dtv_slotinfo_list; /* Number of modules in the static TLS block. */ size_t _dl_tls_static_nelem; -/* Size of the static TLS block. */ -size_t _dl_tls_static_size; +/* Size of the static TLS block. Giving this initialized value + preallocates some surplus bytes in the static TLS area. */ +size_t _dl_tls_static_size = 2048; /* Size actually allocated in the static TLS block. */ size_t _dl_tls_static_used; /* Alignment requirement of the static TLS block. */ diff --git a/sysdeps/generic/openat.c b/sysdeps/generic/openat.c new file mode 100644 index 0000000000..f3f699ca23 --- /dev/null +++ b/sysdeps/generic/openat.c @@ -0,0 +1,69 @@ +/* Copyright (C) 2005 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 <errno.h> +#include <fcntl.h> +#include <stdarg.h> +#include <stddef.h> +#include <sys/stat.h> + +/* Open FILE with access OFLAG. Interpret relative paths relative to + the directory associated with FD. If OFLAG includes O_CREAT, a + third argument is the file protection. */ +int +openat (fd, file, oflag) + int fd; + const char *file; + int oflag; +{ + int mode; + + if (file == NULL) + { + __set_errno (EINVAL); + return -1; + } + + if (fd != AT_FDCWD && file[0] != '/') + { + /* Check FD is associated with a directory. */ + struct stat64 st; + if (__fxstat64 (_STAT_VER, fd, &st) != 0) + return -1; + + if (!S_ISDIR (st.st_mode)) + { + __set_errno (ENOTDIR); + return -1; + } + } + + if (oflag & O_CREAT) + { + va_list arg; + va_start (arg, oflag); + mode = va_arg (arg, int); + va_end (arg); + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (openat) + +#include <stub-tag.h> diff --git a/sysdeps/generic/openat64.c b/sysdeps/generic/openat64.c new file mode 100644 index 0000000000..87952d38d6 --- /dev/null +++ b/sysdeps/generic/openat64.c @@ -0,0 +1,69 @@ +/* Copyright (C) 2005 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 <errno.h> +#include <fcntl.h> +#include <stdarg.h> +#include <stddef.h> +#include <sys/stat.h> + +/* Open FILE with access OFLAG. Interpret relative paths relative to + the directory associated with FD. If OFLAG includes O_CREAT, a + third argument is the file protection. */ +int +openat64 (fd, file, oflag) + int fd; + const char *file; + int oflag; +{ + int mode; + + if (file == NULL) + { + __set_errno (EINVAL); + return -1; + } + + if (fd != AT_FDCWD && file[0] != '/') + { + /* Check FD is associated with a directory. */ + struct stat64 st; + if (__fxstat64 (_STAT_VER, fd, &st) != 0) + return -1; + + if (!S_ISDIR (st.st_mode)) + { + __set_errno (ENOTDIR); + return -1; + } + } + + if (oflag & O_CREAT) + { + va_list arg; + va_start (arg, oflag); + mode = va_arg (arg, int); + va_end (arg); + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (openat64) + +#include <stub-tag.h> diff --git a/sysdeps/generic/renameat.c b/sysdeps/generic/renameat.c new file mode 100644 index 0000000000..e8629098df --- /dev/null +++ b/sysdeps/generic/renameat.c @@ -0,0 +1,50 @@ +/* Copyright (C) 2005 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 <errno.h> +#include <fcntl.h> +#include <stdio.h> + + +/* Rename the file OLD relative to OLDFD to NEW relative to NEWFD. */ +int +renameat (oldfd, old, newfd, new) + int oldfd; + const char *old; + int newfd; + const char *new; +{ + if ((oldfd < 0 & oldfd !_ AT_FDCWD) || (newfd < 0 && newfd != AT_FDCWD)) + { + __set_errno (EBADF); + return -1; + } + + if (old == NULL || new == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (renameat) +#include <stub-tag.h> diff --git a/sysdeps/generic/unlinkat.c b/sysdeps/generic/unlinkat.c new file mode 100644 index 0000000000..f9a08b9903 --- /dev/null +++ b/sysdeps/generic/unlinkat.c @@ -0,0 +1,49 @@ +/* Copyright (C) 2005 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 <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <unistd.h> + + +/* Remove the link named NAME. */ +int +unlinkat (fd, name, flag) + int fd; + const char *name; + int flag; +{ + if (name == NULL || (flag & AT_REMOVEDIR) != 0) + { + __set_errno (EINVAL); + return -1; + } + + if (fd < 0 && fd != AT_FDCWD) + { + __set_errno (EBADF); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (unlinkat) + +#include <stub-tag.h> |