Date: Tue, 8 Jul 2003 15:23:53 -0400 From: Jp Calderone <exarkun@intarweb.us> To: hackers@freebsd.org Subject: telldir()/seekdir() confusion Message-ID: <20030708192342.GA4899@intarweb.us>
next in thread | raw e-mail | index | archive | help
I'm trying to work out some inconsistent behavior in my app across platforms. On FreeBSD, seekdir() doesn't seem to behave as I expect it to. Here's a short program that demonstrates my confusion: #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> int main() { DIR* dirp; off_t pos; struct dirent* ent; dirp = opendir("."); if (!dirp) perror("opendir"); ent = readdir(dirp); if (!ent) perror("readdir"); pos = telldir(dirp); if (pos == -1) perror("telldir"); ent = readdir(dirp); if (!ent) perror("readdir 2"); seekdir(dirp, pos); printf("First telldir:%d\nSecond telldir:%d\n", pos, telldir(dirp)); return 0; } On other platforms, the first and second telldir() return the same value. On the two FreeBSD machines I've tried it on, the first telldir() returns 1 and the second returns 0. Can anyone explain this? Thanks in advance, Jp
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030708192342.GA4899>