From owner-freebsd-hackers Thu Nov 30 03:49:47 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id DAA19987 for hackers-outgoing; Thu, 30 Nov 1995 03:49:47 -0800 Received: from ref.tfs.com (ref.tfs.com [140.145.254.251]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id DAA19980 for ; Thu, 30 Nov 1995 03:49:45 -0800 Received: (from julian@localhost) by ref.tfs.com (8.6.12/8.6.9) id DAA11852 for hackers@freebsd.org; Thu, 30 Nov 1995 03:49:24 -0800 Date: Thu, 30 Nov 1995 03:49:24 -0800 From: Julian Elischer Message-Id: <199511301149.DAA11852@ref.tfs.com> To: hackers@freebsd.org Subject: seekdir broken.. Sender: owner-hackers@freebsd.org Precedence: bulk The following code attempts to read a directory, in small gulps.. it seems silly, but there is a reason for doing this in WINE. The code THINKS it;s stepping through the directory.. but in fact as we can see, the seekdir is having NO effect at all, so we just keep getting the first two entries over and over.. any ideas? this breaks WINE big-time.. I'm AMAZED nothing else breaks.. the readdir code is SHIT! you can't read two directories at once because it uses static elements! ---------------------------------- #include #include DIR *dir; /* * Loop through a directory, looking for something */ main() { int num = 0; while(1) { /* * Look for something that might match */ num = readd(num, "*.c"); printf("-%d-\n",num ); /* * Nope that aint it, keep trying */ } } /* * scan through a directory looking for something that matches a pattern p */ int readd(int tell,char *pat) { int i; struct dirent *ent; dir = opendir("."); /* * Start where we left off, of where we are asked to */ seekdir(dir, tell); /* * pretend we hit on every 2nd item */ for ( i = 1; i< 3;i++) { printf("[%d] ", tell = telldir(dir)); if ( ! (ent = readdir(dir))) { printf("[%d] ",telldir(dir)); printf("exiting\n"); exit(1); } printf("<%s>",ent->d_name); } closedir(dir); return(tell); } ------------------end of test program----------- under OSF1 the output in /tmp (2 files) is: [0] <.>[12] <..>-12- [12] <..>[24] -24- [24] [120] -120- [120] [512] [512] exiting under freeBSD the output is: [1] <.>[2] <..>-2- [4] <.>[5] <..>-5- [7] <.>[8] <..>-8- [10] <.>[11] <..>-11- [13] <.>[14] <..>-14- [16] <.>[17] <..>-17- [19] <.>[20] <..>-20- [22] <.>[23] <..>-23- [25] <.>[26] <..>-26- [28] <.>[29] <..>-29- (etc. forever..) I think I'm going over to see what NetBSD have done about this.. julian