I think there is a bug in the NFS client code. When I compile it
and run it on a nfs dir, I get
# gcc x.c
# df /net/ocean/linux
Filesystem 1024-blocks Used Available Capacity Mounted on
ocean:/home/work/linux
2020332 1504283 511953 75% /net/ocean/linux
# a.out /net/ocean/linux
lseek: Operation not permitted
lseek is ok
# a.out /
lseek is ok
lseek is ok
It seems to me lseek from kernel will return -1 on a nfs dir when it
reaches the end of directory. I don't think it is the correct behavior.
lseek (dirfd (dp), 0, SEEK_CUR) should return the size of the dir when
it is at the end of directory.
Thanks.
-- H.J. Lu (hjl@gnu.org) ---x.c--- #include <unistd.h> #include <fcntl.h> #include <dirent.h> #include <errno.h>main (int argc, char **argv) { DIR * dp = opendir (argv [1]); struct dirent *fp;
while (fp = readdir (dp));
if (lseek (dirfd (dp), 0, SEEK_CUR) < 0) perror ("lseek"); else printf ("lseek is ok\n");
if (lseek (dirfd (dp), 1, SEEK_CUR) < 0) perror ("lseek"); else printf ("lseek is ok\n");
closedir (dp); }
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html