FreeBSD Bugzilla – Attachment 154687 Details for
Bug 198819
rewinddir(3) after fdopendir(3) results in double entries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
example program that produces incorrect output on UFS
readdir_duplicate_entries.c (text/x-csrc), 666 bytes, created by
Mark Williams
on 2015-03-23 05:17:59 UTC
(
hide
)
Description:
example program that produces incorrect output on UFS
Filename:
MIME Type:
Creator:
Mark Williams
Created:
2015-03-23 05:17:59 UTC
Size:
666 bytes
patch
obsolete
>#include <dirent.h> >#include <errno.h> >#include <stdio.h> >#include <string.h> >#include <unistd.h> >#include <fcntl.h> > > >static void lookup() >{ > DIR *dirp; > struct dirent *dp; > int fd; > > if ((fd = open(".", O_RDONLY | O_DIRECTORY)) < 0) { > perror("couldn't open '.'"); > return; > } > > if ((dirp = fdopendir(fd)) == NULL) { > perror("fdopendir failed"); > return; > } > > rewinddir(dirp); > > do { > errno = 0; > if ((dp = readdir(dirp)) != NULL) { > printf("%s\n", dp->d_name); > } > } while (dp != NULL); > > > if (errno != 0) > perror("error reading directory"); > > (void) closedir(dirp); > return; >} > > >int main() >{ > lookup(); > return (0); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 198819
: 154687