diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2020-04-11 17:07:11 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2020-10-16 14:19:23 -0300 |
commit | 905ae44c77a4b899100de99360823a586e095622 (patch) | |
tree | 71d31e80c6f6cc43d062de42be37388aa91e7632 /sysdeps/posix | |
parent | f1ed4d4c2cb24f8f0d4f54c89847adf2bb185f50 (diff) | |
download | glibc-905ae44c77a4b899100de99360823a586e095622.tar.gz glibc-905ae44c77a4b899100de99360823a586e095622.tar.xz glibc-905ae44c77a4b899100de99360823a586e095622.zip |
linux: Move posix dir implementations to Linux
This generic implementation already expects a getdents API which is Linux specific. It also allows simplify it by assuming _DIRENT_HAVE_D_RECLEN and _DIRENT_HAVE_D_OFF support. The readdir are also expanded on each required implementation, futher fixes and improvements will make parametrize the implementation more complex. Checked on x86_64-linux-gnu, i686-linux-gnu, and with a build for all affected ABIs.
Diffstat (limited to 'sysdeps/posix')
-rw-r--r-- | sysdeps/posix/closedir.c | 54 | ||||
-rw-r--r-- | sysdeps/posix/dirfd.c | 31 | ||||
-rw-r--r-- | sysdeps/posix/dirstream.h | 55 | ||||
-rw-r--r-- | sysdeps/posix/fdopendir.c | 52 | ||||
-rw-r--r-- | sysdeps/posix/opendir.c | 148 | ||||
-rw-r--r-- | sysdeps/posix/readdir.c | 127 | ||||
-rw-r--r-- | sysdeps/posix/readdir_r.c | 159 | ||||
-rw-r--r-- | sysdeps/posix/rewinddir.c | 41 | ||||
-rw-r--r-- | sysdeps/posix/seekdir.c | 35 | ||||
-rw-r--r-- | sysdeps/posix/telldir.c | 33 |
10 files changed, 0 insertions, 735 deletions
diff --git a/sysdeps/posix/closedir.c b/sysdeps/posix/closedir.c deleted file mode 100644 index ccc19eefcd..0000000000 --- a/sysdeps/posix/closedir.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 1991-2020 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, see - <https://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <stddef.h> -#include <stdlib.h> -#include <dirent.h> -#include <unistd.h> -#include <dirstream.h> -#include <not-cancel.h> - - -/* Close the directory stream DIRP. - Return 0 if successful, -1 if not. */ -int -__closedir (DIR *dirp) -{ - int fd; - - if (dirp == NULL) - { - __set_errno (EINVAL); - return -1; - } - - /* We do not try to synchronize access here. If some other thread - still uses this handle it is a big mistake and that thread - deserves all the bad data it gets. */ - - fd = dirp->fd; - -#if IS_IN (libc) - __libc_lock_fini (dirp->lock); -#endif - - free ((void *) dirp); - - return __close_nocancel (fd); -} -weak_alias (__closedir, closedir) diff --git a/sysdeps/posix/dirfd.c b/sysdeps/posix/dirfd.c deleted file mode 100644 index 5d0928dca4..0000000000 --- a/sysdeps/posix/dirfd.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Return the file descriptor used by a DIR stream. Unix version. - Copyright (C) 1995-2020 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, see - <https://www.gnu.org/licenses/>. */ - -#include <dirent.h> -#include <dirstream.h> - -#undef dirfd - -int -__dirfd (DIR *dirp) -{ - return dirp->fd; -} - -weak_alias (__dirfd, dirfd) -libc_hidden_def (dirfd) diff --git a/sysdeps/posix/dirstream.h b/sysdeps/posix/dirstream.h deleted file mode 100644 index a3ea2b7197..0000000000 --- a/sysdeps/posix/dirstream.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 1993-2020 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, see - <https://www.gnu.org/licenses/>. */ - -#ifndef _DIRSTREAM_H -#define _DIRSTREAM_H 1 - -#include <sys/types.h> - -#include <libc-lock.h> - -/* Directory stream type. - - The miscellaneous Unix `readdir' implementations read directory data - into a buffer and return `struct dirent *' pointers into it. */ - -struct __dirstream - { - int fd; /* File descriptor. */ - - __libc_lock_define (, lock) /* Mutex lock for this structure. */ - - size_t allocation; /* Space allocated for the block. */ - size_t size; /* Total valid data in the block. */ - size_t offset; /* Current offset into the block. */ - - off_t filepos; /* Position of next entry to read. */ - - int errcode; /* Delayed error code. */ - - /* Directory block. We must make sure that this block starts - at an address that is aligned adequately enough to store - dirent entries. Using the alignment of "void *" is not - sufficient because dirents on 32-bit platforms can require - 64-bit alignment. We use "long double" here to be consistent - with what malloc uses. */ - char data[0] __attribute__ ((aligned (__alignof__ (long double)))); - }; - -#define _DIR_dirfd(dirp) ((dirp)->fd) - -#endif /* dirstream.h */ diff --git a/sysdeps/posix/fdopendir.c b/sysdeps/posix/fdopendir.c deleted file mode 100644 index e424fbdaa2..0000000000 --- a/sysdeps/posix/fdopendir.c +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2005-2020 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, see - <https://www.gnu.org/licenses/>. */ - -#include <dirent.h> -#include <errno.h> -#include <fcntl.h> -#include <stddef.h> -#include <sys/stat.h> - -#include <not-cancel.h> - - -DIR * -__fdopendir (int fd) -{ - struct stat64 statbuf; - - if (__builtin_expect (__fstat64 (fd, &statbuf), 0) < 0) - return NULL; - if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode))) - { - __set_errno (ENOTDIR); - return NULL; - } - - /* Make sure the descriptor allows for reading. */ - int flags = __fcntl64_nocancel (fd, F_GETFL); - if (__glibc_unlikely (flags == -1)) - return NULL; - if (__glibc_unlikely ((flags & O_ACCMODE) == O_WRONLY)) - { - __set_errno (EINVAL); - return NULL; - } - - return __alloc_dir (fd, false, flags, &statbuf); -} -weak_alias (__fdopendir, fdopendir) diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c deleted file mode 100644 index e89e09bfc7..0000000000 --- a/sysdeps/posix/opendir.c +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright (C) 1991-2020 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, see - <https://www.gnu.org/licenses/>. */ - -#include <dirent.h> -#include <fcntl.h> -#include <errno.h> -#include <stdio.h> /* For BUFSIZ. */ -#include <sys/param.h> /* For MIN and MAX. */ - -#include <not-cancel.h> - -/* The st_blksize value of the directory is used as a hint for the - size of the buffer which receives struct dirent values from the - kernel. st_blksize is limited to MAX_DIR_BUFFER_SIZE, in case the - file system provides a bogus value. */ -#define MAX_DIR_BUFFER_SIZE 1048576U - -enum { - opendir_oflags = O_RDONLY|O_NDELAY|O_DIRECTORY|O_LARGEFILE|O_CLOEXEC -}; - -static bool -invalid_name (const char *name) -{ - if (__glibc_unlikely (name[0] == '\0')) - { - /* POSIX.1-1990 says an empty name gets ENOENT; - but `open' might like it fine. */ - __set_errno (ENOENT); - return true; - } - return false; -} - -static DIR * -opendir_tail (int fd) -{ - if (__glibc_unlikely (fd < 0)) - return NULL; - - /* Now make sure this really is a directory and nothing changed since the - `stat' call. The S_ISDIR check is superfluous if O_DIRECTORY works, - but it's cheap and we need the stat call for st_blksize anyway. */ - struct stat64 statbuf; - if (__glibc_unlikely (__fstat64 (fd, &statbuf) < 0)) - goto lose; - if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode))) - { - __set_errno (ENOTDIR); - lose: - __close_nocancel_nostatus (fd); - return NULL; - } - - return __alloc_dir (fd, true, 0, &statbuf); -} - - -#if IS_IN (libc) -DIR * -__opendirat (int dfd, const char *name) -{ - if (__glibc_unlikely (invalid_name (name))) - return NULL; - - return opendir_tail (__openat_nocancel (dfd, name, opendir_oflags)); -} -#endif - - -/* Open a directory stream on NAME. */ -DIR * -__opendir (const char *name) -{ - if (__glibc_unlikely (invalid_name (name))) - return NULL; - - return opendir_tail (__open_nocancel (name, opendir_oflags)); -} -weak_alias (__opendir, opendir) - -DIR * -__alloc_dir (int fd, bool close_fd, int flags, const struct stat64 *statp) -{ - /* We have to set the close-on-exit flag if the user provided the - file descriptor. */ - if (!close_fd - && __glibc_unlikely (__fcntl64_nocancel (fd, F_SETFD, FD_CLOEXEC) < 0)) - goto lose; - - const size_t default_allocation = (4 * BUFSIZ < sizeof (struct dirent64) - ? sizeof (struct dirent64) : 4 * BUFSIZ); - const size_t small_allocation = (BUFSIZ < sizeof (struct dirent64) - ? sizeof (struct dirent64) : BUFSIZ); - size_t allocation = default_allocation; -#ifdef _STATBUF_ST_BLKSIZE - /* Increase allocation if requested, but not if the value appears to - be bogus. */ - if (statp != NULL) - allocation = MIN (MAX ((size_t) statp->st_blksize, default_allocation), - MAX_DIR_BUFFER_SIZE); -#endif - - DIR *dirp = (DIR *) malloc (sizeof (DIR) + allocation); - if (dirp == NULL) - { - allocation = small_allocation; - dirp = (DIR *) malloc (sizeof (DIR) + allocation); - - if (dirp == NULL) - lose: - { - if (close_fd) - { - int save_errno = errno; - __close_nocancel_nostatus (fd); - __set_errno (save_errno); - } - return NULL; - } - } - - dirp->fd = fd; -#if IS_IN (libc) - __libc_lock_init (dirp->lock); -#endif - dirp->allocation = allocation; - dirp->size = 0; - dirp->offset = 0; - dirp->filepos = 0; - dirp->errcode = 0; - - return dirp; -} diff --git a/sysdeps/posix/readdir.c b/sysdeps/posix/readdir.c deleted file mode 100644 index b36278b5f4..0000000000 --- a/sysdeps/posix/readdir.c +++ /dev/null @@ -1,127 +0,0 @@ -/* Copyright (C) 1991-2020 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, see - <https://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <limits.h> -#include <stddef.h> -#include <string.h> -#include <dirent.h> -#include <unistd.h> -#include <sys/types.h> -#include <assert.h> - -#include <dirstream.h> - -#ifndef __READDIR -# define __READDIR __readdir -# define __GETDENTS __getdents -# define DIRENT_TYPE struct dirent -# define __READDIR_ALIAS -#endif - -/* Read a directory entry from DIRP. */ -DIRENT_TYPE * -__READDIR (DIR *dirp) -{ - DIRENT_TYPE *dp; - int saved_errno = errno; - -#if IS_IN (libc) - __libc_lock_lock (dirp->lock); -#endif - - do - { - size_t reclen; - - if (dirp->offset >= dirp->size) - { - /* We've emptied out our buffer. Refill it. */ - - size_t maxread; - ssize_t bytes; - -#ifndef _DIRENT_HAVE_D_RECLEN - /* Fixed-size struct; must read one at a time (see below). */ - maxread = sizeof *dp; -#else - maxread = dirp->allocation; -#endif - - bytes = __GETDENTS (dirp->fd, dirp->data, maxread); - if (bytes <= 0) - { - /* On some systems getdents fails with ENOENT when the - open directory has been rmdir'd already. POSIX.1 - requires that we treat this condition like normal EOF. */ - if (bytes < 0 && errno == ENOENT) - bytes = 0; - - /* Don't modifiy errno when reaching EOF. */ - if (bytes == 0) - __set_errno (saved_errno); - dp = NULL; - break; - } - dirp->size = (size_t) bytes; - - /* Reset the offset into the buffer. */ - dirp->offset = 0; - } - - dp = (DIRENT_TYPE *) &dirp->data[dirp->offset]; - -#ifdef _DIRENT_HAVE_D_RECLEN - reclen = dp->d_reclen; -#else - /* The only version of `struct dirent*' that lacks `d_reclen' - is fixed-size. */ - assert (sizeof dp->d_name > 1); - reclen = sizeof *dp; - /* The name is not terminated if it is the largest possible size. - Clobber the following byte to ensure proper null termination. We - read jst one entry at a time above so we know that byte will not - be used later. */ - dp->d_name[sizeof dp->d_name] = '\0'; -#endif - - dirp->offset += reclen; - -#ifdef _DIRENT_HAVE_D_OFF - dirp->filepos = dp->d_off; -#else - dirp->filepos += reclen; -#endif - - /* Skip deleted files. */ - } while (dp->d_ino == 0); - -#if IS_IN (libc) - __libc_lock_unlock (dirp->lock); -#endif - - return dp; -} - -#ifdef __READDIR_ALIAS -weak_alias (__readdir, readdir) -#endif - -#undef __READDIR -#undef __GETDENTS -#undef DIRENT_TYPE -#undef __READDIR_ALIAS diff --git a/sysdeps/posix/readdir_r.c b/sysdeps/posix/readdir_r.c deleted file mode 100644 index 9079abc2ff..0000000000 --- a/sysdeps/posix/readdir_r.c +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright (C) 1991-2020 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, see - <https://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <limits.h> -#include <stddef.h> -#include <string.h> -#include <dirent.h> -#include <unistd.h> -#include <sys/types.h> -#include <assert.h> - -#include <dirstream.h> - -#ifndef __READDIR_R -# define __READDIR_R __readdir_r -# define __GETDENTS __getdents -# define DIRENT_TYPE struct dirent -# define __READDIR_R_ALIAS -#endif - -/* Read a directory entry from DIRP. */ -int -__READDIR_R (DIR *dirp, DIRENT_TYPE *entry, DIRENT_TYPE **result) -{ - DIRENT_TYPE *dp; - size_t reclen; - const int saved_errno = errno; - int ret; - - __libc_lock_lock (dirp->lock); - - do - { - if (dirp->offset >= dirp->size) - { - /* We've emptied out our buffer. Refill it. */ - - size_t maxread; - ssize_t bytes; - -#ifndef _DIRENT_HAVE_D_RECLEN - /* Fixed-size struct; must read one at a time (see below). */ - maxread = sizeof *dp; -#else - maxread = dirp->allocation; -#endif - - bytes = __GETDENTS (dirp->fd, dirp->data, maxread); - if (bytes <= 0) - { - /* On some systems getdents fails with ENOENT when the - open directory has been rmdir'd already. POSIX.1 - requires that we treat this condition like normal EOF. */ - if (bytes < 0 && errno == ENOENT) - { - bytes = 0; - __set_errno (saved_errno); - } - if (bytes < 0) - dirp->errcode = errno; - - dp = NULL; - break; - } - dirp->size = (size_t) bytes; - - /* Reset the offset into the buffer. */ - dirp->offset = 0; - } - - dp = (DIRENT_TYPE *) &dirp->data[dirp->offset]; - -#ifdef _DIRENT_HAVE_D_RECLEN - reclen = dp->d_reclen; -#else - /* The only version of `struct dirent*' that lacks `d_reclen' - is fixed-size. */ - assert (sizeof dp->d_name > 1); - reclen = sizeof *dp; - /* The name is not terminated if it is the largest possible size. - Clobber the following byte to ensure proper null termination. We - read just one entry at a time above so we know that byte will not - be used later. */ - dp->d_name[sizeof dp->d_name] = '\0'; -#endif - - dirp->offset += reclen; - -#ifdef _DIRENT_HAVE_D_OFF - dirp->filepos = dp->d_off; -#else - dirp->filepos += reclen; -#endif - -#ifdef NAME_MAX - if (reclen > offsetof (DIRENT_TYPE, d_name) + NAME_MAX + 1) - { - /* The record is very long. It could still fit into the - caller-supplied buffer if we can skip padding at the - end. */ - size_t namelen = _D_EXACT_NAMLEN (dp); - if (namelen <= NAME_MAX) - reclen = offsetof (DIRENT_TYPE, d_name) + namelen + 1; - else - { - /* The name is too long. Ignore this file. */ - dirp->errcode = ENAMETOOLONG; - dp->d_ino = 0; - continue; - } - } -#endif - - /* Skip deleted and ignored files. */ - } - while (dp->d_ino == 0); - - if (dp != NULL) - { - *result = memcpy (entry, dp, reclen); -#ifdef _DIRENT_HAVE_D_RECLEN - entry->d_reclen = reclen; -#endif - ret = 0; - } - else - { - *result = NULL; - ret = dirp->errcode; - } - - __libc_lock_unlock (dirp->lock); - - return ret; -} - -#ifdef __READDIR_R_ALIAS -weak_alias (__readdir_r, readdir_r) -#endif - -#undef __READDIR_R -#undef __GETDENTS -#undef DIRENT_TYPE -#undef __READDIR_R_ALIAS diff --git a/sysdeps/posix/rewinddir.c b/sysdeps/posix/rewinddir.c deleted file mode 100644 index 860bfda004..0000000000 --- a/sysdeps/posix/rewinddir.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 1991-2020 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, see - <https://www.gnu.org/licenses/>. */ - -#include <stddef.h> -#include <dirent.h> -#include <sys/types.h> -#include <unistd.h> -#include <dirstream.h> - -/* Rewind DIRP to the beginning of the directory. */ -void -__rewinddir (DIR *dirp) -{ -#if IS_IN (libc) - __libc_lock_lock (dirp->lock); -#endif - (void) __lseek (dirp->fd, (off_t) 0, SEEK_SET); - dirp->filepos = 0; - dirp->offset = 0; - dirp->size = 0; - dirp->errcode = 0; -#if IS_IN (libc) - __libc_lock_unlock (dirp->lock); -#endif -} -libc_hidden_def (__rewinddir) -weak_alias (__rewinddir, rewinddir) diff --git a/sysdeps/posix/seekdir.c b/sysdeps/posix/seekdir.c deleted file mode 100644 index 3c30520928..0000000000 --- a/sysdeps/posix/seekdir.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 1991-2020 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, see - <https://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <stddef.h> -#include <dirent.h> -#include <unistd.h> -#include <dirstream.h> - -/* Seek to position POS in DIRP. */ -/* XXX should be __seekdir ? */ -void -seekdir (DIR *dirp, long int pos) -{ - __libc_lock_lock (dirp->lock); - (void) __lseek (dirp->fd, pos, SEEK_SET); - dirp->size = 0; - dirp->offset = 0; - dirp->filepos = pos; - __libc_lock_unlock (dirp->lock); -} diff --git a/sysdeps/posix/telldir.c b/sysdeps/posix/telldir.c deleted file mode 100644 index 57d435ed21..0000000000 --- a/sysdeps/posix/telldir.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 1991-2020 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, see - <https://www.gnu.org/licenses/>. */ - -#include <dirent.h> - -#include <dirstream.h> - -/* Return the current position of DIRP. */ -long int -telldir (DIR *dirp) -{ - long int ret; - - __libc_lock_lock (dirp->lock); - ret = dirp->filepos; - __libc_lock_unlock (dirp->lock); - - return ret; -} |