diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-07-12 18:26:36 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-07-12 18:26:36 +0000 |
commit | 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch) | |
tree | 2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /io | |
parent | 7d58530341304d403a6626d7f7a1913165fe2f32 (diff) | |
download | glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.gz glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.xz glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip |
2.5-18.1
Diffstat (limited to 'io')
-rw-r--r-- | io/Makefile | 61 | ||||
-rw-r--r-- | io/Versions | 16 | ||||
-rw-r--r-- | io/access.c | 41 | ||||
-rw-r--r-- | io/bug-ftw5.c | 25 | ||||
-rw-r--r-- | io/chdir.c | 40 | ||||
-rw-r--r-- | io/chmod.c | 42 | ||||
-rw-r--r-- | io/chown.c | 45 | ||||
-rw-r--r-- | io/close.c | 40 | ||||
-rw-r--r-- | io/creat.c | 36 | ||||
-rw-r--r-- | io/creat64.c | 31 | ||||
-rw-r--r-- | io/dup.c | 34 | ||||
-rw-r--r-- | io/dup2.c | 48 | ||||
-rw-r--r-- | io/euidaccess.c | 42 | ||||
-rw-r--r-- | io/faccessat.c | 51 | ||||
-rw-r--r-- | io/fchdir.c | 33 | ||||
-rw-r--r-- | io/fchmod.c | 42 | ||||
-rw-r--r-- | io/fchmodat.c | 50 | ||||
-rw-r--r-- | io/fchown.c | 43 | ||||
-rw-r--r-- | io/fchownat.c | 51 | ||||
-rw-r--r-- | io/fcntl.c | 41 | ||||
-rw-r--r-- | io/fcntl.h | 41 | ||||
-rw-r--r-- | io/flock.c | 36 | ||||
-rw-r--r-- | io/fstatat.c | 58 | ||||
-rw-r--r-- | io/fstatat64.c | 58 | ||||
-rw-r--r-- | io/fstatfs.c | 34 | ||||
-rw-r--r-- | io/fstatfs64.c | 32 | ||||
-rw-r--r-- | io/fstatvfs.c | 33 | ||||
-rw-r--r-- | io/fstatvfs64.c | 32 | ||||
-rw-r--r-- | io/fts.c | 54 | ||||
-rw-r--r-- | io/ftw.c | 148 | ||||
-rw-r--r-- | io/ftw64.c | 3 | ||||
-rw-r--r-- | io/fxstat.c | 50 | ||||
-rw-r--r-- | io/fxstat64.c | 49 | ||||
-rw-r--r-- | io/fxstatat.c | 50 | ||||
-rw-r--r-- | io/fxstatat64.c | 51 | ||||
-rw-r--r-- | io/getcwd.c | 40 | ||||
-rw-r--r-- | io/isatty.c | 34 | ||||
-rw-r--r-- | io/lchmod.c | 33 | ||||
-rw-r--r-- | io/lchown.c | 43 | ||||
-rw-r--r-- | io/link.c | 42 | ||||
-rw-r--r-- | io/linkat.c | 52 | ||||
-rw-r--r-- | io/lockf.c | 74 | ||||
-rw-r--r-- | io/lockf64.c | 79 | ||||
-rw-r--r-- | io/lseek64.c | 49 | ||||
-rw-r--r-- | io/lxstat.c | 27 | ||||
-rw-r--r-- | io/lxstat64.c | 39 | ||||
-rw-r--r-- | io/mkdir.c | 43 | ||||
-rw-r--r-- | io/mkdirat.c | 58 | ||||
-rw-r--r-- | io/mkfifo.c | 43 | ||||
-rw-r--r-- | io/mkfifoat.c | 60 | ||||
-rw-r--r-- | io/mknod.c | 62 | ||||
-rw-r--r-- | io/mknodat.c | 60 | ||||
-rw-r--r-- | io/open.c | 54 | ||||
-rw-r--r-- | io/open64.c | 57 | ||||
-rw-r--r-- | io/openat.c | 71 | ||||
-rw-r--r-- | io/openat64.c | 71 | ||||
-rw-r--r-- | io/pipe.c | 44 | ||||
-rw-r--r-- | io/poll.c | 39 | ||||
-rw-r--r-- | io/posix_fadvise.c | 31 | ||||
-rw-r--r-- | io/posix_fadvise64.c | 31 | ||||
-rw-r--r-- | io/posix_fallocate.c | 31 | ||||
-rw-r--r-- | io/posix_fallocate64.c | 31 | ||||
-rw-r--r-- | io/ppoll.c | 76 | ||||
-rw-r--r-- | io/read.c | 49 | ||||
-rw-r--r-- | io/readlink.c | 37 | ||||
-rw-r--r-- | io/readlinkat.c | 51 | ||||
-rw-r--r-- | io/rmdir.c | 41 | ||||
-rw-r--r-- | io/sendfile.c | 33 | ||||
-rw-r--r-- | io/sendfile64.c | 33 | ||||
-rw-r--r-- | io/statfs.c | 35 | ||||
-rw-r--r-- | io/statfs64.c | 32 | ||||
-rw-r--r-- | io/statvfs.c | 34 | ||||
-rw-r--r-- | io/statvfs64.c | 32 | ||||
-rw-r--r-- | io/symlink.c | 42 | ||||
-rw-r--r-- | io/symlinkat.c | 49 | ||||
-rw-r--r-- | io/sys/poll.h | 26 | ||||
-rw-r--r-- | io/sys/sendfile.h | 6 | ||||
-rw-r--r-- | io/sys/stat.h | 100 | ||||
-rw-r--r-- | io/test-lfs.c | 2 | ||||
-rw-r--r-- | io/tst-faccessat.c | 212 | ||||
-rw-r--r-- | io/tst-fchmodat.c | 191 | ||||
-rw-r--r-- | io/tst-fchownat.c | 190 | ||||
-rw-r--r-- | io/tst-fcntl.c | 2 | ||||
-rw-r--r-- | io/tst-fstatat.c | 188 | ||||
-rw-r--r-- | io/tst-futimesat.c | 147 | ||||
-rw-r--r-- | io/tst-linkat.c | 171 | ||||
-rw-r--r-- | io/tst-mkdirat.c | 162 | ||||
-rw-r--r-- | io/tst-mkfifoat.c | 162 | ||||
-rw-r--r-- | io/tst-mknodat.c | 162 | ||||
-rw-r--r-- | io/tst-openat.c | 209 | ||||
-rw-r--r-- | io/tst-readlinkat.c | 136 | ||||
-rw-r--r-- | io/tst-renameat.c | 225 | ||||
-rw-r--r-- | io/tst-symlinkat.c | 164 | ||||
-rw-r--r-- | io/tst-ttyname_r.c | 42 | ||||
-rw-r--r-- | io/tst-unlinkat.c | 178 | ||||
-rw-r--r-- | io/ttyname.c | 38 | ||||
-rw-r--r-- | io/ttyname_r.c | 37 | ||||
-rw-r--r-- | io/umask.c | 34 | ||||
-rw-r--r-- | io/unlink.c | 41 | ||||
-rw-r--r-- | io/unlinkat.c | 49 | ||||
-rw-r--r-- | io/utime.c | 43 | ||||
-rw-r--r-- | io/write.c | 50 | ||||
-rw-r--r-- | io/xmknod.c | 48 | ||||
-rw-r--r-- | io/xmknodat.c | 64 | ||||
-rw-r--r-- | io/xstat.c | 39 | ||||
-rw-r--r-- | io/xstat64.c | 38 |
106 files changed, 6449 insertions, 90 deletions
diff --git a/io/Makefile b/io/Makefile index 906d1e3301..6623551769 100644 --- a/io/Makefile +++ b/io/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1992-2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 1992-2002,2003,2005,2006, 2007 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 @@ -26,38 +26,47 @@ headers := sys/stat.h bits/stat.h sys/statfs.h bits/statfs.h sys/vfs.h \ poll.h sys/poll.h bits/poll.h \ utime.h ftw.h fts.h sys/sendfile.h -routines := \ - utime \ - mkfifo \ - stat fstat lstat mknod stat64 fstat64 lstat64 \ - xstat fxstat lxstat xmknod xstat64 fxstat64 lxstat64 \ - statfs fstatfs statfs64 fstatfs64 \ - statvfs fstatvfs statvfs64 fstatvfs64 \ - umask chmod fchmod lchmod mkdir \ - open open64 close read write lseek lseek64 access euidaccess \ - fcntl flock lockf lockf64 \ - dup dup2 pipe \ - creat creat64 \ - chdir fchdir \ - getcwd getwd getdirname \ - chown fchown lchown \ - ttyname ttyname_r isatty \ - link symlink readlink \ - unlink rmdir \ - ftw ftw64 fts poll \ - posix_fadvise posix_fadvise64 \ - posix_fallocate posix_fallocate64 \ +routines := \ + utime \ + mkfifo mkfifoat \ + stat fstat lstat stat64 fstat64 lstat64 fstatat fstatat64 \ + xstat fxstat lxstat xstat64 fxstat64 lxstat64 \ + mknod mknodat xmknod xmknodat \ + fxstatat fxstatat64 \ + statfs fstatfs statfs64 fstatfs64 \ + statvfs fstatvfs statvfs64 fstatvfs64 \ + umask chmod fchmod lchmod fchmodat \ + mkdir mkdirat \ + open open64 openat openat64 close \ + read write lseek lseek64 access euidaccess faccessat \ + fcntl flock lockf lockf64 \ + dup dup2 pipe \ + creat creat64 \ + chdir fchdir \ + getcwd getwd getdirname \ + chown fchown lchown fchownat \ + ttyname ttyname_r isatty \ + link linkat symlink symlinkat readlink readlinkat \ + unlink unlinkat rmdir \ + ftw ftw64 fts poll ppoll \ + posix_fadvise posix_fadvise64 \ + posix_fallocate posix_fallocate64 \ sendfile sendfile64 # These routines will be omitted from the libc shared object. # Instead the static object files will be included in a special archive # linked against when the shared library will be used. -static-only-routines = stat fstat lstat mknod stat64 fstat64 lstat64 +static-only-routines = stat fstat lstat stat64 fstat64 lstat64 \ + fstatat fstatat64 mknod mknodat others := pwd test-srcs := ftwtest tests := test-utime test-stat test-stat2 test-lfs tst-getcwd \ - tst-fcntl bug-ftw1 bug-ftw2 bug-ftw3 bug-ftw4 tst-statvfs + tst-fcntl bug-ftw1 bug-ftw2 bug-ftw3 bug-ftw4 tst-statvfs \ + tst-openat tst-unlinkat tst-fstatat tst-futimesat \ + tst-renameat tst-fchownat tst-fchmodat tst-faccessat \ + tst-symlinkat tst-linkat tst-readlinkat tst-mkdirat \ + tst-mknodat tst-mkfifoat tst-ttyname_r bug-ftw5 distribute := ftwtest-sh @@ -65,6 +74,7 @@ include ../Rules CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-poll.c = -fexceptions -fasynchronous-unwind-tables +CFLAGS-ppoll.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-lockf.c = -fexceptions CFLAGS-statfs.c = -fexceptions CFLAGS-fstatfs.c = -fexceptions @@ -88,6 +98,9 @@ CFLAGS-mknod.c = -DHAVE_DOT_HIDDEN CFLAGS-stat64.c = -DHAVE_DOT_HIDDEN CFLAGS-fstat64.c = -DHAVE_DOT_HIDDEN CFLAGS-lstat64.c = -DHAVE_DOT_HIDDEN +CFLAGS-fstatat.c = -DHAVE_DOT_HIDDEN +CFLAGS-fstatat64.c = -DHAVE_DOT_HIDDEN +CFLAGS-mknodat.c = -DHAVE_DOT_HIDDEN endif test-stat2-ARGS = Makefile . $(objpfx)test-stat2 diff --git a/io/Versions b/io/Versions index 5b311ee03b..bc9c9d2685 100644 --- a/io/Versions +++ b/io/Versions @@ -97,4 +97,20 @@ libc { # n* nftw; nftw64; } + GLIBC_2.4 { + eaccess; + + faccessat; + fchmodat; + fchownat; + __fxstatat; __fxstatat64; + linkat; + mkdirat; mkfifoat; __xmknodat; + openat; openat64; + readlinkat; + symlinkat; + unlinkat; + + ppoll; + } } diff --git a/io/access.c b/io/access.c new file mode 100644 index 0000000000..c266e945a9 --- /dev/null +++ b/io/access.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1991, 1995, 1996, 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. */ + +#include <errno.h> +#include <stddef.h> +#include <unistd.h> + +/* Test for access to FILE. */ +int +__access (file, type) + const char *file; + int type; +{ + if (file == NULL || (type & ~(R_OK|W_OK|X_OK|F_OK)) != 0) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (access) + +weak_alias (__access, access) +#include <stub-tag.h> diff --git a/io/bug-ftw5.c b/io/bug-ftw5.c new file mode 100644 index 0000000000..c1cd81d30e --- /dev/null +++ b/io/bug-ftw5.c @@ -0,0 +1,25 @@ +#include <errno.h> +#include <ftw.h> +#include <stdio.h> + +static int +fn (const char *file, const struct stat *sb, int flag, struct FTW *s) +{ + puts (file); + return FTW_STOP; +} + +static int +do_test (void) +{ + if (nftw ("/", fn, 0, FTW_CHDIR | FTW_ACTIONRETVAL) < 0) + { + printf ("nftw / FTW_CHDIR: %m\n"); + return 1; + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/io/chdir.c b/io/chdir.c new file mode 100644 index 0000000000..afaeef8787 --- /dev/null +++ b/io/chdir.c @@ -0,0 +1,40 @@ +/* Copyright (C) 1991, 1995, 1996, 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. */ + +#include <errno.h> +#include <stddef.h> +#include <unistd.h> + +/* Change the current directory to PATH. */ +int +__chdir (path) + const char *path; +{ + if (path == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (chdir) + +weak_alias (__chdir, chdir) +#include <stub-tag.h> diff --git a/io/chmod.c b/io/chmod.c new file mode 100644 index 0000000000..38b05127c9 --- /dev/null +++ b/io/chmod.c @@ -0,0 +1,42 @@ +/* Copyright (C) 1991, 1995, 1996, 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. */ + +#include <errno.h> +#include <stddef.h> +#include <sys/stat.h> +#include <sys/types.h> + +/* Change the protections of FILE to MODE. */ +int +__chmod (file, mode) + const char *file; + mode_t mode; +{ + if (file == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (chmod) + +weak_alias (__chmod, chmod) +#include <stub-tag.h> diff --git a/io/chown.c b/io/chown.c new file mode 100644 index 0000000000..0e368f2ac4 --- /dev/null +++ b/io/chown.c @@ -0,0 +1,45 @@ +/* Copyright (C) 1991, 1992, 1995, 1996, 1997, 2002 + 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 <stddef.h> +#include <unistd.h> +#include <sys/types.h> + +/* Change the owner and group of FILE. */ +int +__chown (file, owner, group) + const char *file; + uid_t owner; + gid_t group; +{ + if (file == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__chown) +stub_warning (chown) + +weak_alias (__chown, chown) +#include <stub-tag.h> diff --git a/io/close.c b/io/close.c new file mode 100644 index 0000000000..0856ba851b --- /dev/null +++ b/io/close.c @@ -0,0 +1,40 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 2002 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 <unistd.h> + +/* Close the file descriptor FD. */ +int +__close (fd) + int fd; +{ + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__close) +stub_warning (close) + +weak_alias (__close, close) +#include <stub-tag.h> diff --git a/io/creat.c b/io/creat.c new file mode 100644 index 0000000000..462882415c --- /dev/null +++ b/io/creat.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1991, 1996, 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 + 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 <fcntl.h> +#include <sys/types.h> +#include <sysdep-cancel.h> + +#undef creat + +/* Create FILE with protections MODE. */ +int +__libc_creat (file, mode) + const char *file; + mode_t mode; +{ + return __open (file, O_WRONLY|O_CREAT|O_TRUNC, mode); +} +weak_alias (__libc_creat, creat) + +/* __open handles cancellation. */ +LIBC_CANCEL_HANDLED (); diff --git a/io/creat64.c b/io/creat64.c new file mode 100644 index 0000000000..39f4580571 --- /dev/null +++ b/io/creat64.c @@ -0,0 +1,31 @@ +/* Copyright (C) 1991, 1996, 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. */ + +#include <fcntl.h> +#include <sys/types.h> + +#undef creat + +/* Create FILE with protections MODE. */ +int +creat64 (file, mode) + const char *file; + mode_t mode; +{ + return __open64 (file, O_WRONLY|O_CREAT|O_TRUNC, mode); +} diff --git a/io/dup.c b/io/dup.c new file mode 100644 index 0000000000..5d5e1b4cd5 --- /dev/null +++ b/io/dup.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991, 1995, 1996, 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. */ + +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> + +/* Duplicate FD, returning a new file descriptor open on the same file. */ +int +__dup (fd) + int fd; +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (dup) + +weak_alias (__dup, dup) +#include <stub-tag.h> diff --git a/io/dup2.c b/io/dup2.c new file mode 100644 index 0000000000..2b897896f6 --- /dev/null +++ b/io/dup2.c @@ -0,0 +1,48 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 2002 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 <unistd.h> + + +/* Duplicate FD to FD2, closing the old FD2 and making FD2 be + open the same file as FD is. Return FD2 or -1. */ +int +__dup2 (fd, fd2) + int fd; + int fd2; +{ + if (fd < 0 || fd2 < 0) + { + __set_errno (EBADF); + return -1; + } + + if (fd == fd2) + /* No way to check that they are valid. */ + return fd2; + + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__dup2) +stub_warning (dup2) + +weak_alias (__dup2, dup2) +#include <stub-tag.h> diff --git a/io/euidaccess.c b/io/euidaccess.c new file mode 100644 index 0000000000..943f1f7c82 --- /dev/null +++ b/io/euidaccess.c @@ -0,0 +1,42 @@ +/* Test for access to FILE using effective UID and GID. Stub version. + Copyright (C) 1991,1995,1996,1997,2006 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 <stddef.h> +#include <unistd.h> + +int +__euidaccess (file, type) + const char *file; + int type; +{ + if (file == NULL || (type & ~(R_OK|W_OK|X_OK|F_OK)) != 0) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +weak_alias (__euidaccess, euidaccess) +weak_alias (__euidaccess, eaccess) +stub_warning (euidaccess) +stub_warning (eaccess) +#include <stub-tag.h> diff --git a/io/faccessat.c b/io/faccessat.c new file mode 100644 index 0000000000..8e41d37c21 --- /dev/null +++ b/io/faccessat.c @@ -0,0 +1,51 @@ +/* Test for access to file, relative to open directory. Stub version. + Copyright (C) 2006 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> + +int +faccessat (fd, file, type, flag) + int fd; + const char *file; + int type; + int flag; +{ + if (file == NULL || (flag & ~(AT_SYMLINK_NOFOLLOW | AT_EACCESS)) != 0 + || (type & ~(R_OK|W_OK|X_OK|F_OK)) != 0) + { + __set_errno (EINVAL); + return -1; + } + + if (fd < 0 && fd != AT_FDCWD) + { + __set_errno (EBADF); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (faccessat) + +#include <stub-tag.h> diff --git a/io/fchdir.c b/io/fchdir.c new file mode 100644 index 0000000000..db1e4f8f35 --- /dev/null +++ b/io/fchdir.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1991, 1995, 1996, 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. */ + +#include <errno.h> +#include <stddef.h> +#include <unistd.h> + +/* Change the current directory to FD. */ +int +fchdir (fd) + int fd; +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (fchdir) +#include <stub-tag.h> diff --git a/io/fchmod.c b/io/fchmod.c new file mode 100644 index 0000000000..4b5eacb3eb --- /dev/null +++ b/io/fchmod.c @@ -0,0 +1,42 @@ +/* Copyright (C) 1991, 1992, 1995, 1996, 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. */ + +#include <errno.h> +#include <stddef.h> +#include <sys/stat.h> +#include <sys/types.h> + +/* Change the protections of the file FD refers to to MODE. */ +int +__fchmod (fd, mode) + int fd; + mode_t mode; +{ + if (fd < 0) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (fchmod) + +weak_alias (__fchmod, fchmod) +#include <stub-tag.h> diff --git a/io/fchmodat.c b/io/fchmodat.c new file mode 100644 index 0000000000..6aecf2ac23 --- /dev/null +++ b/io/fchmodat.c @@ -0,0 +1,50 @@ +/* Change the protections of file relative to open directory. Stub version. + Copyright (C) 2006 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> + +int +fchmodat (fd, file, mode, flag) + int fd; + const char *file; + mode_t mode; + 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/io/fchown.c b/io/fchown.c new file mode 100644 index 0000000000..e0d42dd293 --- /dev/null +++ b/io/fchown.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1991, 1992, 1995, 1996, 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. */ + +#include <errno.h> +#include <stddef.h> +#include <unistd.h> +#include <sys/types.h> + +/* Change the owner and group of the file referred to by FD. */ +int +__fchown (fd, owner, group) + int fd; + uid_t owner; + gid_t group; +{ + if (fd < 0) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (fchown) + +weak_alias (__fchown, fchown) +#include <stub-tag.h> diff --git a/io/fchownat.c b/io/fchownat.c new file mode 100644 index 0000000000..f6921c9012 --- /dev/null +++ b/io/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/io/fcntl.c b/io/fcntl.c new file mode 100644 index 0000000000..db6fbc399c --- /dev/null +++ b/io/fcntl.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 2002 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> + +/* Perform file control operations on FD. */ +int +__fcntl (fd, cmd) + int fd; + int cmd; +{ + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__fcntl) +stub_warning (fcntl) + +weak_alias (__fcntl, fcntl) +#include <stub-tag.h> diff --git a/io/fcntl.h b/io/fcntl.h index ef9d5f9b81..72a944b3d4 100644 --- a/io/fcntl.h +++ b/io/fcntl.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1991,1992,1994-2001,2003,2004 Free Software Foundation, Inc. +/* Copyright (C) 1991,1992,1994-2001,2003,2004,2005,2006 + 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 @@ -55,6 +56,18 @@ __BEGIN_DECLS # define SEEK_END 2 /* Seek from end of file. */ #endif /* XPG */ +#ifdef __USE_ATFILE +# define AT_FDCWD -100 /* Special value used to indicate + the *at functions should use the + current working directory. */ +# define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */ +# define AT_REMOVEDIR 0x200 /* Remove directory instead of + unlinking file. */ +# define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */ +# define AT_EACCESS 0x200 /* Test access permitted for + effective IDs, not real IDs. */ +#endif + /* Do the file control operation described by CMD on FD. The remaining arguments are interpreted depending on CMD. @@ -82,6 +95,32 @@ extern int __REDIRECT (open, (__const char *__file, int __oflag, ...), open64) extern int open64 (__const char *__file, int __oflag, ...) __nonnull ((1)); #endif +#ifdef __USE_ATFILE +/* Similar to `open' but a relative path name is interpreted relative to + the directory for which FD is a descriptor. + + NOTE: some other `openat' implementation support additional functionality + through this interface, especially using the O_XATTR flag. This is not + yet supported here. + + This function is a cancellation point and therefore not marked with + __THROW. */ +# ifndef __USE_FILE_OFFSET64 +extern int openat (int __fd, __const char *__file, int __oflag, ...) + __nonnull ((2)); +# else +# ifdef __REDIRECT +extern int __REDIRECT (openat, (int __fd, __const char *__file, int __oflag, + ...), openat64) __nonnull ((2)); +# else +# define openat openat64 +# endif +# endif + +extern int openat64 (int __fd, __const char *__file, int __oflag, ...) + __nonnull ((2)); +#endif + /* Create and open FILE, with mode MODE. This takes an `int' MODE argument because that is what `mode_t' will be widened to. diff --git a/io/flock.c b/io/flock.c new file mode 100644 index 0000000000..db3bfcfcbe --- /dev/null +++ b/io/flock.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1992, 1995, 1996, 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. */ + +#include <errno.h> +#include <sys/file.h> + +/* Apply or remove an advisory lock, according to OPERATION, + on the file FD refers to. */ +int +__flock (fd, operation) + int fd; + int operation; +{ + __set_errno (ENOSYS); + return -1; +} + +weak_alias (__flock, flock) + +stub_warning (flock) +#include <stub-tag.h> diff --git a/io/fstatat.c b/io/fstatat.c new file mode 100644 index 0000000000..1ac80597a0 --- /dev/null +++ b/io/fstatat.c @@ -0,0 +1,58 @@ +/* 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. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file with other + programs, and to distribute those programs without any restriction + coming from the use of this file. (The GNU Lesser General Public + License restrictions do apply in other respects; for example, they + cover modification of the file, and distribution when not linked + into another program.) + + Note that people who make modified versions of this file are not + obligated to grant this special exception for their modified + versions; it is their choice whether to do so. The GNU Lesser + General Public License gives permission to release a modified + version without this exception; this exception also makes it + possible to release a modified version which carries forward this + exception. + + 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 <sys/stat.h> + +/* This definition is only used if inlining fails for this function; see + the last page of <sys/stat.h>. The real work is done by the `x' + function which is passed a version number argument. We arrange in the + makefile that when not inlined this function is always statically + linked; that way a dynamically-linked executable always encodes the + version number corresponding to the data structures it uses, so the `x' + functions in the shared library can adapt without needing to recompile + all callers. */ + +#undef fstatat +int +fstatat (int fd, const char *file, struct stat *buf, int flag) +{ + return __fxstatat (_STAT_VER, fd, file, buf, flag); +} + +/* Hide the symbol so that no definition but the one locally in the + executable or DSO is used. */ +#ifdef HAVE_DOT_HIDDEN +asm (".hidden\tfstatat"); +#endif diff --git a/io/fstatat64.c b/io/fstatat64.c new file mode 100644 index 0000000000..a14b42d42e --- /dev/null +++ b/io/fstatat64.c @@ -0,0 +1,58 @@ +/* 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. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file with other + programs, and to distribute those programs without any restriction + coming from the use of this file. (The GNU Lesser General Public + License restrictions do apply in other respects; for example, they + cover modification of the file, and distribution when not linked + into another program.) + + Note that people who make modified versions of this file are not + obligated to grant this special exception for their modified + versions; it is their choice whether to do so. The GNU Lesser + General Public License gives permission to release a modified + version without this exception; this exception also makes it + possible to release a modified version which carries forward this + exception. + + 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 <sys/stat.h> + +/* This definition is only used if inlining fails for this function; see + the last page of <sys/stat.h>. The real work is done by the `x' + function which is passed a version number argument. We arrange in the + makefile that when not inlined this function is always statically + linked; that way a dynamically-linked executable always encodes the + version number corresponding to the data structures it uses, so the `x' + functions in the shared library can adapt without needing to recompile + all callers. */ + +#undef fstatat64 +int +fstatat64 (int fd, const char *file, struct stat64 *buf, int flag) +{ + return __fxstatat64 (_STAT_VER, fd, file, buf, flag); +} + +/* Hide the symbol so that no definition but the one locally in the + executable or DSO is used. */ +#ifdef HAVE_DOT_HIDDEN +asm (".hidden\tfstatat64"); +#endif diff --git a/io/fstatfs.c b/io/fstatfs.c new file mode 100644 index 0000000000..4a1a996cbc --- /dev/null +++ b/io/fstatfs.c @@ -0,0 +1,34 @@ +/* Return information about the filesystem on which FD resides. + Copyright (C) 1996, 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. */ + +#include <errno.h> +#include <sys/statfs.h> +#include <stddef.h> + +/* Return information about the filesystem on which FD resides. */ +int +__fstatfs (int fd, struct statfs *buf) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (fstatfs) + +weak_alias (__fstatfs, fstatfs) +#include <stub-tag.h> diff --git a/io/fstatfs64.c b/io/fstatfs64.c new file mode 100644 index 0000000000..249b97ea44 --- /dev/null +++ b/io/fstatfs64.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1998, 2000 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 <sys/statfs.h> + +/* Return information about the filesystem on which FD resides. */ +int +__fstatfs64 (int fd, struct statfs64 *buf) +{ + __set_errno (ENOSYS); + return -1; +} +weak_alias (__fstatfs64, fstatfs64) + +stub_warning (fstatfs64) +#include <stub-tag.h> diff --git a/io/fstatvfs.c b/io/fstatvfs.c new file mode 100644 index 0000000000..c5f75a7c97 --- /dev/null +++ b/io/fstatvfs.c @@ -0,0 +1,33 @@ +/* Return information about the filesystem on which FD resides. + Copyright (C) 1996, 1997, 1998, 2002 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 <sys/statvfs.h> + +/* Return information about the filesystem on which FD resides. */ +int +__fstatvfs (int fd, struct statvfs *buf) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (fstatvfs) +weak_alias (__fstatvfs, fstatvfs) +libc_hidden_weak (fstatvfs) +#include <stub-tag.h> diff --git a/io/fstatvfs64.c b/io/fstatvfs64.c new file mode 100644 index 0000000000..47d4e266e2 --- /dev/null +++ b/io/fstatvfs64.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1998, 2001 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 <sys/statvfs.h> + +/* Return information about the filesystem on which FD resides. */ +int +__fstatvfs64 (int fd, struct statvfs64 *buf) +{ + __set_errno (ENOSYS); + return -1; +} +weak_alias (__fstatvfs64, fstatvfs64) + +stub_warning (fstatvfs64) +#include <stub-tag.h> diff --git a/io/fts.c b/io/fts.c index f0df56cc7b..8e628b481d 100644 --- a/io/fts.c +++ b/io/fts.c @@ -53,7 +53,7 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; #endif -static FTSENT *fts_alloc (FTS *, const char *, int) internal_function; +static FTSENT *fts_alloc (FTS *, const char *, size_t) internal_function; static FTSENT *fts_build (FTS *, int) internal_function; static void fts_lfree (FTSENT *) internal_function; static void fts_load (FTS *, FTSENT *) internal_function; @@ -93,8 +93,8 @@ fts_open(argv, options, compar) register FTS *sp; register FTSENT *p, *root; register int nitems; - FTSENT *parent, *tmp; - int len; + FTSENT *parent = NULL; + FTSENT *tmp; /* Options check. */ if (options & ~FTS_OPTIONMASK) { @@ -120,18 +120,22 @@ fts_open(argv, options, compar) #ifndef MAXPATHLEN #define MAXPATHLEN 1024 #endif - if (fts_palloc(sp, MAX(fts_maxarglen(argv), MAXPATHLEN))) + size_t maxarglen = fts_maxarglen(argv); + if (fts_palloc(sp, MAX(maxarglen, MAXPATHLEN))) goto mem1; /* Allocate/initialize root's parent. */ - if ((parent = fts_alloc(sp, "", 0)) == NULL) - goto mem2; - parent->fts_level = FTS_ROOTPARENTLEVEL; + if (*argv != NULL) { + if ((parent = fts_alloc(sp, "", 0)) == NULL) + goto mem2; + parent->fts_level = FTS_ROOTPARENTLEVEL; + } /* Allocate/initialize root(s). */ for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) { /* Don't allow zero-length paths. */ - if ((len = strlen(*argv)) == 0) { + size_t len = strlen(*argv); + if (len == 0) { __set_errno (ENOENT); goto mem3; } @@ -247,8 +251,7 @@ fts_close(sp) /* Free up child linked list, sort array, path buffer. */ if (sp->fts_child) fts_lfree(sp->fts_child); - if (sp->fts_array) - free(sp->fts_array); + free(sp->fts_array); free(sp->fts_path); /* Return to original directory, save errno if necessary. */ @@ -373,12 +376,14 @@ fts_read(sp) } p = sp->fts_child; sp->fts_child = NULL; + sp->fts_cur = p; goto name; } /* Move to the next node on this level. */ next: tmp = p; if ((p = p->fts_link) != NULL) { + sp->fts_cur = p; free(tmp); /* @@ -391,7 +396,7 @@ next: tmp = p; return (NULL); } fts_load(sp, p); - return (sp->fts_cur = p); + return p; } /* @@ -417,11 +422,12 @@ next: tmp = p; name: t = sp->fts_path + NAPPEND(p->fts_parent); *t++ = '/'; memmove(t, p->fts_name, p->fts_namelen + 1); - return (sp->fts_cur = p); + return p; } /* Move up to the parent node. */ p = tmp->fts_parent; + sp->fts_cur = p; free(tmp); if (p->fts_level == FTS_ROOTPARENTLEVEL) { @@ -462,7 +468,7 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent); return (NULL); } p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP; - return (sp->fts_cur = p); + return p; } /* @@ -690,7 +696,7 @@ fts_build(sp, type) if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) continue; - if ((p = fts_alloc(sp, dp->d_name, (int)_D_EXACT_NAMLEN (dp))) == NULL) + if ((p = fts_alloc(sp, dp->d_name, _D_EXACT_NAMLEN (dp))) == NULL) goto mem1; if (_D_EXACT_NAMLEN (dp) >= maxlen) {/* include space for NUL */ oldaddr = sp->fts_path; @@ -701,8 +707,7 @@ fts_build(sp, type) * structures already allocated. */ mem1: saved_errno = errno; - if (p) - free(p); + free(p); fts_lfree(head); (void)__closedir(dirp); cur->fts_info = FTS_ERR; @@ -743,6 +748,10 @@ mem1: saved_errno = errno; p->fts_flags |= FTS_ISW; #endif +#if 0 + /* Unreachable code. cderrno is only ever set to a nonnull + value if dirp is closed at the same time. But then we + cannot enter this loop. */ if (cderrno) { if (nlinks) { p->fts_info = FTS_NS; @@ -750,7 +759,9 @@ mem1: saved_errno = errno; } else p->fts_info = FTS_NSOK; p->fts_accpath = cur->fts_accpath; - } else if (nlinks == 0 + } else +#endif + if (nlinks == 0 #if defined DT_DIR && defined _DIRENT_HAVE_D_TYPE || (nostat && dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN) @@ -818,6 +829,7 @@ mem1: saved_errno = errno; fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) { cur->fts_info = FTS_ERR; SET(FTS_STOP); + fts_lfree(head); return (NULL); } @@ -825,6 +837,7 @@ mem1: saved_errno = errno; if (!nitems) { if (type == BREAD) cur->fts_info = FTS_DP; + fts_lfree(head); return (NULL); } @@ -961,7 +974,7 @@ internal_function fts_alloc(sp, name, namelen) FTS *sp; const char *name; - register int namelen; + size_t namelen; { register FTSENT *p; size_t len; @@ -1031,10 +1044,7 @@ fts_palloc(sp, more) * We limit fts_pathlen to USHRT_MAX to be safe in both cases. */ if (sp->fts_pathlen < 0 || sp->fts_pathlen >= USHRT_MAX) { - if (sp->fts_path) { - free(sp->fts_path); - sp->fts_path = NULL; - } + free(sp->fts_path); sp->fts_path = NULL; __set_errno (ENAMETOOLONG); return (1); diff --git a/io/ftw.c b/io/ftw.c index 7610851047..5495bc7ecc 100644 --- a/io/ftw.c +++ b/io/ftw.c @@ -1,5 +1,5 @@ /* File tree walker functions. - Copyright (C) 1996-2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1996-2003, 2004, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -36,7 +36,7 @@ char *alloca (); # endif #endif -#if defined _LIBC +#ifdef _LIBC # include <dirent.h> # define NAMLEN(dirent) _D_EXACT_NAMLEN (dirent) #else @@ -59,12 +59,14 @@ char *alloca (); #endif #include <errno.h> +#include <fcntl.h> #include <ftw.h> #include <limits.h> #include <search.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <not-cancel.h> #if HAVE_SYS_PARAM_H || defined _LIBC # include <sys/param.h> #endif @@ -142,9 +144,11 @@ int rpl_lstat (const char *, struct stat *); # ifdef _LIBC # define LXSTAT __lxstat # define XSTAT __xstat +# define FXSTATAT __fxstatat # else # define LXSTAT(V,f,sb) lstat (f,sb) # define XSTAT(V,f,sb) stat (f,sb) +# define FXSTATAT(V,d,f,sb,m) fstatat (d, f, sb, m) # endif # define FTW_FUNC_T __ftw_func_t # define NFTW_FUNC_T __nftw_func_t @@ -161,6 +165,7 @@ int rpl_lstat (const char *, struct stat *); struct dir_data { DIR *stream; + int streamfd; char *content; }; @@ -262,7 +267,7 @@ find_object (struct ftw_data *data, struct STAT *st) static inline int __attribute ((always_inline)) -open_dir_stream (struct ftw_data *data, struct dir_data *dirp) +open_dir_stream (int *dfdp, struct ftw_data *data, struct dir_data *dirp) { int result = 0; @@ -296,8 +301,7 @@ open_dir_stream (struct ftw_data *data, struct dir_data *dirp) int save_err = errno; free (buf); __set_errno (save_err); - result = -1; - break; + return -1; } buf = newp; } @@ -323,6 +327,7 @@ open_dir_stream (struct ftw_data *data, struct dir_data *dirp) { __closedir (st); data->dirstreams[data->actdir]->stream = NULL; + data->dirstreams[data->actdir]->streamfd = -1; data->dirstreams[data->actdir] = NULL; } } @@ -331,15 +336,37 @@ open_dir_stream (struct ftw_data *data, struct dir_data *dirp) /* Open the new stream. */ if (result == 0) { - const char *name = ((data->flags & FTW_CHDIR) - ? data->dirbuf + data->ftw.base: data->dirbuf); assert (data->dirstreams[data->actdir] == NULL); - dirp->stream = __opendir (name); + if (dfdp != NULL && *dfdp != -1) + { + int fd = openat64_not_cancel_3 (*dfdp, data->dirbuf + data->ftw.base, + O_RDONLY | O_DIRECTORY | O_NDELAY); + dirp->stream = NULL; + if (fd != -1 && (dirp->stream = __fdopendir (fd)) == NULL) + close_not_cancel_no_status (fd); + } + else + { + const char *name; + + if (data->flags & FTW_CHDIR) + { + name = data->dirbuf + data->ftw.base; + if (name[0] == '\0') + name = "."; + } + else + name = data->dirbuf; + + dirp->stream = __opendir (name); + } + if (dirp->stream == NULL) result = -1; else { + dirp->streamfd = dirfd (dirp->stream); dirp->content = NULL; data->dirstreams[data->actdir] = dirp; @@ -355,7 +382,7 @@ open_dir_stream (struct ftw_data *data, struct dir_data *dirp) static int internal_function process_entry (struct ftw_data *data, struct dir_data *dir, const char *name, - size_t namlen) + size_t namlen, int d_type) { struct STAT st; int result = 0; @@ -382,21 +409,40 @@ process_entry (struct ftw_data *data, struct dir_data *dir, const char *name, *((char *) __mempcpy (data->dirbuf + data->ftw.base, name, namlen)) = '\0'; - if ((data->flags & FTW_CHDIR) == 0) - name = data->dirbuf; + int statres; + if (dir->streamfd != -1) + statres = FXSTATAT (_STAT_VER, dir->streamfd, name, &st, + (data->flags & FTW_PHYS) ? AT_SYMLINK_NOFOLLOW : 0); + else + { + if ((data->flags & FTW_CHDIR) == 0) + name = data->dirbuf; - if (((data->flags & FTW_PHYS) - ? LXSTAT (_STAT_VER, name, &st) - : XSTAT (_STAT_VER, name, &st)) < 0) + statres = ((data->flags & FTW_PHYS) + ? LXSTAT (_STAT_VER, name, &st) + : XSTAT (_STAT_VER, name, &st)); + } + + if (statres < 0) { if (errno != EACCES && errno != ENOENT) result = -1; - else if (!(data->flags & FTW_PHYS) - && LXSTAT (_STAT_VER, name, &st) == 0 - && S_ISLNK (st.st_mode)) + else if (data->flags & FTW_PHYS) + flag = FTW_NS; + else if (d_type == DT_LNK) flag = FTW_SLN; else - flag = FTW_NS; + { + if (dir->streamfd != -1) + statres = FXSTATAT (_STAT_VER, dir->streamfd, name, &st, + AT_SYMLINK_NOFOLLOW); + else + statres = LXSTAT (_STAT_VER, name, &st); + if (statres == 0 && S_ISLNK (st.st_mode)) + flag = FTW_SLN; + else + flag = FTW_NS; + } } else { @@ -445,7 +491,8 @@ ftw_dir (struct ftw_data *data, struct STAT *st, struct dir_data *old_dir) /* Open the stream for this directory. This might require that another stream has to be closed. */ - result = open_dir_stream (data, &dir); + result = open_dir_stream (old_dir == NULL ? NULL : &old_dir->streamfd, + data, &dir); if (result != 0) { if (errno == EACCES) @@ -465,6 +512,7 @@ ftw_dir (struct ftw_data *data, struct STAT *st, struct dir_data *old_dir) fail: save_err = errno; __closedir (dir.stream); + dir.streamfd = -1; __set_errno (save_err); if (data->actdir-- == 0) @@ -486,7 +534,7 @@ fail: /* Next, update the `struct FTW' information. */ ++data->ftw.level; - startp = strchr (data->dirbuf, '\0'); + startp = __rawmemchr (data->dirbuf, '\0'); /* There always must be a directory name. */ assert (startp != data->dirbuf); if (startp[-1] != '/') @@ -495,7 +543,7 @@ fail: while (dir.stream != NULL && (d = __readdir64 (dir.stream)) != NULL) { - result = process_entry (data, &dir, d->d_name, NAMLEN (d)); + result = process_entry (data, &dir, d->d_name, NAMLEN (d), d->d_type); if (result != 0) break; } @@ -509,6 +557,7 @@ fail: assert (dir.content == NULL); __closedir (dir.stream); + dir.streamfd = -1; __set_errno (save_err); if (data->actdir-- == 0) @@ -524,7 +573,8 @@ fail: { char *endp = strchr (runp, '\0'); - result = process_entry (data, &dir, runp, endp - runp); + // XXX Should store the d_type values as well?! + result = process_entry (data, &dir, runp, endp - runp, DT_UNKNOWN); runp = endp + 1; } @@ -585,6 +635,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors, struct STAT st; int result = 0; int save_err; + int cwdfd = -1; char *cwd = NULL; char *cp; @@ -639,11 +690,26 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors, /* Now go to the directory containing the initial file/directory. */ if (flags & FTW_CHDIR) { - /* GNU extension ahead. */ - cwd = __getcwd (NULL, 0); - if (cwd == NULL) - result = -1; - else if (data.ftw.base > 0) + /* We have to be able to go back to the current working + directory. The best way to do this is to use a file + descriptor. */ + cwdfd = __open (".", O_RDONLY | O_DIRECTORY); + if (cwdfd == -1) + { + /* Try getting the directory name. This can be needed if + the current directory is executable but not readable. */ + if (errno == EACCES) + /* GNU extension ahead. */ + cwd = __getcwd (NULL, 0); + + if (cwd == NULL) + goto out_fail; + } + else if (data.maxdir > 1) + /* Account for the file descriptor we use here. */ + --data.maxdir; + + if (data.ftw.base > 0) { /* Change to the directory the file is in. In data.dirbuf we have a writable copy of the file name. Just NUL @@ -664,9 +730,16 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors, /* Get stat info for start directory. */ if (result == 0) { - const char *name = ((data.flags & FTW_CHDIR) - ? data.dirbuf + data.ftw.base - : data.dirbuf); + const char *name; + + if (data.flags & FTW_CHDIR) + { + name = data.dirbuf + data.ftw.base; + if (name[0] == '\0') + name = "."; + } + else + name = data.dirbuf; if (((flags & FTW_PHYS) ? LXSTAT (_STAT_VER, name, &st) @@ -713,7 +786,13 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors, } /* Return to the start directory (if necessary). */ - if (cwd != NULL) + if (cwdfd != -1) + { + int save_err = errno; + __fchdir (cwdfd); + __set_errno (save_err); + } + else if (cwd != NULL) { int save_err = errno; __chdir (cwd); @@ -722,6 +801,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors, } /* Free all memory. */ + out_fail: save_err = errno; __tdestroy (data.known_objects, free); free (data.dirbuf); @@ -755,7 +835,7 @@ NFTW_NAME (path, func, descriptors, flags) } #else -#include <shlib-compat.h> +# include <shlib-compat.h> int NFTW_NEW_NAME (const char *, NFTW_FUNC_T, int, int); @@ -777,7 +857,7 @@ NFTW_NEW_NAME (path, func, descriptors, flags) versioned_symbol (libc, NFTW_NEW_NAME, NFTW_NAME, GLIBC_2_3_3); -#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_3_3) +# if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_3_3) /* Older nftw* version just ignored all unknown flags. */ @@ -796,5 +876,5 @@ NFTW_OLD_NAME (path, func, descriptors, flags) } compat_symbol (libc, NFTW_OLD_NAME, NFTW_NAME, GLIBC_2_1); -#endif +# endif #endif diff --git a/io/ftw64.c b/io/ftw64.c index 7913b7af17..39e6ceabf8 100644 --- a/io/ftw64.c +++ b/io/ftw64.c @@ -1,5 +1,5 @@ /* File tree walker functions. LFS version. - Copyright (C) 1996, 1997, 1998, 2001 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 2001, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -26,6 +26,7 @@ #define STAT stat64 #define LXSTAT __lxstat64 #define XSTAT __xstat64 +#define FXSTATAT __fxstatat64 #define FTW_FUNC_T __ftw64_func_t #define NFTW_FUNC_T __nftw64_func_t diff --git a/io/fxstat.c b/io/fxstat.c new file mode 100644 index 0000000000..b750daca63 --- /dev/null +++ b/io/fxstat.c @@ -0,0 +1,50 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 2002 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 <stddef.h> +#include <sys/stat.h> + +/* Get information about the file descriptor FD in BUF. */ +int +__fxstat (int vers, int fd, struct stat *buf) +{ + if (vers != _STAT_VER) + { + __set_errno (EINVAL); + return -1; + } + + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } + else if (buf == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (fstat) +hidden_def (__fxstat) +weak_alias (__fxstat, _fxstat) +#include <stub-tag.h> diff --git a/io/fxstat64.c b/io/fxstat64.c new file mode 100644 index 0000000000..865ba49484 --- /dev/null +++ b/io/fxstat64.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 2002 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 <stddef.h> +#include <sys/stat.h> + +/* Get information about the file descriptor FD in BUF. */ +int +__fxstat64 (int vers, int fd, struct stat64 *buf) +{ + if (vers != _STAT_VER) + { + __set_errno (EINVAL); + return -1; + } + + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } + else if (buf == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +hidden_def (__fxstat64) +stub_warning (fstat64) +#include <stub-tag.h> diff --git a/io/fxstatat.c b/io/fxstatat.c new file mode 100644 index 0000000000..2486c73c84 --- /dev/null +++ b/io/fxstatat.c @@ -0,0 +1,50 @@ +/* Copyright (C) 2005, 2006 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; +} +libc_hidden_def (__fxstatat) +stub_warning (fstatat) +#include <stub-tag.h> diff --git a/io/fxstatat64.c b/io/fxstatat64.c new file mode 100644 index 0000000000..20bdd610c3 --- /dev/null +++ b/io/fxstatat64.c @@ -0,0 +1,51 @@ +/* Copyright (C) 2005, 2006 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; +} +libc_hidden_def (__fxstatat64) +stub_warning (fstatat64) +#include <stub-tag.h> diff --git a/io/getcwd.c b/io/getcwd.c new file mode 100644 index 0000000000..c472d1d7a6 --- /dev/null +++ b/io/getcwd.c @@ -0,0 +1,40 @@ +/* Copyright (C) 1991, 1992, 1995, 1996, 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. */ + +#include <errno.h> +#include <unistd.h> +#include <stddef.h> + +/* Get the pathname of the current working directory, + and put it in SIZE bytes of BUF. Returns NULL if the + directory couldn't be determined or SIZE was too small. + If successful, returns BUF. In GNU, if BUF is NULL, + an array is allocated with `malloc'; the array is SIZE + bytes long, unless SIZE <= 0, in which case it is as + big as necessary. */ +char * +__getcwd (char *buf, size_t size) +{ + __set_errno (ENOSYS); + return NULL; +} +weak_alias (__getcwd, getcwd) + +stub_warning (__getcwd) +stub_warning (getcwd) +#include <stub-tag.h> diff --git a/io/isatty.c b/io/isatty.c new file mode 100644 index 0000000000..9b0410c614 --- /dev/null +++ b/io/isatty.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991, 1995, 1996, 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. */ + +#include <errno.h> +#include <unistd.h> + +/* Return 1 if FD is a terminal, 0 if not. */ +int +__isatty (fd) + int fd; +{ + __set_errno (ENOSYS); + return -1; +} + +weak_alias (__isatty, isatty) + +stub_warning (isatty) +#include <stub-tag.h> diff --git a/io/lchmod.c b/io/lchmod.c new file mode 100644 index 0000000000..524b24c1ed --- /dev/null +++ b/io/lchmod.c @@ -0,0 +1,33 @@ +/* lchmod -- Change the protections of a file or symbolic link. Stub version. + Copyright (C) 2002 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 <sys/stat.h> +#include <sys/types.h> + +/* Change the protections of FILE to MODE. */ +int +lchmod (const char *file, mode_t mode) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (lchmod) +#include <stub-tag.h> diff --git a/io/lchown.c b/io/lchown.c new file mode 100644 index 0000000000..4e0330e526 --- /dev/null +++ b/io/lchown.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1996 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 <stddef.h> +#include <unistd.h> +#include <sys/types.h> + +/* Change the owner and group of FILE. */ +int +__lchown (file, owner, group) + const char *file; + uid_t owner; + gid_t group; +{ + if (file == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (lchown) + +weak_alias (__lchown, lchown) +#include <stub-tag.h> diff --git a/io/link.c b/io/link.c new file mode 100644 index 0000000000..70c9949704 --- /dev/null +++ b/io/link.c @@ -0,0 +1,42 @@ +/* Copyright (C) 1991, 1995, 1996, 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. */ + +#include <errno.h> +#include <stddef.h> +#include <unistd.h> + + +/* Make a link to FROM called TO. */ +int +__link (from, to) + const char *from; + const char *to; +{ + if (from == NULL || to == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (link) + +weak_alias (__link, link) +#include <stub-tag.h> diff --git a/io/linkat.c b/io/linkat.c new file mode 100644 index 0000000000..9afcf61a3c --- /dev/null +++ b/io/linkat.c @@ -0,0 +1,52 @@ +/* Copyright (C) 2005, 2006 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> + + +/* Make a link to FROM relative to FROMFD called TO relative to TOFD. */ +int +linkat (fromfd, from, tofd, to, flags) + int fromfd; + const char *from; + int tofd; + const char *to; + int flags; +{ + if (from == NULL || to == NULL) + { + __set_errno (EINVAL); + return -1; + } + + if ((tofd != AT_FDCWD && tofd < 0 && *to != '/') + || (fromfd != AT_FDCWD && fromfd < 0 && *from != '/')) + { + __set_errno (EBADF); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (linkat) + +#include <stub-tag.h> diff --git a/io/lockf.c b/io/lockf.c new file mode 100644 index 0000000000..7b23f66bc9 --- /dev/null +++ b/io/lockf.c @@ -0,0 +1,74 @@ +/* Copyright (C) 1994,1996,1997,1998,2000,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 + 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 <sys/types.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> + +/* lockf is a simplified interface to fcntl's locking facilities. */ + +int +lockf (int fd, int cmd, off_t len) +{ + struct flock fl; + + memset ((char *) &fl, '\0', sizeof (fl)); + + /* lockf is always relative to the current file position. */ + fl.l_whence = SEEK_CUR; + fl.l_start = 0; + fl.l_len = len; + + switch (cmd) + { + case F_TEST: + /* Test the lock: return 0 if FD is unlocked or locked by this process; + return -1, set errno to EACCES, if another process holds the lock. */ + fl.l_type = F_RDLCK; + if (__fcntl (fd, F_GETLK, &fl) < 0) + return -1; + if (fl.l_type == F_UNLCK || fl.l_pid == __getpid ()) + return 0; + __set_errno (EACCES); + return -1; + + case F_ULOCK: + fl.l_type = F_UNLCK; + cmd = F_SETLK; + break; + case F_LOCK: + fl.l_type = F_WRLCK; + cmd = F_SETLKW; + break; + case F_TLOCK: + fl.l_type = F_WRLCK; + cmd = F_SETLK; + break; + + default: + __set_errno (EINVAL); + return -1; + } + + /* lockf() is a cancellation point but so is fcntl() if F_SETLKW is + used. Therefore we don't have to care about cancellation here, + the fcntl() function will take care of it. */ + return __fcntl (fd, cmd, &fl); +} diff --git a/io/lockf64.c b/io/lockf64.c new file mode 100644 index 0000000000..e3b110cd3f --- /dev/null +++ b/io/lockf64.c @@ -0,0 +1,79 @@ +/* Copyright (C) 1994,96,97,98,99,2000 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 <sys/types.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> + +/* lockf is a simplified interface to fcntl's locking facilities. */ + +int +lockf64 (int fd, int cmd, off64_t len64) +{ + struct flock fl; + off_t len = (off_t) len64; + + if (len64 != (off64_t) len) + { + /* We can't represent the length. */ + __set_errno (EOVERFLOW); + return -1; + } + + memset ((char *) &fl, '\0', sizeof (fl)); + + /* lockf is always relative to the current file position. */ + fl.l_whence = SEEK_CUR; + fl.l_start = 0; + fl.l_len = len; + + switch (cmd) + { + case F_TEST: + /* Test the lock: return 0 if FD is unlocked or locked by this process; + return -1, set errno to EACCES, if another process holds the lock. */ + fl.l_type = F_RDLCK; + if (__fcntl (fd, F_GETLK, &fl) < 0) + return -1; + if (fl.l_type == F_UNLCK || fl.l_pid == __getpid ()) + return 0; + __set_errno (EACCES); + return -1; + + case F_ULOCK: + fl.l_type = F_UNLCK; + cmd = F_SETLK; + break; + case F_LOCK: + fl.l_type = F_WRLCK; + cmd = F_SETLKW; + break; + case F_TLOCK: + fl.l_type = F_WRLCK; + cmd = F_SETLK; + break; + + default: + __set_errno (EINVAL); + return -1; + } + + return __fcntl (fd, cmd, &fl); +} diff --git a/io/lseek64.c b/io/lseek64.c new file mode 100644 index 0000000000..d0a8cff03e --- /dev/null +++ b/io/lseek64.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1991,95,96,97,98,2000 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 <unistd.h> +#include <sys/types.h> + +/* Seek to OFFSET on FD, starting from WHENCE. */ +off64_t +__libc_lseek64 (int fd, off64_t offset, int whence) +{ + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } + switch (whence) + { + case SEEK_SET: + case SEEK_CUR: + case SEEK_END: + break; + default: + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +weak_alias (__libc_lseek64, __lseek64) +weak_alias (__libc_lseek64, lseek64) +stub_warning (lseek64) +#include <stub-tag.h> diff --git a/io/lxstat.c b/io/lxstat.c new file mode 100644 index 0000000000..23d4442b5c --- /dev/null +++ b/io/lxstat.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1991,1992,1995,1996,1997,2002 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 <sys/stat.h> + +int +__lxstat (int version, const char *file, struct stat *buf) +{ + return __xstat (version, file, buf); +} +hidden_def (__lxstat) +weak_alias (__lxstat, _lxstat) diff --git a/io/lxstat64.c b/io/lxstat64.c new file mode 100644 index 0000000000..596ecd2277 --- /dev/null +++ b/io/lxstat64.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 2002 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 <stddef.h> +#include <sys/stat.h> + +/* Get file information about FILE in BUF. + If FILE is a symbolic link, do not follow it. */ +int +__lxstat64 (int vers, const char *file, struct stat64 *buf) +{ + if (vers != _STAT_VER || file == NULL || buf == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +hidden_def (__lxstat64) +stub_warning (__lxstat64) +#include <stub-tag.h> diff --git a/io/mkdir.c b/io/mkdir.c new file mode 100644 index 0000000000..8037dfb3ee --- /dev/null +++ b/io/mkdir.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1991, 1995, 1996, 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. */ + +#include <errno.h> +#include <stddef.h> +#include <sys/stat.h> +#include <sys/types.h> + + +/* Create a directory named PATH with protections MODE. */ +int +__mkdir (path, mode) + const char *path; + mode_t mode; +{ + if (path == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (mkdir) + +weak_alias (__mkdir, mkdir) +#include <stub-tag.h> diff --git a/io/mkdirat.c b/io/mkdirat.c new file mode 100644 index 0000000000..ccea3aa8d8 --- /dev/null +++ b/io/mkdirat.c @@ -0,0 +1,58 @@ +/* Copyright (C) 1991, 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 + 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> +#include <sys/types.h> + + +/* Create a directory named PATH relative to FD with protections MODE. */ +int +mkdirat (fd, path, mode) + int fd; + const char *path; + mode_t mode; +{ + if (path == NULL) + { + __set_errno (EINVAL); + return -1; + } + + if (fd != AT_FDCWD && path[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; + } + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (mkdirat) + +#include <stub-tag.h> diff --git a/io/mkfifo.c b/io/mkfifo.c new file mode 100644 index 0000000000..614ebe97c3 --- /dev/null +++ b/io/mkfifo.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1991, 1995, 1996, 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. */ + +#include <errno.h> +#include <stddef.h> +#include <sys/stat.h> +#include <sys/types.h> + + +/* Create a named pipe (FIFO) named PATH with protections MODE. */ +int +mkfifo (path, mode) + const char *path; + mode_t mode; +{ + if (path == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (mkfifo) +#include <stub-tag.h> diff --git a/io/mkfifoat.c b/io/mkfifoat.c new file mode 100644 index 0000000000..48c38c8182 --- /dev/null +++ b/io/mkfifoat.c @@ -0,0 +1,60 @@ +/* Copyright (C) 1991, 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 + 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> +#include <sys/types.h> + + +/* Create a named pipe (FIFO) named PATH relative to FD with + protections MODE. */ +int +mkfifoat (fd, path, mode) + int fd; + const char *path; + mode_t mode; +{ + if (path == NULL) + { + __set_errno (EINVAL); + return -1; + } + + if (fd != AT_FDCWD && path[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; + } + } + + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (mkfifoat) +#include <stub-tag.h> diff --git a/io/mknod.c b/io/mknod.c new file mode 100644 index 0000000000..7d43593a25 --- /dev/null +++ b/io/mknod.c @@ -0,0 +1,62 @@ +/* Copyright (C) 1995, 1996, 2001 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. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file with other + programs, and to distribute those programs without any restriction + coming from the use of this file. (The GNU Lesser General Public + License restrictions do apply in other respects; for example, they + cover modification of the file, and distribution when not linked + into another program.) + + Note that people who make modified versions of this file are not + obligated to grant this special exception for their modified + versions; it is their choice whether to do so. The GNU Lesser + General Public License gives permission to release a modified + version without this exception; this exception also makes it + possible to release a modified version which carries forward this + exception. + + 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 <sys/types.h> +#include <sys/stat.h> + +/* This definition is only used if inlining fails for this function; see + the last page of <sys/stat.h>. The real work is done by the `x' + function which is passed a version number argument. We arrange in the + makefile that when not inlined this function is always statically + linked; that way a dynamically-linked executable always encodes the + version number corresponding to the data structures it uses, so the `x' + functions in the shared library can adapt without needing to recompile + all callers. */ + +int +__mknod (const char *path, mode_t mode, dev_t dev) +{ + return __xmknod (_MKNOD_VER, path, mode, &dev); +} + +weak_alias (__mknod, mknod) + +/* Hide the symbol so that no definition but the one locally in the + executable or DSO is used. */ +#ifdef HAVE_DOT_HIDDEN +asm (".hidden\tmknod"); +asm (".hidden\t__mknod"); +#endif diff --git a/io/mknodat.c b/io/mknodat.c new file mode 100644 index 0000000000..ac515b5b48 --- /dev/null +++ b/io/mknodat.c @@ -0,0 +1,60 @@ +/* Copyright (C) 1995, 1996, 2001, 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. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file with other + programs, and to distribute those programs without any restriction + coming from the use of this file. (The GNU Lesser General Public + License restrictions do apply in other respects; for example, they + cover modification of the file, and distribution when not linked + into another program.) + + Note that people who make modified versions of this file are not + obligated to grant this special exception for their modified + versions; it is their choice whether to do so. The GNU Lesser + General Public License gives permission to release a modified + version without this exception; this exception also makes it + possible to release a modified version which carries forward this + exception. + + 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 <sys/types.h> +#include <sys/stat.h> + +/* This definition is only used if inlining fails for this function; see + the last page of <sys/stat.h>. The real work is done by the `x' + function which is passed a version number argument. We arrange in the + makefile that when not inlined this function is always statically + linked; that way a dynamically-linked executable always encodes the + version number corresponding to the data structures it uses, so the `x' + functions in the shared library can adapt without needing to recompile + all callers. */ + +int +mknodat (int fd, const char *path, mode_t mode, dev_t dev) +{ + return __xmknodat (_MKNOD_VER, fd, path, mode, &dev); +} + + +/* Hide the symbol so that no definition but the one locally in the + executable or DSO is used. */ +#ifdef HAVE_DOT_HIDDEN +asm (".hidden\tmknodat"); +#endif diff --git a/io/open.c b/io/open.c new file mode 100644 index 0000000000..188110b3f3 --- /dev/null +++ b/io/open.c @@ -0,0 +1,54 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 2002 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> + +/* Open FILE with access OFLAG. If OFLAG includes O_CREAT, + a third argument is the file protection. */ +int +__open (file, oflag) + const char *file; + int oflag; +{ + int mode; + + if (file == NULL) + { + __set_errno (EINVAL); + 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; +} +libc_hidden_def (__open) +stub_warning (open) + +weak_alias (__open, open) +#include <stub-tag.h> diff --git a/io/open64.c b/io/open64.c new file mode 100644 index 0000000000..d9a38112ac --- /dev/null +++ b/io/open64.c @@ -0,0 +1,57 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 1999, 2000, 2002 + 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 <bp-sym.h> + +/* Open FILE with access OFLAG. If OFLAG includes O_CREAT, + a third argument is the file protection. */ +int +__libc_open64 (file, oflag) + const char *file; + int oflag; +{ + int mode; + + if (file == NULL) + { + __set_errno (EINVAL); + 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; +} +strong_alias (__libc_open64, __open64) +libc_hidden_def (__open64) +weak_alias (__libc_open64, BP_SYM (open64)) + +stub_warning (open64) +#include <stub-tag.h> diff --git a/io/openat.c b/io/openat.c new file mode 100644 index 0000000000..c65ad19c7a --- /dev/null +++ b/io/openat.c @@ -0,0 +1,71 @@ +/* Copyright (C) 2005, 2006 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; +} +libc_hidden_def (__openat) +weak_alias (__openat, openat) +stub_warning (openat) + +#include <stub-tag.h> diff --git a/io/openat64.c b/io/openat64.c new file mode 100644 index 0000000000..830701a949 --- /dev/null +++ b/io/openat64.c @@ -0,0 +1,71 @@ +/* Copyright (C) 2005, 2006 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; +} +libc_hidden_def (__openat64) +weak_alias (__openat64, openat64) +stub_warning (openat64) + +#include <stub-tag.h> diff --git a/io/pipe.c b/io/pipe.c new file mode 100644 index 0000000000..babaf9c24b --- /dev/null +++ b/io/pipe.c @@ -0,0 +1,44 @@ +/* Copyright (C) 1991, 1995, 1996, 2002 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 <unistd.h> +#include <stddef.h> + +/* Create a one-way communication channel (__pipe). + If successful, two file descriptors are stored in PIPEDES; + bytes written on PIPEDES[1] can be read from PIPEDES[0]. + Returns 0 if successful, -1 if not. */ +int +__pipe (__pipedes) + int __pipedes[2]; +{ + if (__pipedes == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__pipe) +stub_warning (pipe) + +weak_alias (__pipe, pipe) +#include <stub-tag.h> diff --git a/io/poll.c b/io/poll.c new file mode 100644 index 0000000000..9f2f191764 --- /dev/null +++ b/io/poll.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1994, 1995, 1996, 1997, 2001 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 <sys/poll.h> +#include <errno.h> + +/* Poll the file descriptors described by the NFDS structures starting at + FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for + an event to occur; if TIMEOUT is -1, block until an event occurs. + Returns the number of file descriptors with events, zero if timed out, + or -1 for errors. */ + +int +poll (fds, nfds, timeout) + struct pollfd *fds; + nfds_t nfds; + int timeout; +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (poll) +#include <stub-tag.h> diff --git a/io/posix_fadvise.c b/io/posix_fadvise.c new file mode 100644 index 0000000000..92f8bb8974 --- /dev/null +++ b/io/posix_fadvise.c @@ -0,0 +1,31 @@ +/* Copyright (C) 2000, 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 + 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> + +/* Advice the system about the expected behaviour of the application with + respect to the file associated with FD. */ + +int +posix_fadvise (int fd, __off_t offset, __off_t len, int advise) +{ + return ENOSYS; +} +stub_warning (posix_fadvise) +#include <stub-tag.h> diff --git a/io/posix_fadvise64.c b/io/posix_fadvise64.c new file mode 100644 index 0000000000..e7eae5e6e3 --- /dev/null +++ b/io/posix_fadvise64.c @@ -0,0 +1,31 @@ +/* Copyright (C) 2000, 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 + 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> + +/* Advice the system about the expected behaviour of the application with + respect to the file associated with FD. */ + +int +posix_fadvise64 (int fd, __off64_t offset, __off64_t len, int advise) +{ + return ENOSYS; +} +stub_warning (posix_fadvise64) +#include <stub-tag.h> diff --git a/io/posix_fallocate.c b/io/posix_fallocate.c new file mode 100644 index 0000000000..218b4adbe3 --- /dev/null +++ b/io/posix_fallocate.c @@ -0,0 +1,31 @@ +/* Copyright (C) 2000, 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 + 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> + +/* Reserve storage for the data of the file associated with FD. */ + +int +posix_fallocate (int fd, __off_t offset, __off_t len) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (posix_fallocate) +#include <stub-tag.h> diff --git a/io/posix_fallocate64.c b/io/posix_fallocate64.c new file mode 100644 index 0000000000..80c1cd385d --- /dev/null +++ b/io/posix_fallocate64.c @@ -0,0 +1,31 @@ +/* Copyright (C) 2000, 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 + 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> + +/* Reserve storage for the data of the file associated with FD. */ + +int +posix_fallocate64 (int fd, __off64_t offset, __off64_t len) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (posix_fallocate64) +#include <stub-tag.h> diff --git a/io/ppoll.c b/io/ppoll.c new file mode 100644 index 0000000000..a035cfeb1f --- /dev/null +++ b/io/ppoll.c @@ -0,0 +1,76 @@ +/* Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@redhat.com>, 2006. + + 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 <limits.h> +#include <signal.h> +#include <stddef.h> /* For NULL. */ +#include <sys/poll.h> +#include <sysdep-cancel.h> + + +int +ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, + const sigset_t *sigmask) +{ + int tval = -1; + + /* poll uses a simple millisecond value. Convert it. */ + if (timeout != NULL) + { + if (timeout->tv_sec < 0 + || timeout->tv_nsec < 0 || timeout->tv_nsec >= 1000000000) + { + __set_errno (EINVAL); + return -1; + } + + if (timeout->tv_sec > INT_MAX / 1000 + || (timeout->tv_sec == INT_MAX / 1000 + && ((timeout->tv_nsec + 999999) / 1000000 > INT_MAX % 1000))) + /* We cannot represent the timeout in an int value. Wait + forever. */ + tval = -1; + else + tval = (timeout->tv_sec * 1000 + + (timeout->tv_nsec + 999999) / 1000000); + } + + /* The setting and restoring of the signal mask and the select call + should be an atomic operation. This can't be done without kernel + help. */ + sigset_t savemask; + if (sigmask != NULL) + __sigprocmask (SIG_SETMASK, sigmask, &savemask); + + /* Note the ppoll() is a cancellation point. But since we call + poll() which itself is a cancellation point we do not have + to do anything here. */ + int retval = __poll (fds, nfds, tval); + + if (sigmask != NULL) + __sigprocmask (SIG_SETMASK, &savemask, NULL); + + return retval; +} + +#ifndef ppoll +/* __poll handles cancellation. */ +LIBC_CANCEL_HANDLED (); +#endif diff --git a/io/read.c b/io/read.c new file mode 100644 index 0000000000..3943edd689 --- /dev/null +++ b/io/read.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 2002 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 <unistd.h> +#include <stddef.h> + +/* Read NBYTES into BUF from FD. Return the number read or -1. */ +ssize_t +__libc_read (int fd, void *buf, size_t nbytes) +{ + if (nbytes == 0) + return 0; + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } + if (buf == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__libc_read) +stub_warning (read) + +weak_alias (__libc_read, __read) +libc_hidden_weak (__read) +weak_alias (__libc_read, read) +#include <stub-tag.h> diff --git a/io/readlink.c b/io/readlink.c new file mode 100644 index 0000000000..b69d08695c --- /dev/null +++ b/io/readlink.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 2006 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 <unistd.h> + +/* Read the contents of the symbolic link PATH into no more than + LEN bytes of BUF. The contents are not null-terminated. + Returns the number of characters read, or -1 for errors. */ +ssize_t +__readlink (path, buf, len) + const char *path; + char *buf; + size_t len; +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (readlink) + +weak_alias (__readlink, readlink) +#include <stub-tag.h> diff --git a/io/readlinkat.c b/io/readlinkat.c new file mode 100644 index 0000000000..7e6a2227d8 --- /dev/null +++ b/io/readlinkat.c @@ -0,0 +1,51 @@ +/* Copyright (C) 2005, 2006 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 <unistd.h> + +/* Read the contents of the symbolic link PATH relative to FD into no + more than LEN bytes of BUF. The contents are not null-terminated. + Returns the number of characters read, or -1 for errors. */ +ssize_t +readlinkat (fd, path, buf, len) + int fd; + const char *path; + char *buf; + size_t len; +{ + if (path == NULL) + { + __set_errno (EINVAL); + return -1; + } + + if (fd != AT_FDCWD && fd < 0 && *path != '/') + { + __set_errno (EBADF); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (readlinkat) +libc_hidden_def (readlinkat) + +#include <stub-tag.h> diff --git a/io/rmdir.c b/io/rmdir.c new file mode 100644 index 0000000000..5a16fd4284 --- /dev/null +++ b/io/rmdir.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1991, 1995, 1996, 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. */ + +#include <errno.h> +#include <stddef.h> +#include <unistd.h> + + +/* Remove the directory PATH. */ +int +__rmdir (path) + const char *path; +{ + if (path == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (rmdir) + +weak_alias (__rmdir, rmdir) +#include <stub-tag.h> diff --git a/io/sendfile.c b/io/sendfile.c new file mode 100644 index 0000000000..98dc9a814d --- /dev/null +++ b/io/sendfile.c @@ -0,0 +1,33 @@ +/* sendfile -- copy data directly from one file descriptor to another + Copyright (C) 2002 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 <sys/sendfile.h> +#include <errno.h> + +/* Send COUNT bytes from file associated with IN_FD starting at OFFSET to + descriptor OUT_FD. */ +ssize_t +sendfile (int out_fd, int in_fd, off_t *offset, size_t count) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (sendfile) + +#include <stub-tag.h> diff --git a/io/sendfile64.c b/io/sendfile64.c new file mode 100644 index 0000000000..76b961e22a --- /dev/null +++ b/io/sendfile64.c @@ -0,0 +1,33 @@ +/* sendfile -- copy data directly from one file descriptor to another + Copyright (C) 2002 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 <sys/sendfile.h> +#include <errno.h> + +/* Send COUNT bytes from file associated with IN_FD starting at OFFSET to + descriptor OUT_FD. */ +ssize_t +sendfile64 (int out_fd, int in_fd, off64_t *offset, size_t count) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (sendfile64) + +#include <stub-tag.h> diff --git a/io/statfs.c b/io/statfs.c new file mode 100644 index 0000000000..af4a9ea4e5 --- /dev/null +++ b/io/statfs.c @@ -0,0 +1,35 @@ +/* statfs -- Return information about the filesystem on which FILE resides. + Copyright (C) 1996, 1997, 2002 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 <sys/statfs.h> +#include <stddef.h> + +/* Return information about the filesystem on which FILE resides. */ +int +__statfs (const char *file, struct statfs *buf) +{ + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__statfs) +weak_alias (__statfs, statfs) + +stub_warning (statfs) +#include <stub-tag.h> diff --git a/io/statfs64.c b/io/statfs64.c new file mode 100644 index 0000000000..cf1a7d82a4 --- /dev/null +++ b/io/statfs64.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1998, 2000 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 <sys/statfs.h> + +/* Return information about the filesystem on which FILE resides. */ +int +__statfs64 (const char *file, struct statfs64 *buf) +{ + __set_errno (ENOSYS); + return -1; +} +weak_alias (__statfs64, statfs64) + +stub_warning (statfs64) +#include <stub-tag.h> diff --git a/io/statvfs.c b/io/statvfs.c new file mode 100644 index 0000000000..22e24cfeeb --- /dev/null +++ b/io/statvfs.c @@ -0,0 +1,34 @@ +/* Return information about the filesystem on which FILE resides. + Copyright (C) 1998, 2002 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 <sys/statvfs.h> +#include <stddef.h> + +/* Return information about the filesystem on which FILE resides. */ +int +__statvfs (const char *file, struct statvfs *buf) +{ + __set_errno (ENOSYS); + return -1; +} +weak_alias (__statvfs, statvfs) +libc_hidden_weak (statvfs) +stub_warning (statvfs) +#include <stub-tag.h> diff --git a/io/statvfs64.c b/io/statvfs64.c new file mode 100644 index 0000000000..4424abdbea --- /dev/null +++ b/io/statvfs64.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1998, 2001 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 <sys/statvfs.h> + +/* Return information about the filesystem on which FILE resides. */ +int +__statvfs64 (const char *file, struct statvfs64 *buf) +{ + __set_errno (ENOSYS); + return -1; +} +weak_alias (__statvfs64, statvfs64) + +stub_warning (statvfs64) +#include <stub-tag.h> diff --git a/io/symlink.c b/io/symlink.c new file mode 100644 index 0000000000..e6c6709f1a --- /dev/null +++ b/io/symlink.c @@ -0,0 +1,42 @@ +/* Copyright (C) 1991, 1995, 1996, 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. */ + +#include <errno.h> +#include <stddef.h> +#include <unistd.h> + + +/* Make a link to FROM called TO. */ +int +__symlink (from, to) + const char *from; + const char *to; +{ + if (from == NULL || to == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (symlink) + +weak_alias (__symlink, symlink) +#include <stub-tag.h> diff --git a/io/symlinkat.c b/io/symlinkat.c new file mode 100644 index 0000000000..5c2f3f553a --- /dev/null +++ b/io/symlinkat.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> + + +/* Make a link to FROM called TO relative to FD. */ +int +symlinkat (from, fd, to) + const char *from; + int fd; + const char *to; +{ + if (from == NULL || to == NULL) + { + __set_errno (EINVAL); + return -1; + } + + if (fd != AT_FDCWD && fd < 0 && *to != '/') + { + __set_errno (EBADF); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (symlinkat) + +#include <stub-tag.h> diff --git a/io/sys/poll.h b/io/sys/poll.h index 89a27eab2b..4085b785ee 100644 --- a/io/sys/poll.h +++ b/io/sys/poll.h @@ -1,5 +1,5 @@ /* Compatibility definitions for System V `poll' interface. - Copyright (C) 1994,96,97,98,99,2000,2001,2004 Free Software Foundation, Inc. + Copyright (C) 1994,1996-2001,2004,2005,2006 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,6 +24,13 @@ /* Get the platform dependent bits of `poll'. */ #include <bits/poll.h> +#ifdef __USE_GNU +/* Get the __sigset_t definition. */ +# include <bits/sigset.h> +/* Get the timespec definition. */ +# define __need_timespec +# include <time.h> +#endif /* Type used for the number of file descriptors. */ @@ -44,9 +51,24 @@ __BEGIN_DECLS FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for an event to occur; if TIMEOUT is -1, block until an event occurs. Returns the number of file descriptors with events, zero if timed out, - or -1 for errors. */ + or -1 for errors. + + This function is a cancellation point and therefore not marked with + __THROW. */ extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout); +#ifdef __USE_GNU +/* Like poll, but before waiting the threads signal mask is replaced + with that specified in the fourth parameter. For better usability, + the timeout value is specified using a TIMESPEC object. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int ppoll (struct pollfd *__fds, nfds_t __nfds, + __const struct timespec *__timeout, + __const __sigset_t *__ss); +#endif + __END_DECLS #endif /* sys/poll.h */ diff --git a/io/sys/sendfile.h b/io/sys/sendfile.h index 24256b5414..4c1367b6be 100644 --- a/io/sys/sendfile.h +++ b/io/sys/sendfile.h @@ -32,19 +32,19 @@ __BEGIN_DECLS case of error. */ #ifndef __USE_FILE_OFFSET64 extern ssize_t sendfile (int __out_fd, int __in_fd, off_t *__offset, - size_t __count) __THROW __nonnull ((3)); + size_t __count) __THROW; #else # ifdef __REDIRECT_NTH extern ssize_t __REDIRECT_NTH (sendfile, (int __out_fd, int __in_fd, __off64_t *__offset, - size_t __count), sendfile64) __nonnull ((3)); + size_t __count), sendfile64); # else # define sendfile sendfile64 # endif #endif #ifdef __USE_LARGEFILE64 extern ssize_t sendfile64 (int __out_fd, int __in_fd, __off64_t *__offset, - size_t __count) __THROW __nonnull ((3)); + size_t __count) __THROW; #endif __END_DECLS diff --git a/io/sys/stat.h b/io/sys/stat.h index 7075003922..4cc0b429a2 100644 --- a/io/sys/stat.h +++ b/io/sys/stat.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1992,1995-2002,2003,2004 Free Software Foundation, Inc. +/* Copyright (C) 1991,1992,1995-2004,2005,2006 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 @@ -228,6 +228,30 @@ extern int stat64 (__const char *__restrict __file, extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2)); #endif +#ifdef __USE_ATFILE +/* Similar to stat, get the attributes for FILE and put them in BUF. + Relative path names are interpreted relative to FD unless FD is + AT_FDCWD. */ +# ifndef __USE_FILE_OFFSET64 +extern int fstatat (int __fd, __const char *__restrict __file, + struct stat *__restrict __buf, int __flag) + __THROW __nonnull ((2, 3)); +# else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (fstatat, (int __fd, __const char *__restrict __file, + struct stat *__restrict __buf, + int __flag), + fstatat64) __nonnull ((2, 3)); +# else +# define fstatat fstatat64 +# endif +# endif + +extern int fstatat64 (int __fd, __const char *__restrict __file, + struct stat64 *__restrict __buf, int __flag) + __THROW __nonnull ((2, 3)); +#endif + #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED # ifndef __USE_FILE_OFFSET64 /* Get file attributes about FILE and put them in BUF. @@ -269,6 +293,14 @@ extern int lchmod (__const char *__file, __mode_t __mode) extern int fchmod (int __fd, __mode_t __mode) __THROW; #endif +#ifdef __USE_ATFILE +/* Set file access permissions of FILE relative to + the directory FD is open on. */ +extern int fchmodat (int __fd, __const char *__file, __mode_t mode, int __flag) + __THROW __nonnull ((2)) __wur; +#endif /* Use ATFILE. */ + + /* Set the file creation mask of the current process to MASK, and return the old creation mask. */ @@ -284,6 +316,14 @@ extern __mode_t getumask (void) __THROW; extern int mkdir (__const char *__path, __mode_t __mode) __THROW __nonnull ((1)); +#ifdef __USE_ATFILE +/* Like mkdir, create a new directory with permission bits MODE. But + interpret relative PATH names relative to the directory associated + with FD. */ +extern int mkdirat (int __fd, __const char *__path, __mode_t __mode) + __THROW __nonnull ((2)); +#endif + /* Create a device file named PATH, with permission and special bits MODE and device number DEV (which can be constructed from major and minor device numbers with the `makedev' macro above). */ @@ -292,10 +332,26 @@ extern int mknod (__const char *__path, __mode_t __mode, __dev_t __dev) __THROW __nonnull ((1)); #endif +#ifdef __USE_ATFILE +/* Like mknod, create a new device file with permission bits MODE and + device number DEV. But interpret relative PATH names relative to + the directory associated with FD. */ +extern int mknodat (int __fd, __const char *__path, __mode_t __mode, + __dev_t __dev) __THROW __nonnull ((2)); +#endif + /* Create a new FIFO named PATH, with permission bits MODE. */ extern int mkfifo (__const char *__path, __mode_t __mode) __THROW __nonnull ((1)); + +#ifdef __USE_ATFILE +/* Like mkfifo, create a new FIFO with permission bits MODE. But + interpret relative PATH names relative to the directory associated + with FD. */ +extern int mkfifoat (int __fd, __const char *__path, __mode_t __mode) + __THROW __nonnull ((2)); +#endif /* To allow the `struct stat' structure and the file type `mode_t' bits to vary without changing shared library major version number, @@ -327,6 +383,9 @@ extern int __xstat (int __ver, __const char *__filename, struct stat *__stat_buf) __THROW __nonnull ((2, 3)); extern int __lxstat (int __ver, __const char *__filename, struct stat *__stat_buf) __THROW __nonnull ((2, 3)); +extern int __fxstatat (int __ver, int __fildes, __const char *__filename, + struct stat *__stat_buf, int __flag) + __THROW __nonnull ((3, 4)); #else # ifdef __REDIRECT_NTH extern int __REDIRECT_NTH (__fxstat, (int __ver, int __fildes, @@ -338,6 +397,10 @@ extern int __REDIRECT_NTH (__xstat, (int __ver, __const char *__filename, extern int __REDIRECT_NTH (__lxstat, (int __ver, __const char *__filename, struct stat *__stat_buf), __lxstat64) __nonnull ((2, 3)); +extern int __REDIRECT_NTH (__fxstatat, (int __ver, int __fildes, + __const char *__filename, + struct stat *__stat_buf, int __flag), + __fxstatat64) __nonnull ((3, 4)); # else # define __fxstat __fxstat64 @@ -353,10 +416,17 @@ extern int __xstat64 (int __ver, __const char *__filename, struct stat64 *__stat_buf) __THROW __nonnull ((2, 3)); extern int __lxstat64 (int __ver, __const char *__filename, struct stat64 *__stat_buf) __THROW __nonnull ((2, 3)); +extern int __fxstatat64 (int __ver, int __fildes, __const char *__filename, + struct stat64 *__stat_buf, int __flag) + __THROW __nonnull ((3, 4)); #endif extern int __xmknod (int __ver, __const char *__path, __mode_t __mode, __dev_t *__dev) __THROW __nonnull ((2, 4)); +extern int __xmknodat (int __ver, int __fd, __const char *__path, + __mode_t __mode, __dev_t *__dev) + __THROW __nonnull ((3, 5)); + #if defined __GNUC__ && __GNUC__ >= 2 /* Inlined versions of the real stat and mknod functions. */ @@ -380,6 +450,15 @@ __NTH (fstat (int __fd, struct stat *__statbuf)) return __fxstat (_STAT_VER, __fd, __statbuf); } +# ifdef __USE_ATFILE +extern __inline__ int +__NTH (fstatat (int __fd, __const char *__filename, struct stat *__statbuf, + int __flag)) +{ + return __fxstatat (_STAT_VER, __fd, __filename, __statbuf, __flag); +} +# endif + # if defined __USE_MISC || defined __USE_BSD extern __inline__ int __NTH (mknod (__const char *__path, __mode_t __mode, __dev_t __dev)) @@ -388,6 +467,15 @@ __NTH (mknod (__const char *__path, __mode_t __mode, __dev_t __dev)) } # endif +# ifdef __USE_ATFILE +extern __inline__ int +__NTH (mknodat (int __fd, __const char *__path, __mode_t __mode, + __dev_t __dev)) +{ + return __xmknodat (_MKNOD_VER, __fd, __path, __mode, &__dev); +} +# endif + # if defined __USE_LARGEFILE64 \ && (! defined __USE_FILE_OFFSET64 \ || (defined __REDIRECT_NTH && defined __OPTIMIZE__)) @@ -410,6 +498,16 @@ __NTH (fstat64 (int __fd, struct stat64 *__statbuf)) { return __fxstat64 (_STAT_VER, __fd, __statbuf); } + +# ifdef __USE_GNU +extern __inline__ int +__NTH (fstatat64 (int __fd, __const char *__filename, struct stat64 *__statbuf, + int __flag)) +{ + return __fxstatat64 (_STAT_VER, __fd, __filename, __statbuf, __flag); +} +# endif + # endif #endif diff --git a/io/test-lfs.c b/io/test-lfs.c index a4669c3984..c27af408eb 100644 --- a/io/test-lfs.c +++ b/io/test-lfs.c @@ -50,7 +50,7 @@ int fd; void do_prepare (int argc, char *argv[]) { - char name_len; + size_t name_len; struct rlimit64 rlim; name_len = strlen (test_dir); diff --git a/io/tst-faccessat.c b/io/tst-faccessat.c new file mode 100644 index 0000000000..48532070a7 --- /dev/null +++ b/io/tst-faccessat.c @@ -0,0 +1,212 @@ +/* Test for faccessat function. */ + +#include <dirent.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + +static int do_test (void); +#define TEST_FUNCTION do_test () + +#include "../test-skeleton.c" + +static int dir_fd; + +static void +prepare (void) +{ + size_t test_dir_len = strlen (test_dir); + static const char dir_name[] = "/tst-faccessat.XXXXXX"; + + size_t dirbuflen = test_dir_len + sizeof (dir_name); + char *dirbuf = malloc (dirbuflen); + if (dirbuf == NULL) + { + puts ("out of memory"); + exit (1); + } + + snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name); + if (mkdtemp (dirbuf) == NULL) + { + puts ("cannot create temporary directory"); + exit (1); + } + + add_temp_file (dirbuf); + + dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY); + if (dir_fd == -1) + { + puts ("cannot open directory"); + exit (1); + } +} + + +static int +do_test (void) +{ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + /* The directory should be empty save the . and .. files. */ + DIR *dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + /* Try to create a file. */ + int fd = openat (dir_fd, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666); + if (fd == -1) + { + if (errno == ENOSYS) + { + puts ("*at functions not supported"); + return 0; + } + + puts ("file creation failed"); + return 1; + } + write (fd, "hello", 5); + puts ("file created"); + + /* Before closing the file, try using this file descriptor to open + another file. This must fail. */ + if (faccessat (fd, "should-not-work", F_OK, AT_EACCESS) != -1) + { + puts ("faccessat using descriptor for normal file worked"); + return 1; + } + if (errno != ENOTDIR) + { + puts ("\ +error for faccessat using descriptor for normal file not ENOTDIR "); + return 1; + } + + close (fd); + + int result = 0; + + if (faccessat (dir_fd, "some-file", F_OK, AT_EACCESS)) + { + printf ("faccessat F_OK: %m\n"); + result = 1; + } + if (faccessat (dir_fd, "some-file", W_OK, AT_EACCESS)) + { + printf ("faccessat W_OK: %m\n"); + result = 1; + } + + errno = 0; + if (faccessat (dir_fd, "some-file", X_OK, AT_EACCESS) == 0 + || errno != EACCES) + { + printf ("faccessat X_OK on nonexecutable: %m\n"); + result = 1; + } + + if (fchmodat (dir_fd, "some-file", 0400, 0) != 0) + { + printf ("fchownat failed: %m\n"); + return 1; + } + + if (faccessat (dir_fd, "some-file", R_OK, AT_EACCESS)) + { + printf ("faccessat R_OK: %m\n"); + result = 1; + } + + errno = 0; + if (faccessat (dir_fd, "some-file", W_OK, AT_EACCESS) == 0 + ? (geteuid () != 0) : (errno != EACCES)) + { + printf ("faccessat W_OK on unwritable file: %m\n"); + result = 1; + } + + /* Create a file descriptor which is closed again right away. */ + int dir_fd2 = dup (dir_fd); + if (dir_fd2 == -1) + { + puts ("dup failed"); + return 1; + } + close (dir_fd2); + + /* With the file descriptor closed the next call must fail. */ + if (faccessat (dir_fd2, "some-file", F_OK, AT_EACCESS) != -1) + { + puts ("faccessat using closed descriptor succeeded"); + return 1; + } + if (errno != EBADF) + { + puts ("faccessat using closed descriptor did not set EBADF"); + return 1; + } + + /* Same with a non-existing file. */ + if (faccessat (dir_fd2, "non-existing-file", F_OK, AT_EACCESS) != -1) + { + puts ("2nd faccessat using closed descriptor succeeded"); + return 1; + } + if (errno != EBADF) + { + puts ("2nd faccessat using closed descriptor did not set EBADF"); + return 1; + } + + if (unlinkat (dir_fd, "some-file", 0) != 0) + { + puts ("unlinkat failed"); + result = 1; + } + + close (dir_fd); + + fd = faccessat (-1, "some-file", F_OK, AT_EACCESS); + if (fd != -1) + { + puts ("faccessat using -1 descriptor succeeded"); + return 1; + } + if (errno != EBADF) + { + puts ("faccessat using -1 descriptor did not set EBADF"); + return 1; + } + + return result; +} diff --git a/io/tst-fchmodat.c b/io/tst-fchmodat.c new file mode 100644 index 0000000000..bfb75d62e5 --- /dev/null +++ b/io/tst-fchmodat.c @@ -0,0 +1,191 @@ +/* Test for fchmodat function. */ + +#include <dirent.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + +static int do_test (void); +#define TEST_FUNCTION do_test () + +#include "../test-skeleton.c" + +static int dir_fd; + +static void +prepare (void) +{ + size_t test_dir_len = strlen (test_dir); + static const char dir_name[] = "/tst-fchmodat.XXXXXX"; + + size_t dirbuflen = test_dir_len + sizeof (dir_name); + char *dirbuf = malloc (dirbuflen); + if (dirbuf == NULL) + { + puts ("out of memory"); + exit (1); + } + + snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name); + if (mkdtemp (dirbuf) == NULL) + { + puts ("cannot create temporary directory"); + exit (1); + } + + add_temp_file (dirbuf); + + dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY); + if (dir_fd == -1) + { + puts ("cannot open directory"); + exit (1); + } +} + + +static int +do_test (void) +{ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + /* The directory should be empty save the . and .. files. */ + DIR *dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + umask (022); + + /* Try to create a file. */ + int fd = openat (dir_fd, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666); + if (fd == -1) + { + if (errno == ENOSYS) + { + puts ("*at functions not supported"); + return 0; + } + + puts ("file creation failed"); + return 1; + } + write (fd, "hello", 5); + puts ("file created"); + + struct stat64 st1; + if (fstat64 (fd, &st1) != 0) + { + puts ("fstat64 failed"); + return 1; + } + + /* Before closing the file, try using this file descriptor to open + another file. This must fail. */ + if (fchmodat (fd, "some-file", 0400, 0) != -1) + { + puts ("fchmodat using descriptor for normal file worked"); + return 1; + } + if (errno != ENOTDIR) + { + puts ("\ +error for fchmodat using descriptor for normal file not ENOTDIR "); + return 1; + } + + close (fd); + + if ((st1.st_mode & 0777) != 0644) + { + printf ("openat created mode %04o, not 0644\n", (st1.st_mode & 0777)); + return 1; + } + + if (fchmodat (dir_fd, "some-file", 0400, 0) != 0) + { + puts ("fchownat failed"); + return 1; + } + + struct stat64 st2; + if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0) + { + puts ("fstatat64 failed"); + return 1; + } + + if ((st2.st_mode & 0777) != 0400) + { + puts ("mode change failed"); + return 1; + } + + if (unlinkat (dir_fd, "some-file", 0) != 0) + { + puts ("unlinkat failed"); + return 1; + } + + /* Create a file descriptor which is closed again right away. */ + int dir_fd2 = dup (dir_fd); + if (dir_fd2 == -1) + { + puts ("dup failed"); + return 1; + } + close (dir_fd2); + + if (fchmodat (dir_fd2, "some-file", 0400, 0) != -1) + { + puts ("fchmodat using closed descriptor worked"); + return 1; + } + if (errno != EBADF) + { + puts ("error for fchmodat using closed descriptor not EBADF "); + return 1; + } + + close (dir_fd); + + if (fchmodat (-1, "some-file", 0400, 0) != -1) + { + puts ("fchmodat using invalid descriptor worked"); + return 1; + } + if (errno != EBADF) + { + puts ("error for fchmodat using invalid descriptor not EBADF "); + return 1; + } + + return 0; +} diff --git a/io/tst-fchownat.c b/io/tst-fchownat.c new file mode 100644 index 0000000000..fd32ac9e6b --- /dev/null +++ b/io/tst-fchownat.c @@ -0,0 +1,190 @@ +#include <dirent.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + +static int do_test (void); +#define TEST_FUNCTION do_test () + +#include "../test-skeleton.c" + +static int dir_fd; + +static void +prepare (void) +{ +#if _POSIX_CHOWN_RESTRICTED > 0 + uid_t uid = getuid (); + if (uid != 0) + { + puts ("need root privileges"); + exit (0); + } +#endif + + size_t test_dir_len = strlen (test_dir); + static const char dir_name[] = "/tst-fchownat.XXXXXX"; + + size_t dirbuflen = test_dir_len + sizeof (dir_name); + char *dirbuf = malloc (dirbuflen); + if (dirbuf == NULL) + { + puts ("out of memory"); + exit (1); + } + + snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name); + if (mkdtemp (dirbuf) == NULL) + { + puts ("cannot create temporary directory"); + exit (1); + } + + add_temp_file (dirbuf); + + dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY); + if (dir_fd == -1) + { + puts ("cannot open directory"); + exit (1); + } +} + + +static int +do_test (void) +{ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + DIR *dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + /* Try to create a file. */ + int fd = openat (dir_fd, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666); + if (fd == -1) + { + if (errno == ENOSYS) + { + puts ("*at functions not supported"); + return 0; + } + + puts ("file creation failed"); + return 1; + } + write (fd, "hello", 5); + puts ("file created"); + + struct stat64 st1; + if (fstat64 (fd, &st1) != 0) + { + puts ("fstat64 failed"); + return 1; + } + + /* Before closing the file, try using this file descriptor to open + another file. This must fail. */ + if (fchownat (fd, "some-file", 1, 1, 0) != -1) + { + puts ("fchownat using descriptor for normal file worked"); + return 1; + } + if (errno != ENOTDIR) + { + puts ("\ +error for fchownat using descriptor for normal file not ENOTDIR "); + return 1; + } + + close (fd); + + if (fchownat (dir_fd, "some-file", st1.st_uid + 1, st1.st_gid + 1, 0) != 0) + { + puts ("fchownat failed"); + return 1; + } + + struct stat64 st2; + if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0) + { + puts ("fstatat64 failed"); + return 1; + } + + if (st1.st_uid + 1 != st2.st_uid || st1.st_gid + 1 != st2.st_gid) + { + puts ("owner change failed"); + return 1; + } + + if (unlinkat (dir_fd, "some-file", 0) != 0) + { + puts ("unlinkat failed"); + return 1; + } + + /* Create a file descriptor which is closed again right away. */ + int dir_fd2 = dup (dir_fd); + if (dir_fd2 == -1) + { + puts ("dup failed"); + return 1; + } + close (dir_fd2); + + if (fchownat (dir_fd2, "some-file", 1, 1, 0) != -1) + { + puts ("fchownat using closed descriptor worked"); + return 1; + } + if (errno != EBADF) + { + puts ("error for fchownat using closed descriptor not EBADF "); + return 1; + } + + close (dir_fd); + + if (fchownat (-1, "some-file", 1, 1, 0) != -1) + { + puts ("fchownat using invalid descriptor worked"); + return 1; + } + if (errno != EBADF) + { + puts ("error for fchownat using invalid descriptor not EBADF "); + return 1; + } + + return 0; +} diff --git a/io/tst-fcntl.c b/io/tst-fcntl.c index fed884913c..93ea9b0b02 100644 --- a/io/tst-fcntl.c +++ b/io/tst-fcntl.c @@ -42,7 +42,7 @@ static char *name; void do_prepare (int argc, char *argv[]) { - char name_len; + size_t name_len; name_len = strlen (test_dir); name = malloc (name_len + sizeof ("/fcntlXXXXXX")); diff --git a/io/tst-fstatat.c b/io/tst-fstatat.c new file mode 100644 index 0000000000..5493102167 --- /dev/null +++ b/io/tst-fstatat.c @@ -0,0 +1,188 @@ +#include <dirent.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + +static int do_test (void); +#define TEST_FUNCTION do_test () + +#include "../test-skeleton.c" + +static int dir_fd; + +static void +prepare (void) +{ + size_t test_dir_len = strlen (test_dir); + static const char dir_name[] = "/tst-fstatat.XXXXXX"; + + size_t dirbuflen = test_dir_len + sizeof (dir_name); + char *dirbuf = malloc (dirbuflen); + if (dirbuf == NULL) + { + puts ("out of memory"); + exit (1); + } + + snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name); + if (mkdtemp (dirbuf) == NULL) + { + puts ("cannot create temporary directory"); + exit (1); + } + + add_temp_file (dirbuf); + + dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY); + if (dir_fd == -1) + { + puts ("cannot open directory"); + exit (1); + } +} + + +static int +do_test (void) +{ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + DIR *dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + /* Try to create a file. */ + int fd = openat (dir_fd, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666); + if (fd == -1) + { + if (errno == ENOSYS) + { + puts ("*at functions not supported"); + return 0; + } + + puts ("file creation failed"); + return 1; + } + write (fd, "hello", 5); + puts ("file created"); + + struct stat64 st1; + + /* Before closing the file, try using this file descriptor to open + another file. This must fail. */ + if (fstatat64 (fd, "some-file", &st1, 0) != -1) + { + puts ("fstatatat using descriptor for normal file worked"); + return 1; + } + if (errno != ENOTDIR) + { + puts ("error for fstatat using descriptor for normal file not ENOTDIR "); + return 1; + } + + if (fstat64 (fd, &st1) != 0) + { + puts ("fstat64 failed"); + return 1; + } + + close (fd); + + struct stat64 st2; + if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0) + { + puts ("fstatat64 failed"); + return 1; + } + + if (st1.st_dev != st2.st_dev + || st1.st_ino != st2.st_ino + || st1.st_size != st2.st_size) + { + puts ("stat results do not match"); + return 1; + } + + if (unlinkat (dir_fd, "some-file", 0) != 0) + { + puts ("unlinkat failed"); + return 1; + } + + if (fstatat64 (dir_fd, "some-file", &st2, 0) == 0) + { + puts ("second fstatat64 succeeded"); + return 1; + } + if (errno != ENOENT) + { + puts ("second fstatat64 did not fail with ENOENT"); + return 1; + } + + /* Create a file descriptor which is closed again right away. */ + int dir_fd2 = dup (dir_fd); + if (dir_fd2 == -1) + { + puts ("dup failed"); + return 1; + } + close (dir_fd2); + + if (fstatat64 (dir_fd2, "some-file", &st1, 0) != -1) + { + puts ("fstatat64 using closed descriptor worked"); + return 1; + } + if (errno != EBADF) + { + puts ("error for fstatat using closed descriptor not EBADF "); + return 1; + } + + close (dir_fd); + + if (fstatat64 (-1, "some-file", &st1, 0) != -1) + { + puts ("fstatat64 using invalid descriptor worked"); + return 1; + } + if (errno != EBADF) + { + puts ("error for fstatat using invalid descriptor not EBADF "); + return 1; + } + + return 0; +} diff --git a/io/tst-futimesat.c b/io/tst-futimesat.c new file mode 100644 index 0000000000..c1e8d93f41 --- /dev/null +++ b/io/tst-futimesat.c @@ -0,0 +1,147 @@ +#include <dirent.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/time.h> + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + +static int do_test (void); +#define TEST_FUNCTION do_test () + +#include "../test-skeleton.c" + +static int dir_fd; + +static void +prepare (void) +{ + size_t test_dir_len = strlen (test_dir); + static const char dir_name[] = "/tst-futimesat.XXXXXX"; + + size_t dirbuflen = test_dir_len + sizeof (dir_name); + char *dirbuf = malloc (dirbuflen); + if (dirbuf == NULL) + { + puts ("out of memory"); + exit (1); + } + + snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name); + if (mkdtemp (dirbuf) == NULL) + { + puts ("cannot create temporary directory"); + exit (1); + } + + add_temp_file (dirbuf); + + dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY); + if (dir_fd == -1) + { + puts ("cannot open directory"); + exit (1); + } +} + + +static int +do_test (void) +{ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + DIR *dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + /* Try to create a file. */ + int fd = openat (dir_fd, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666); + if (fd == -1) + { + if (errno == ENOSYS) + { + puts ("*at functions not supported"); + return 0; + } + + puts ("file creation failed"); + return 1; + } + write (fd, "hello", 5); + puts ("file created"); + + struct stat64 st1; + if (fstat64 (fd, &st1) != 0) + { + puts ("fstat64 failed"); + return 1; + } + + close (fd); + + struct timeval tv[2]; + tv[0].tv_sec = st1.st_atime + 1; + tv[0].tv_usec = 0; + tv[1].tv_sec = st1.st_mtime + 1; + tv[1].tv_usec = 0; + if (futimesat (dir_fd, "some-file", tv) != 0) + { + puts ("futimesat failed"); + return 1; + } + + struct stat64 st2; + if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0) + { + puts ("fstatat64 failed"); + return 1; + } + + if (st2.st_mtime != tv[1].tv_sec +#ifdef _STATBUF_ST_NSEC + || st2.st_mtim.tv_nsec != 0 +#endif + ) + { + puts ("stat shows different mtime"); + return 1; + } + + + if (unlinkat (dir_fd, "some-file", 0) != 0) + { + puts ("unlinkat failed"); + return 1; + } + + close (dir_fd); + + return 0; +} diff --git a/io/tst-linkat.c b/io/tst-linkat.c new file mode 100644 index 0000000000..d63c982751 --- /dev/null +++ b/io/tst-linkat.c @@ -0,0 +1,171 @@ +#include <dirent.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + +static int do_test (void); +#define TEST_FUNCTION do_test () + +#include "../test-skeleton.c" + +static int dir_fd; + +static void +prepare (void) +{ + size_t test_dir_len = strlen (test_dir); + static const char dir_name[] = "/tst-linkat.XXXXXX"; + + size_t dirbuflen = test_dir_len + sizeof (dir_name); + char *dirbuf = malloc (dirbuflen); + if (dirbuf == NULL) + { + puts ("out of memory"); + exit (1); + } + + snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name); + if (mkdtemp (dirbuf) == NULL) + { + puts ("cannot create temporary directory"); + exit (1); + } + + add_temp_file (dirbuf); + + dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY); + if (dir_fd == -1) + { + puts ("cannot open directory"); + exit (1); + } +} + + +static int +do_test (void) +{ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + DIR *dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + /* Try to create a file. */ + int fd = openat (dir_fd, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666); + if (fd == -1) + { + if (errno == ENOSYS) + { + puts ("*at functions not supported"); + return 0; + } + + puts ("file creation failed"); + return 1; + } + write (fd, "hello", 5); + puts ("file created"); + + struct stat64 st1; + if (fstat64 (fd, &st1) != 0) + { + puts ("fstat64 failed"); + return 1; + } + + close (fd); + + if (linkat (dir_fd, "some-file", dir_fd, "another-file", 0) != 0) + { + puts ("symlinkat failed"); + return 1; + } + + struct stat64 st2; + if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0) + { + puts ("fstatat64 failed"); + return 1; + } + if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) + { + puts ("file changed after symlinkat"); + return 1; + } + + if (fstatat64 (dir_fd, "another-file", &st2, AT_SYMLINK_NOFOLLOW) != 0) + { + puts ("2nd fstatat64 failed"); + return 1; + } + if (S_ISLNK (st2.st_mode)) + { + puts ("2nd fstatat64 shows file is a symlink"); + return 1; + } + if (st1.st_dev != st2.st_dev + || st1.st_ino != st2.st_ino + || st1.st_size != st2.st_size) + { + puts ("stat results for linked file do not match"); + return 1; + } + + if (fstatat64 (dir_fd, "another-file", &st2, 0) != 0) + { + puts ("3rd fstatat64 failed"); + return 1; + } + if (st1.st_dev != st2.st_dev + || st1.st_ino != st2.st_ino + || st1.st_size != st2.st_size) + { + puts ("stat results do not match"); + return 1; + } + + if (unlinkat (dir_fd, "another-file", 0) != 0) + { + puts ("unlinkat failed"); + return 1; + } + if (unlinkat (dir_fd, "some-file", 0) != 0) + { + puts ("2nd unlinkat failed"); + return 1; + } + + close (dir_fd); + + return 0; +} diff --git a/io/tst-mkdirat.c b/io/tst-mkdirat.c new file mode 100644 index 0000000000..3efa4622ef --- /dev/null +++ b/io/tst-mkdirat.c @@ -0,0 +1,162 @@ +#include <dirent.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + +static int do_test (void); +#define TEST_FUNCTION do_test () + +#include "../test-skeleton.c" + +static int dir_fd; + +static void +prepare (void) +{ + size_t test_dir_len = strlen (test_dir); + static const char dir_name[] = "/tst-mkdirat.XXXXXX"; + + size_t dirbuflen = test_dir_len + sizeof (dir_name); + char *dirbuf = malloc (dirbuflen); + if (dirbuf == NULL) + { + puts ("out of memory"); + exit (1); + } + + snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name); + if (mkdtemp (dirbuf) == NULL) + { + puts ("cannot create temporary directory"); + exit (1); + } + + add_temp_file (dirbuf); + + dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY); + if (dir_fd == -1) + { + puts ("cannot open directory"); + exit (1); + } +} + + +static int +do_test (void) +{ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + DIR *dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + /* Create a new directory. */ + int e = mkdirat (dir_fd, "some-dir", 0777); + if (e == -1) + { + if (errno == ENOSYS) + { + puts ("*at functions not supported"); + return 0; + } + + puts ("directory creation failed"); + return 1; + } + + struct stat64 st1; + if (fstatat64 (dir_fd, "some-dir", &st1, 0) != 0) + { + puts ("fstat64 failed"); + return 1; + } + if (!S_ISDIR (st1.st_mode)) + { + puts ("mkdirat did not create a directory"); + return 1; + } + + dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("2nd fdopendir failed"); + return 1; + } + bool has_some_dir = false; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, "some-dir") == 0) + { + has_some_dir = true; +#ifdef _DIRENT_HAVE_D_TYPE + if (d->d_type != DT_UNKNOWN && d->d_type != DT_DIR) + { + puts ("d_type for some-dir wrong"); + return 1; + } +#endif + } + else if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + if (!has_some_dir) + { + puts ("some-dir not in directory list"); + return 1; + } + + if (unlinkat (dir_fd, "some-dir", AT_REMOVEDIR) != 0) + { + puts ("unlinkat failed"); + return 1; + } + + close (dir_fd); + + return 0; +} diff --git a/io/tst-mkfifoat.c b/io/tst-mkfifoat.c new file mode 100644 index 0000000000..2bf29f63af --- /dev/null +++ b/io/tst-mkfifoat.c @@ -0,0 +1,162 @@ +#include <dirent.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + +static int do_test (void); +#define TEST_FUNCTION do_test () + +#include "../test-skeleton.c" + +static int dir_fd; + +static void +prepare (void) +{ + size_t test_dir_len = strlen (test_dir); + static const char dir_name[] = "/tst-mkfifoat.XXXXXX"; + + size_t dirbuflen = test_dir_len + sizeof (dir_name); + char *dirbuf = malloc (dirbuflen); + if (dirbuf == NULL) + { + puts ("out of memory"); + exit (1); + } + + snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name); + if (mkdtemp (dirbuf) == NULL) + { + puts ("cannot create temporary directory"); + exit (1); + } + + add_temp_file (dirbuf); + + dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY); + if (dir_fd == -1) + { + puts ("cannot open directory"); + exit (1); + } +} + + +static int +do_test (void) +{ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + DIR *dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + /* Create a new directory. */ + int e = mkfifoat (dir_fd, "some-fifo", 0777); + if (e == -1) + { + if (errno == ENOSYS) + { + puts ("*at functions not supported"); + return 0; + } + + puts ("fifo creation failed"); + return 1; + } + + struct stat64 st1; + if (fstatat64 (dir_fd, "some-fifo", &st1, 0) != 0) + { + puts ("fstat64 failed"); + return 1; + } + if (!S_ISFIFO (st1.st_mode)) + { + puts ("mkfifoat did not create FIFO"); + return 1; + } + + dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("2nd fdopendir failed"); + return 1; + } + bool has_some_fifo = false; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, "some-fifo") == 0) + { + has_some_fifo = true; +#ifdef _DIRENT_HAVE_D_TYPE + if (d->d_type != DT_UNKNOWN && d->d_type != DT_FIFO) + { + puts ("d_type for some-fifo wrong"); + return 1; + } +#endif + } + else if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + if (!has_some_fifo) + { + puts ("some-fifo not in directory list"); + return 1; + } + + if (unlinkat (dir_fd, "some-fifo", 0) != 0) + { + puts ("unlinkat failed"); + return 1; + } + + close (dir_fd); + + return 0; +} diff --git a/io/tst-mknodat.c b/io/tst-mknodat.c new file mode 100644 index 0000000000..9158c0dfd4 --- /dev/null +++ b/io/tst-mknodat.c @@ -0,0 +1,162 @@ +#include <dirent.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + +static int do_test (void); +#define TEST_FUNCTION do_test () + +#include "../test-skeleton.c" + +static int dir_fd; + +static void +prepare (void) +{ + size_t test_dir_len = strlen (test_dir); + static const char dir_name[] = "/tst-mknodat.XXXXXX"; + + size_t dirbuflen = test_dir_len + sizeof (dir_name); + char *dirbuf = malloc (dirbuflen); + if (dirbuf == NULL) + { + puts ("out of memory"); + exit (1); + } + + snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name); + if (mkdtemp (dirbuf) == NULL) + { + puts ("cannot create temporary directory"); + exit (1); + } + + add_temp_file (dirbuf); + + dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY); + if (dir_fd == -1) + { + puts ("cannot open directory"); + exit (1); + } +} + + +static int +do_test (void) +{ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + DIR *dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + /* Create a new directory. */ + int e = mknodat (dir_fd, "some-sock", 0777 | S_IFSOCK, 0); + if (e == -1) + { + if (errno == ENOSYS) + { + puts ("*at functions not supported"); + return 0; + } + + puts ("socket creation failed"); + return 1; + } + + struct stat64 st1; + if (fstatat64 (dir_fd, "some-sock", &st1, 0) != 0) + { + puts ("fstat64 failed"); + return 1; + } + if (!S_ISSOCK (st1.st_mode)) + { + puts ("mknodat did not create a Unix domain socket"); + return 1; + } + + dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("2nd fdopendir failed"); + return 1; + } + bool has_some_sock = false; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, "some-sock") == 0) + { + has_some_sock = true; +#ifdef _DIRENT_HAVE_D_TYPE + if (d->d_type != DT_UNKNOWN && d->d_type != DT_SOCK) + { + puts ("d_type for some-sock wrong"); + return 1; + } +#endif + } + else if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + if (!has_some_sock) + { + puts ("some-sock not in directory list"); + return 1; + } + + if (unlinkat (dir_fd, "some-sock", 0) != 0) + { + puts ("unlinkat failed"); + return 1; + } + + close (dir_fd); + + return 0; +} diff --git a/io/tst-openat.c b/io/tst-openat.c new file mode 100644 index 0000000000..0ceb745880 --- /dev/null +++ b/io/tst-openat.c @@ -0,0 +1,209 @@ +#include <dirent.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + +static int do_test (void); +#define TEST_FUNCTION do_test () + +#include "../test-skeleton.c" + +static int dir_fd; + +static void +prepare (void) +{ + size_t test_dir_len = strlen (test_dir); + static const char dir_name[] = "/tst-openat.XXXXXX"; + + size_t dirbuflen = test_dir_len + sizeof (dir_name); + char *dirbuf = malloc (dirbuflen); + if (dirbuf == NULL) + { + puts ("out of memory"); + exit (1); + } + + snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name); + if (mkdtemp (dirbuf) == NULL) + { + puts ("cannot create temporary directory"); + exit (1); + } + + add_temp_file (dirbuf); + + dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY); + if (dir_fd == -1) + { + puts ("cannot open directory"); + exit (1); + } +} + + +static int +do_test (void) +{ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + DIR *dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + /* Try to create a file. */ + int fd = openat (dir_fd, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666); + if (fd == -1) + { + if (errno == ENOSYS) + { + puts ("*at functions not supported"); + return 0; + } + + puts ("file creation failed"); + return 1; + } + write (fd, "hello", 5); + + /* Before closing the file, try using this file descriptor to open + another file. This must fail. */ + int fd2 = openat (fd, "should-not-work", O_CREAT|O_RDWR, 0666); + if (fd2 != -1) + { + puts ("openat using descriptor for normal file worked"); + return 1; + } + if (errno != ENOTDIR) + { + puts ("error for openat using descriptor for normal file not ENOTDIR "); + return 1; + } + + close (fd); + puts ("file created"); + + /* fdopendir takes over the descriptor, make a copy. */ + dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("2nd lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + bool seen_file = false; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + if (strcmp (d->d_name, "some-file") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + + seen_file = true; + } + closedir (dir); + + if (!seen_file) + { + puts ("file not created in correct directory"); + return 1; + } + + int cwdfd = open (".", O_RDONLY | O_DIRECTORY); + if (cwdfd == -1) + { + puts ("cannot get descriptor for cwd"); + return 1; + } + + if (fchdir (dir_fd) != 0) + { + puts ("1st fchdir failed"); + return 1; + } + + if (unlink ("some-file") != 0) + { + puts ("unlink failed"); + return 1; + } + + if (fchdir (cwdfd) != 0) + { + puts ("2nd fchdir failed"); + return 1; + } + + close (dir_fd); + close (cwdfd); + + /* With the file descriptor closed the next call must fail. */ + fd = openat (dir_fd, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666); + if (fd != -1) + { + puts ("openat using closed descriptor succeeded"); + return 1; + } + if (errno != EBADF) + { + puts ("openat using closed descriptor did not set EBADF"); + return 1; + } + + fd = openat (-1, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666); + if (fd != -1) + { + puts ("openat using -1 descriptor succeeded"); + return 1; + } + if (errno != EBADF) + { + puts ("openat using -1 descriptor did not set EBADF"); + return 1; + } + + return 0; +} diff --git a/io/tst-readlinkat.c b/io/tst-readlinkat.c new file mode 100644 index 0000000000..891b6e6817 --- /dev/null +++ b/io/tst-readlinkat.c @@ -0,0 +1,136 @@ +#include <dirent.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + +static int do_test (void); +#define TEST_FUNCTION do_test () + +#include "../test-skeleton.c" + +static int dir_fd; + +static void +prepare (void) +{ + size_t test_dir_len = strlen (test_dir); + static const char dir_name[] = "/tst-symlinkat.XXXXXX"; + + size_t dirbuflen = test_dir_len + sizeof (dir_name); + char *dirbuf = malloc (dirbuflen); + if (dirbuf == NULL) + { + puts ("out of memory"); + exit (1); + } + + snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name); + if (mkdtemp (dirbuf) == NULL) + { + puts ("cannot create temporary directory"); + exit (1); + } + + add_temp_file (dirbuf); + + dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY); + if (dir_fd == -1) + { + puts ("cannot open directory"); + exit (1); + } +} + + +static int +do_test (void) +{ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + DIR *dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + static const char symlinkcontent[] = "some-file"; + if (symlinkat (symlinkcontent, dir_fd, "another-file") != 0) + { + puts ("symlinkat failed"); + return 1; + } + + struct stat64 st2; + if (fstatat64 (dir_fd, "another-file", &st2, AT_SYMLINK_NOFOLLOW) != 0) + { + puts ("fstatat64 failed"); + return 1; + } + if (!S_ISLNK (st2.st_mode)) + { + puts ("2nd fstatat64 does not show file is a symlink"); + return 1; + } + + if (fstatat64 (dir_fd, symlinkcontent, &st2, AT_SYMLINK_NOFOLLOW) == 0) + { + puts ("2nd fstatat64 succeeded"); + return 1; + } + + char buf[100]; + int n = readlinkat (dir_fd, "another-file", buf, sizeof (buf)); + if (n == -1) + { + puts ("readlinkat failed"); + return 1; + } + if (n != sizeof (symlinkcontent) - 1) + { + printf ("readlinkat returned %d, expected %zu\n", + n, sizeof (symlinkcontent) - 1); + return 1; + } + if (strncmp (buf, symlinkcontent, n) != 0) + { + puts ("readlinkat retrieved wrong link content"); + return 1; + } + + if (unlinkat (dir_fd, "another-file", 0) != 0) + { + puts ("unlinkat failed"); + return 1; + } + + close (dir_fd); + + return 0; +} diff --git a/io/tst-renameat.c b/io/tst-renameat.c new file mode 100644 index 0000000000..a7c0ec16c4 --- /dev/null +++ b/io/tst-renameat.c @@ -0,0 +1,225 @@ +#include <dirent.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + +static int do_test (void); +#define TEST_FUNCTION do_test () + +#include "../test-skeleton.c" + +static int dir_fd; + +static void +prepare (void) +{ + size_t test_dir_len = strlen (test_dir); + static const char dir_name[] = "/tst-renameat.XXXXXX"; + + size_t dirbuflen = test_dir_len + sizeof (dir_name); + char *dirbuf = malloc (dirbuflen); + if (dirbuf == NULL) + { + puts ("out of memory"); + exit (1); + } + + snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name); + if (mkdtemp (dirbuf) == NULL) + { + puts ("cannot create temporary directory"); + exit (1); + } + + add_temp_file (dirbuf); + + dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY); + if (dir_fd == -1) + { + puts ("cannot open directory"); + exit (1); + } +} + + +static int +do_test (void) +{ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + DIR *dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + /* Try to create a file. */ + int fd = openat (dir_fd, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666); + if (fd == -1) + { + if (errno == ENOSYS) + { + puts ("*at functions not supported"); + return 0; + } + + puts ("file creation failed"); + return 1; + } + write (fd, "hello", 5); + puts ("file created"); + + struct stat64 st1; + if (fstat64 (fd, &st1) != 0) + { + puts ("fstat64 failed"); + return 1; + } + + /* Using a descriptor for a normal file must fail. */ + if (renameat (fd, "some-file", dir_fd, "another-file") == 0) + { + puts ("renameat with normal file descriptor succeeded"); + return 1; + } + if (errno != ENOTDIR) + { + puts ("error for renameat with normal file descriptor not ENOTDIR"); + return 1; + } + + if (renameat (dir_fd, "some-file", fd, "another-file") == 0) + { + puts ("2nd renameat with normal file descriptor succeeded"); + return 1; + } + if (errno != ENOTDIR) + { + puts ("error for 2nd renameat with normal file descriptor not ENOTDIR"); + return 1; + } + + close (fd); + + if (renameat (dir_fd, "some-file", dir_fd, "another-file") != 0) + { + puts ("renameat failed"); + return 1; + } + + struct stat64 st2; + if (fstatat64 (dir_fd, "some-file", &st2, 0) == 0) + { + puts ("fstatat64 succeeded"); + return 1; + } + if (errno != ENOENT) + { + puts ("fstatat64 did not fail with ENOENT"); + return 1; + } + + if (fstatat64 (dir_fd, "another-file", &st2, 0) != 0) + { + puts ("2nd fstatat64 failed"); + return 1; + } + + if (st1.st_dev != st2.st_dev + || st1.st_ino != st2.st_ino + || st1.st_size != st2.st_size) + { + puts ("stat results do not match"); + return 1; + } + + /* Create a file descriptor which is closed again right away. */ + int dir_fd2 = dup (dir_fd); + if (dir_fd2 == -1) + { + puts ("dup failed"); + return 1; + } + close (dir_fd2); + + if (renameat (dir_fd2, "another-file", dir_fd, "some-file") == 0) + { + puts ("renameat with closed file descriptor succeeded"); + return 1; + } + if (errno != EBADF) + { + puts ("error for renameat with closed file descriptor not EBADF"); + return 1; + } + + if (renameat (dir_fd, "another-file", dir_fd2, "some-file") == 0) + { + puts ("2nd renameat with closed file descriptor succeeded"); + return 1; + } + if (errno != EBADF) + { + puts ("error for 2nd renameat with closed file descriptor not EBADF"); + return 1; + } + + if (unlinkat (dir_fd, "another-file", 0) != 0) + { + puts ("unlinkat failed"); + return 1; + } + + if (renameat (-1, "another-file", dir_fd, "some-file") == 0) + { + puts ("renameat with invalid file descriptor succeeded"); + return 1; + } + if (errno != EBADF) + { + puts ("error for renameat with invalid file descriptor not EBADF"); + return 1; + } + + if (renameat (dir_fd, "another-file", -1, "some-file") == 0) + { + puts ("2nd renameat with invalid file descriptor succeeded"); + return 1; + } + if (errno != EBADF) + { + puts ("error for 2nd renameat with invalid file descriptor not EBADF"); + return 1; + } + + close (dir_fd); + + return 0; +} diff --git a/io/tst-symlinkat.c b/io/tst-symlinkat.c new file mode 100644 index 0000000000..1e98588fc8 --- /dev/null +++ b/io/tst-symlinkat.c @@ -0,0 +1,164 @@ +#include <dirent.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + +static int do_test (void); +#define TEST_FUNCTION do_test () + +#include "../test-skeleton.c" + +static int dir_fd; + +static void +prepare (void) +{ + size_t test_dir_len = strlen (test_dir); + static const char dir_name[] = "/tst-symlinkat.XXXXXX"; + + size_t dirbuflen = test_dir_len + sizeof (dir_name); + char *dirbuf = malloc (dirbuflen); + if (dirbuf == NULL) + { + puts ("out of memory"); + exit (1); + } + + snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name); + if (mkdtemp (dirbuf) == NULL) + { + puts ("cannot create temporary directory"); + exit (1); + } + + add_temp_file (dirbuf); + + dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY); + if (dir_fd == -1) + { + puts ("cannot open directory"); + exit (1); + } +} + + +static int +do_test (void) +{ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + DIR *dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + /* Try to create a file. */ + int fd = openat (dir_fd, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666); + if (fd == -1) + { + if (errno == ENOSYS) + { + puts ("*at functions not supported"); + return 0; + } + + puts ("file creation failed"); + return 1; + } + write (fd, "hello", 5); + puts ("file created"); + + struct stat64 st1; + if (fstat64 (fd, &st1) != 0) + { + puts ("fstat64 failed"); + return 1; + } + + close (fd); + + if (symlinkat ("some-file", dir_fd, "another-file") != 0) + { + puts ("symlinkat failed"); + return 1; + } + + struct stat64 st2; + if (fstatat64 (dir_fd, "some-file", &st2, 0) != 0) + { + puts ("fstatat64 failed"); + return 1; + } + if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) + { + puts ("file changed after symlinkat"); + return 1; + } + + if (fstatat64 (dir_fd, "another-file", &st2, AT_SYMLINK_NOFOLLOW) != 0) + { + puts ("2nd fstatat64 failed"); + return 1; + } + if (!S_ISLNK (st2.st_mode)) + { + puts ("2nd fstatat64 does not show file is a symlink"); + return 1; + } + + if (fstatat64 (dir_fd, "another-file", &st2, 0) != 0) + { + puts ("3rd fstatat64 failed"); + return 1; + } + if (st1.st_dev != st2.st_dev + || st1.st_ino != st2.st_ino + || st1.st_size != st2.st_size) + { + puts ("stat results do not match"); + return 1; + } + + if (unlinkat (dir_fd, "another-file", 0) != 0) + { + puts ("unlinkat failed"); + return 1; + } + if (unlinkat (dir_fd, "some-file", 0) != 0) + { + puts ("2nd unlinkat failed"); + return 1; + } + + close (dir_fd); + + return 0; +} diff --git a/io/tst-ttyname_r.c b/io/tst-ttyname_r.c new file mode 100644 index 0000000000..8e2f30c972 --- /dev/null +++ b/io/tst-ttyname_r.c @@ -0,0 +1,42 @@ +#include <errno.h> +#include <error.h> +#include <fcntl.h> +#include <stdio.h> +#include <unistd.h> + +static void do_prepare (void); +#define PREPARE(argc, argv) do_prepare () +static int do_test (void); +#define TEST_FUNCTION do_test () +#include <test-skeleton.c> + +static int temp_fd; + +static void +do_prepare (void) +{ + char *temp_file; + temp_fd = create_temp_file ("tst-ttyname_r.", &temp_file); + if (temp_fd == -1) + error (1, errno, "cannot create temporary file"); +} + +static int +do_test (void) +{ + int ret = 0; + char buf[sysconf (_SC_TTY_NAME_MAX) + 1]; + int res = ttyname_r (-1, buf, sizeof (buf)); + if (res != EBADF) + { + printf ("1st ttyname_r returned with res %d\n", res); + ret++; + } + res = ttyname_r (temp_fd, buf, sizeof (buf)); + if (res != ENOTTY) + { + printf ("2nd ttyname_r returned with res %d\n", res); + ret++; + } + return ret; +} diff --git a/io/tst-unlinkat.c b/io/tst-unlinkat.c new file mode 100644 index 0000000000..c25443c27f --- /dev/null +++ b/io/tst-unlinkat.c @@ -0,0 +1,178 @@ +#include <dirent.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + + +static void prepare (void); +#define PREPARE(argc, argv) prepare () + +static int do_test (void); +#define TEST_FUNCTION do_test () + +#include "../test-skeleton.c" + +static int dir_fd; + +static void +prepare (void) +{ + size_t test_dir_len = strlen (test_dir); + static const char dir_name[] = "/tst-unlinkat.XXXXXX"; + + size_t dirbuflen = test_dir_len + sizeof (dir_name); + char *dirbuf = malloc (dirbuflen); + if (dirbuf == NULL) + { + puts ("out of memory"); + exit (1); + } + + snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name); + if (mkdtemp (dirbuf) == NULL) + { + puts ("cannot create temporary directory"); + exit (1); + } + + add_temp_file (dirbuf); + + dir_fd = open (dirbuf, O_RDONLY | O_DIRECTORY); + if (dir_fd == -1) + { + puts ("cannot open directory"); + exit (1); + } +} + + +static int +do_test (void) +{ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("1st lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + DIR *dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + struct dirent64 *d; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + closedir (dir); + + /* Try to create a file. */ + int fd = openat (dir_fd, "some-file", O_CREAT|O_RDWR|O_EXCL, 0666); + if (fd == -1) + { + if (errno == ENOSYS) + { + puts ("*at functions not supported"); + return 0; + } + + puts ("file creation failed"); + return 1; + } + write (fd, "hello", 5); + close (fd); + puts ("file created"); + + /* fdopendir takes over the descriptor, make a copy. */ + dupfd = dup (dir_fd); + if (dupfd == -1) + { + puts ("2nd dup failed"); + return 1; + } + if (lseek (dupfd, 0, SEEK_SET) != 0) + { + puts ("2nd lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + dir = fdopendir (dupfd); + if (dir == NULL) + { + puts ("2nd fdopendir failed"); + return 1; + } + bool seen_file = false; + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + if (strcmp (d->d_name, "some-file") != 0) + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + + seen_file = true; + } + closedir (dir); + + if (!seen_file) + { + puts ("file not created in correct directory"); + return 1; + } + + /* Remove the file now. */ + if (unlinkat (dir_fd, "some-file", 0) != 0) + { + puts ("unlinkat failed"); + return 1; + } + + /* We won't need dir_fd anymore after this, so use it. */ + if (lseek (dir_fd, 0, SEEK_SET) != 0) + { + puts ("3rd lseek failed"); + return 1; + } + + /* The directory should be empty safe the . and .. files. */ + dir = fdopendir (dir_fd); + if (dir == NULL) + { + puts ("3rd fdopendir failed"); + return 1; + } + while ((d = readdir64 (dir)) != NULL) + if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0) + { + if (strcmp (d->d_name, "some-file") == 0) + { + puts ("some-file not removed"); + return 1; + } + else + { + printf ("temp directory contains file \"%s\"\n", d->d_name); + return 1; + } + } + closedir (dir); + + return 0; +} diff --git a/io/ttyname.c b/io/ttyname.c new file mode 100644 index 0000000000..088ba918a8 --- /dev/null +++ b/io/ttyname.c @@ -0,0 +1,38 @@ +/* Copyright (C) 1991, 1995, 1996, 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. */ + +#include <errno.h> +#include <stddef.h> +#include <unistd.h> + + +char *__ttyname = NULL; + +/* Return the pathname of the terminal FD is open on, or NULL on errors. + The returned storage is good only until the next call to this function. */ +char * +ttyname (fd) + int fd; +{ + __set_errno (ENOSYS); + return NULL; +} + + +stub_warning (ttyname) +#include <stub-tag.h> diff --git a/io/ttyname_r.c b/io/ttyname_r.c new file mode 100644 index 0000000000..14c1209096 --- /dev/null +++ b/io/ttyname_r.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 1998 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 <unistd.h> + + +/* Store at most BUFLEN characters the pathname of the terminal FD is + open on in BUF. Return 0 on success, otherwise an error number. */ +int +__ttyname_r (fd, buf, buflen) + int fd; + char *buf; + size_t buflen; +{ + __set_errno (ENOSYS); + return ENOSYS; +} +weak_alias (__ttyname_r, ttyname_r) + +stub_warning (ttyname_r) +#include <stub-tag.h> diff --git a/io/umask.c b/io/umask.c new file mode 100644 index 0000000000..588d57e1ce --- /dev/null +++ b/io/umask.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991, 1995, 1996, 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. */ + +#include <sys/stat.h> +#include <errno.h> +#include <sys/types.h> + +/* Set the file creation mask to MASK, returning the old mask. */ +mode_t +__umask (mask) + mode_t mask; +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (umask) + +weak_alias (__umask, umask) +#include <stub-tag.h> diff --git a/io/unlink.c b/io/unlink.c new file mode 100644 index 0000000000..1ec6d87ae1 --- /dev/null +++ b/io/unlink.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1991, 1995, 1996, 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. */ + +#include <errno.h> +#include <stddef.h> +#include <unistd.h> + + +/* Remove the link named NAME. */ +int +__unlink (name) + const char *name; +{ + if (name == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (unlink) + +weak_alias (__unlink, unlink) +#include <stub-tag.h> diff --git a/io/unlinkat.c b/io/unlinkat.c new file mode 100644 index 0000000000..f9a08b9903 --- /dev/null +++ b/io/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> diff --git a/io/utime.c b/io/utime.c new file mode 100644 index 0000000000..3a3bcc38cc --- /dev/null +++ b/io/utime.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1991,95,96,97,2002 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 <stddef.h> +#include <utime.h> + + +/* Set the access and modification times of FILE to those given in TIMES. + If TIMES is NULL, set them to the current time. */ +int +utime (file, times) + const char *file; + const struct utimbuf *times; +{ + if (file == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (utime) + +stub_warning (utime) +#include <stub-tag.h> diff --git a/io/write.c b/io/write.c new file mode 100644 index 0000000000..928d43ced2 --- /dev/null +++ b/io/write.c @@ -0,0 +1,50 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 2002 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 <sysdep.h> +#include <errno.h> +#include <unistd.h> +#include <stddef.h> + +/* Write NBYTES of BUF to FD. Return the number written, or -1. */ +ssize_t +__libc_write (int fd, const void *buf, size_t nbytes) +{ + if (nbytes == 0) + return 0; + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } + if (buf == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (__libc_write) +stub_warning (write) + +weak_alias (__libc_write, __write) +libc_hidden_weak (__write) +weak_alias (__libc_write, write) +#include <stub-tag.h> diff --git a/io/xmknod.c b/io/xmknod.c new file mode 100644 index 0000000000..c2daa46e07 --- /dev/null +++ b/io/xmknod.c @@ -0,0 +1,48 @@ +/* Copyright (C) 1991,1993,1995-1997,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 + 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 <sys/types.h> +#include <sys/stat.h> + +/* Create a device file named PATH, with permission and special bits MODE + and device number DEV (which can be constructed from major and minor + device numbers with the `makedev' macro above). */ +int +__xmknod (int vers, const char *path, mode_t mode, dev_t *dev) +{ + if (vers != _MKNOD_VER) + { + __set_errno (EINVAL); + return -1; + } + + if (path == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (__xmknod) + +weak_alias (__xmknod, _xmknod) +libc_hidden_def (__xmknod) +#include <stub-tag.h> diff --git a/io/xmknodat.c b/io/xmknodat.c new file mode 100644 index 0000000000..48dc1b2630 --- /dev/null +++ b/io/xmknodat.c @@ -0,0 +1,64 @@ +/* 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/types.h> +#include <sys/stat.h> + +/* Create a device file named PATH relative to FD, with permission and + special bits MODE and device number DEV (which can be constructed + from major and minor device numbers with the `makedev' macro + above). */ +int +__xmknodat (int vers, int fd, const char *path, mode_t mode, dev_t *dev) +{ + if (vers != _MKNOD_VER) + { + __set_errno (EINVAL); + return -1; + } + + if (path == NULL) + { + __set_errno (EINVAL); + return -1; + } + + if (fd != AT_FDCWD && path[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; + } + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (__xmknodat) + +libc_hidden_def (__xmknodat) +#include <stub-tag.h> diff --git a/io/xstat.c b/io/xstat.c new file mode 100644 index 0000000000..e7328cc10e --- /dev/null +++ b/io/xstat.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 2002 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 <sys/stat.h> +#include <stddef.h> + +/* Get file information about FILE in BUF. */ +int +__xstat (int vers, const char *file, struct stat *buf) +{ + if (vers != _STAT_VER || file == NULL || buf == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +hidden_def (__xstat) +stub_warning (stat) +weak_alias (__xstat, _xstat) +#include <stub-tag.h> diff --git a/io/xstat64.c b/io/xstat64.c new file mode 100644 index 0000000000..2fb94cf331 --- /dev/null +++ b/io/xstat64.c @@ -0,0 +1,38 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 2002 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 <sys/stat.h> +#include <stddef.h> + +/* Get file information about FILE in BUF. */ +int +__xstat64 (int vers, const char *file, struct stat64 *buf) +{ + if (vers != _STAT_VER || file == NULL || buf == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +hidden_def (__xstat64) +stub_warning (stat64) +#include <stub-tag.h> |