? dirent.diff ? o ? syslog.3q Index: dirent_private.h =================================================================== RCS file: /cvsroot/src/lib/libc/gen/dirent_private.h,v retrieving revision 1.4 diff -u -p -u -r1.4 dirent_private.h --- dirent_private.h 26 Sep 2010 02:26:59 -0000 1.4 +++ dirent_private.h 31 Aug 2024 14:28:35 -0000 @@ -1,5 +1,6 @@ /* $NetBSD: dirent_private.h,v 1.4 2010/09/26 02:26:59 yamt Exp $ */ +#include <errno.h> /* * One struct _dirpos is malloced to describe the current directory * position each time telldir is called. It records the current magic @@ -12,6 +13,14 @@ struct dirpos { long dp_loc; /* offset of entry in buffer */ }; +static __inline void +_dirent_lseek(DIR *dirp, off_t offset, int whence) +{ + int save_errno = errno; + dirp->dd_seek = lseek(dirp->dd_fd, offset, whence); + errno = save_errno; +} + struct _dirdesc; void _seekdir_unlocked(struct _dirdesc *, long); long _telldir_unlocked(struct _dirdesc *); Index: initdir.c =================================================================== RCS file: /cvsroot/src/lib/libc/gen/initdir.c,v retrieving revision 1.5 diff -u -p -u -r1.5 initdir.c --- initdir.c 11 Jul 2021 16:30:41 -0000 1.5 +++ initdir.c 31 Aug 2024 14:28:35 -0000 @@ -120,7 +120,7 @@ retry: ddptr = buf + (len - space); } - dirp->dd_seek = lseek(fd, (off_t)0, SEEK_CUR); + _dirent_lseek(dirp, (off_t)0, SEEK_CUR); n = getdents(fd, ddptr, space); /* * For NFS: EINVAL means a bad cookie error Index: readdir.c =================================================================== RCS file: /cvsroot/src/lib/libc/gen/readdir.c,v retrieving revision 1.26 diff -u -p -u -r1.26 readdir.c --- readdir.c 25 Jun 2012 22:32:43 -0000 1.26 +++ readdir.c 31 Aug 2024 14:28:36 -0000 @@ -65,7 +65,7 @@ _readdir_unlocked(DIR *dirp, int skipdel dirp->dd_loc = 0; } if (dirp->dd_loc == 0 && !(dirp->dd_flags & __DTF_READALL)) { - dirp->dd_seek = lseek(dirp->dd_fd, (off_t)0, SEEK_CUR); + _dirent_lseek(dirp, (off_t)0, SEEK_CUR); dirp->dd_size = getdents(dirp->dd_fd, dirp->dd_buf, (size_t)dirp->dd_len); if (dirp->dd_size <= 0) Index: rewinddir.c =================================================================== RCS file: /cvsroot/src/lib/libc/gen/rewinddir.c,v retrieving revision 1.13 diff -u -p -u -r1.13 rewinddir.c --- rewinddir.c 26 Sep 2010 02:26:59 -0000 1.13 +++ rewinddir.c 31 Aug 2024 14:28:36 -0000 @@ -64,7 +64,7 @@ rewinddir(DIR *dirp) #endif fd = dirp->dd_fd; _finidir(dirp); - dirp->dd_seek = lseek(fd, (off_t)0, SEEK_SET); + _dirent_lseek(dirp, (off_t)0, SEEK_SET); _initdir(dirp, fd, NULL); #ifdef _REENTRANT if (__isthreaded) { Index: telldir.c =================================================================== RCS file: /cvsroot/src/lib/libc/gen/telldir.c,v retrieving revision 1.20 diff -u -p -u -r1.20 telldir.c --- telldir.c 6 Mar 2013 11:27:28 -0000 1.20 +++ telldir.c 31 Aug 2024 14:28:36 -0000 @@ -114,7 +114,7 @@ _seekdir_unlocked(DIR *dirp, long loc) if (lp->dp_loc == dirp->dd_loc && lp->dp_seek == dirp->dd_seek) return; - dirp->dd_seek = lseek(dirp->dd_fd, lp->dp_seek, SEEK_SET); + _dirent_lseek(dirp, lp->dp_seek, SEEK_SET); dirp->dd_loc = 0; while (dirp->dd_loc < lp->dp_loc) if (_readdir_unlocked(dirp, 0) == NULL)