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 /dirent | |
parent | 7d58530341304d403a6626d7f7a1913165fe2f32 (diff) | |
download | glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.gz glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.bz2 |
2.5-18.1
Diffstat (limited to 'dirent')
-rw-r--r-- | dirent/Makefile | 7 | ||||
-rw-r--r-- | dirent/Versions | 3 | ||||
-rw-r--r-- | dirent/alphasort64.c | 27 | ||||
-rw-r--r-- | dirent/closedir.c | 35 | ||||
-rw-r--r-- | dirent/dirent.h | 10 | ||||
-rw-r--r-- | dirent/dirfd.c | 33 | ||||
-rw-r--r-- | dirent/fdopendir.c | 35 | ||||
-rw-r--r-- | dirent/getdents.c | 37 | ||||
-rw-r--r-- | dirent/getdents64.c | 36 | ||||
-rw-r--r-- | dirent/opendir.c | 34 | ||||
-rw-r--r-- | dirent/readdir.c | 33 | ||||
-rw-r--r-- | dirent/readdir64.c | 32 | ||||
-rw-r--r-- | dirent/readdir64_r.c | 33 | ||||
-rw-r--r-- | dirent/readdir_r.c | 35 | ||||
-rw-r--r-- | dirent/rewinddir.c | 35 | ||||
-rw-r--r-- | dirent/scandir64.c | 30 | ||||
-rw-r--r-- | dirent/seekdir.c | 41 | ||||
-rw-r--r-- | dirent/telldir.c | 41 | ||||
-rw-r--r-- | dirent/tst-fdopendir.c | 124 | ||||
-rw-r--r-- | dirent/tst-fdopendir2.c | 41 | ||||
-rw-r--r-- | dirent/tst-seekdir.c | 28 | ||||
-rw-r--r-- | dirent/versionsort64.c | 27 |
22 files changed, 753 insertions, 4 deletions
diff --git a/dirent/Makefile b/dirent/Makefile index df150bc..ef639f2 100644 --- a/dirent/Makefile +++ b/dirent/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2000, 2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 1991-2000,2002,2003,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 @@ -25,10 +25,11 @@ headers := dirent.h bits/dirent.h routines := opendir closedir readdir readdir_r rewinddir \ seekdir telldir scandir alphasort versionsort \ getdents getdents64 dirfd readdir64 readdir64_r scandir64 \ - alphasort64 versionsort64 + alphasort64 versionsort64 fdopendir distribute := dirstream.h -tests := list tst-seekdir opendir-tst1 bug-readdir1 +tests := list tst-seekdir opendir-tst1 bug-readdir1 tst-fdopendir \ + tst-fdopendir2 CFLAGS-scandir.c = $(uses-callbacks) CFLAGS-scandir64.c = $(uses-callbacks) diff --git a/dirent/Versions b/dirent/Versions index 9d96cae..41c1584 100644 --- a/dirent/Versions +++ b/dirent/Versions @@ -41,4 +41,7 @@ libc { # g* getdirentries64; } + GLIBC_2.4 { + fdopendir; + } } diff --git a/dirent/alphasort64.c b/dirent/alphasort64.c new file mode 100644 index 0000000..fe84aec --- /dev/null +++ b/dirent/alphasort64.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1992, 1997, 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 <dirent.h> +#include <string.h> + +int +alphasort64 (const void *a, const void *b) +{ + return strcoll ((*(const struct dirent64 **) a)->d_name, + (*(const struct dirent64 **) b)->d_name); +} diff --git a/dirent/closedir.c b/dirent/closedir.c new file mode 100644 index 0000000..4410f02 --- /dev/null +++ b/dirent/closedir.c @@ -0,0 +1,35 @@ +/* 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 <dirent.h> + + +/* Close the directory stream DIRP. + Return 0 if successful, -1 if not. */ +int +__closedir (DIR *dirp) +{ + __set_errno (ENOSYS); + return -1; +} +weak_alias (__closedir, closedir) + +stub_warning (closedir) +#include <stub-tag.h> diff --git a/dirent/dirent.h b/dirent/dirent.h index a5e8a00..ed4147d 100644 --- a/dirent/dirent.h +++ b/dirent/dirent.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2000, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1991-2000, 2003, 2004, 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 @@ -134,6 +134,14 @@ typedef struct __dirstream DIR; marked with __THROW. */ extern DIR *opendir (__const char *__name) __nonnull ((1)); +#ifdef __USE_GNU +/* Same as opendir, but open the stream on the file descriptor FD. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern DIR *fdopendir (int __fd); +#endif + /* Close the directory stream DIRP. Return 0 if successful, -1 if not. diff --git a/dirent/dirfd.c b/dirent/dirfd.c new file mode 100644 index 0000000..06c0cde --- /dev/null +++ b/dirent/dirfd.c @@ -0,0 +1,33 @@ +/* Return the file descriptor used by a DIR stream. Stub version. + Copyright (C) 1995, 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 <dirent.h> +#include <dirstream.h> +#include <errno.h> + +int +dirfd (dirp) + DIR *dirp; +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (dirfd) +#include <stub-tag.h> diff --git a/dirent/fdopendir.c b/dirent/fdopendir.c new file mode 100644 index 0000000..275cfd5 --- /dev/null +++ b/dirent/fdopendir.c @@ -0,0 +1,35 @@ +/* Open a directory stream from a file descriptor. Stub version. + 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 <stddef.h> +#include <dirent.h> + + +/* Open a directory stream on FD. */ +DIR * +__fdopendir (int fd) +{ + __set_errno (ENOSYS); + return NULL; +} +weak_alias (__fdopendir, fdopendir) + +stub_warning (fdopendir) +#include <stub-tag.h> diff --git a/dirent/getdents.c b/dirent/getdents.c new file mode 100644 index 0000000..1b1b7c7 --- /dev/null +++ b/dirent/getdents.c @@ -0,0 +1,37 @@ +/* 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 <stddef.h> +#include <errno.h> +#include <sys/types.h> +#include <dirent.h> + +ssize_t +__getdirentries (fd, buf, nbytes, basep) + int fd; + char *buf; + size_t nbytes; + off_t *basep; +{ + __set_errno (ENOSYS); + return -1; +} +weak_alias (__getdirentries, getdirentries) + +stub_warning (getdirentries) +#include <stub-tag.h> diff --git a/dirent/getdents64.c b/dirent/getdents64.c new file mode 100644 index 0000000..cb30e76 --- /dev/null +++ b/dirent/getdents64.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1991,95,96,97,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 <stddef.h> +#include <errno.h> +#include <sys/types.h> +#include <dirent.h> + +ssize_t +getdirentries64 (fd, buf, nbytes, basep) + int fd; + char *buf; + size_t nbytes; + off64_t *basep; +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (getdirentries64) +#include <stub-tag.h> diff --git a/dirent/opendir.c b/dirent/opendir.c new file mode 100644 index 0000000..771013f --- /dev/null +++ b/dirent/opendir.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 <stddef.h> +#include <dirent.h> + + +/* Open a directory stream on NAME. */ +DIR * +__opendir (const char *name) +{ + __set_errno (ENOSYS); + return NULL; +} +weak_alias (__opendir, opendir) + +stub_warning (opendir) +#include <stub-tag.h> diff --git a/dirent/readdir.c b/dirent/readdir.c new file mode 100644 index 0000000..893b246 --- /dev/null +++ b/dirent/readdir.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 <dirent.h> + +/* Read a directory entry from DIRP. */ +struct dirent * +__readdir (DIR *dirp) +{ + __set_errno (ENOSYS); + return NULL; +} +weak_alias (__readdir, readdir) + +stub_warning (readdir) +#include <stub-tag.h> diff --git a/dirent/readdir64.c b/dirent/readdir64.c new file mode 100644 index 0000000..0c18bd9 --- /dev/null +++ b/dirent/readdir64.c @@ -0,0 +1,32 @@ +/* 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 <stddef.h> +#include <dirent.h> + +/* Read a directory entry from DIRP. */ +struct dirent64 * +__readdir64 (DIR *dirp) +{ + __set_errno (ENOSYS); + return NULL; +} +weak_alias (__readdir64, readdir64) +stub_warning (readdir64) +#include <stub-tag.h> diff --git a/dirent/readdir64_r.c b/dirent/readdir64_r.c new file mode 100644 index 0000000..cf9e952 --- /dev/null +++ b/dirent/readdir64_r.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 <dirent.h> + +/* Read a directory entry from DIRP, store result in ENTRY and return + pointer to result in *RESULT. */ +int +readdir64_r (DIR *dirp, struct dirent64 *entry, struct dirent64 **result) +{ + __set_errno (ENOSYS); + *result = NULL; + return -1; +} +stub_warning (readdir64_r) +#include <stub-tag.h> diff --git a/dirent/readdir_r.c b/dirent/readdir_r.c new file mode 100644 index 0000000..ad45dfa --- /dev/null +++ b/dirent/readdir_r.c @@ -0,0 +1,35 @@ +/* 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 <dirent.h> + +/* Read a directory entry from DIRP, store result in ENTRY and return + pointer to result in *RESULT. */ +int +__readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result) +{ + __set_errno (ENOSYS); + *result = NULL; + return ENOSYS; +} +weak_alias (__readdir_r, readdir_r) + +stub_warning (readdir_r) +#include <stub-tag.h> diff --git a/dirent/rewinddir.c b/dirent/rewinddir.c new file mode 100644 index 0000000..e78d316 --- /dev/null +++ b/dirent/rewinddir.c @@ -0,0 +1,35 @@ +/* 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 <dirent.h> + + +/* Rewind DIRP to the beginning of the directory. */ +void +rewinddir (dirp) + DIR *dirp; +{ + __set_errno (ENOSYS); + /* No way to indicate failure. */ +} + + +stub_warning (rewinddir) +#include <stub-tag.h> diff --git a/dirent/scandir64.c b/dirent/scandir64.c new file mode 100644 index 0000000..68608de --- /dev/null +++ b/dirent/scandir64.c @@ -0,0 +1,30 @@ +/* Copyright (C) 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 <dirent.h> + +#define SCANDIR scandir64 +#define READDIR __readdir64 +#define DIRENT_TYPE struct dirent64 + +int scandir64 (__const char *__restrict __dir, + struct dirent64 ***__restrict __namelist, + int (*__selector) (__const struct dirent64 *), + int (*__cmp) (__const void *, __const void *)); + +#include <dirent/scandir.c> diff --git a/dirent/seekdir.c b/dirent/seekdir.c new file mode 100644 index 0000000..c3828cd --- /dev/null +++ b/dirent/seekdir.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + 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 <errno.h> +#include <stddef.h> +#include <dirent.h> + +/* Seek to position POS in DIRP. */ +void +seekdir (dirp, pos) + DIR *dirp; + long int pos; +{ + if (dirp == NULL) + { + __set_errno (EINVAL); + return; + } + + __set_errno (ENOSYS); +} + + +stub_warning (seekdir) +#include <stub-tag.h> diff --git a/dirent/telldir.c b/dirent/telldir.c new file mode 100644 index 0000000..7b14452 --- /dev/null +++ b/dirent/telldir.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + 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 <stddef.h> +#include <dirent.h> + +/* Return the current position of DIRP. */ +long int +telldir (dirp) + DIR *dirp; +{ + if (dirp == NULL) + { + __set_errno (EINVAL); + return -1l; + } + + __set_errno (ENOSYS); + return -1l; +} + + +stub_warning (telldir) +#include <stub-tag.h> diff --git a/dirent/tst-fdopendir.c b/dirent/tst-fdopendir.c new file mode 100644 index 0000000..3cf315d --- /dev/null +++ b/dirent/tst-fdopendir.c @@ -0,0 +1,124 @@ +#include <stdio.h> +#include <fcntl.h> +#include <stdlib.h> +#include <unistd.h> +#include <dirent.h> +#include <stdbool.h> +#include <string.h> + + +static int +do_test (void) +{ + char fname[] = "/tmp/jXXXXXX"; + int fd = mkstemp (fname); + if (fd == -1) + { + puts ("mkstemp failed"); + return 1; + } + + write (fd, "hello", 5); + close (fd); + + struct stat64 st; + if (stat64 (fname, &st) == -1) + { + puts ("first stat failed"); + return 0; + } + + /* Make sure there is enough time between the creation and the access. */ + sleep (2); + + fd = open (fname, O_RDONLY | O_NOATIME); + if (fd == -1) + { + puts ("first open failed"); + return 1; + } + + char buf[5]; + read(fd, buf, sizeof (buf)); + close(fd); + + struct stat64 st2; + if (stat64 (fname, &st2) == -1) + { + puts ("second stat failed"); + return 0; + } + + bool no_noatime = false; +#ifdef _STATBUF_ST_NSEC + if (st.st_atim.tv_sec != st2.st_atim.tv_sec + || st.st_atim.tv_nsec != st2.st_atim.tv_nsec) +#else + if (st.st_atime != st2.st_atime) +#endif + { + puts ("file atime changed"); + no_noatime = true; + } + + unlink(fname); + + strcpy(fname, "/tmp/dXXXXXX"); + char *d = mkdtemp (fname); + if (d == NULL) + { + puts ("mkdtemp failed"); + return 1; + } + + if (stat64 (d, &st) == -1) + { + puts ("third stat failed"); + return 0; + } + sleep (2); + + fd = open64 (d, O_RDONLY|O_NDELAY|O_DIRECTORY|O_NOATIME); + if (fd == -1) + { + puts ("second open failed"); + return 1; + } + DIR *dir = fdopendir (fd); + if (dir == NULL) + { + puts ("fdopendir failed"); + return 1; + } + + struct dirent *de; + while ((de = readdir (dir)) != NULL) + ; + + closedir (dir); + + if (stat64 (d, &st2) == -1) + { + puts ("fourth stat failed"); + return 0; + } +#ifdef _STATBUF_ST_NSEC + if (!no_noatime + && (st.st_atim.tv_sec != st2.st_atim.tv_sec + || st.st_atim.tv_nsec != st2.st_atim.tv_nsec)) +#else + if (!no_noatime && st.st_atime != st2.st_atime) +#endif + { + puts ("directory atime changed"); + return 1; + } + + rmdir(fname); + + return 0; +} + +#define TIMEOUT 6 +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/dirent/tst-fdopendir2.c b/dirent/tst-fdopendir2.c new file mode 100644 index 0000000..3720809 --- /dev/null +++ b/dirent/tst-fdopendir2.c @@ -0,0 +1,41 @@ +#include <errno.h> +#include <dirent.h> +#include <stdio.h> +#include <unistd.h> + + +static int +do_test (void) +{ + char tmpl[] = "/tmp/tst-fdopendir2-XXXXXX"; + int fd = mkstemp (tmpl); + if (fd == -1) + { + puts ("cannot open temp file"); + return 1; + } + + errno = 0; + DIR *d = fdopendir (fd); + + int e = errno; + + close (fd); + unlink (tmpl); + + if (d != NULL) + { + puts ("fdopendir with normal file descriptor did not fail"); + return 1; + } + if (e != ENOTDIR) + { + printf ("fdopendir set errno to %d, not %d as expected\n", e, ENOTDIR); + return 1; + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/dirent/tst-seekdir.c b/dirent/tst-seekdir.c index b833c30..43808fe 100644 --- a/dirent/tst-seekdir.c +++ b/dirent/tst-seekdir.c @@ -11,8 +11,23 @@ main (int argc, char *argv[]) int i = 0; int result = 0; struct dirent *dp; + long int save0; + long int rewind; dirp = opendir ("."); + if (dirp == NULL) + { + printf ("opendir failed: %m\n"); + return 1; + } + + save0 = telldir (dirp); + if (save0 == -1) + { + printf ("telldir failed: %m\n"); + result = 1; + } + for (dp = readdir (dirp); dp != NULL; dp = readdir (dirp)) { /* save position 3 (after fourth entry) */ @@ -44,6 +59,19 @@ main (int argc, char *argv[]) for (dp = readdir (dirp); dp != NULL; dp = readdir (dirp)) printf ("%s\n", dp->d_name); + /* Check rewinddir */ + rewinddir (dirp); + rewind = telldir (dirp); + if (rewind == -1) + { + printf ("telldir failed: %m\n"); + result = 1; + } + else if (save0 != rewind) + { + printf ("rewinddir didn't reset directory stream\n"); + result = 1; + } closedir (dirp); return result; diff --git a/dirent/versionsort64.c b/dirent/versionsort64.c new file mode 100644 index 0000000..e471827 --- /dev/null +++ b/dirent/versionsort64.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1992, 1997, 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 <dirent.h> +#include <string.h> + +int +versionsort64 (const void *a, const void *b) +{ + return __strverscmp ((*(const struct dirent64 **) a)->d_name, + (*(const struct dirent64 **) b)->d_name); +} |