Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Jun 1999 01:30:10 -0400 (EDT)
From:      Mike Nowlin <mike@argos.org>
To:        freebsd-stable@freebsd.org
Cc:        adoyle@viewsnet.com
Subject:   3.2-STABLE: readdir() in /proc problem
Message-ID:  <Pine.LNX.4.05.9906250116260.2002-100000@jason.argos.org>

next in thread | raw e-mail | index | archive | help

Not sure, but it looks like there might be a problem with the /proc
filesystem's file type reporting....  When using readdir() to pull the
directory entries, and then looking at x->d_type, it seems to be reporting
. and .. as file type 4 (directory), but the rest of the "directories" in
there as regular files -- /proc/1 is reported as type 8, not type 4.
Below is the code I used to test this on a couple of machines....  Other
than in the the /proc filesystem, it behaves the way you'd expect..

One of our programs written on a 2.8 box quit working when we upgraded to
3.1 last week....  Just tried the same thing on a 3.2-STABLE box, and it
has the same problem.

Bug?  Feature?  Something I missed?  If it's a bug, I'd be willing to take
a crack at finding it.....:)

--Mike

-------------------------------------------------------------------------


Ye Olde Test Code
-----------------

#include <sys/types.h>
#include <dirent.h>

main() {
   DIR *d;
   struct dirent *e;

   e=malloc(sizeof(struct dirent));
   d=opendir("/proc");

   while ((e = readdir(d)) != NULL) {
      printf("%d %s\n", e->d_type, e->d_name);
   }

   closedir(d);
}

... and sample output

4 .
4 ..
10 curproc
8 41588
8 41587
8 41450
8 41448
8 41447
8 41432
8 41431
8 41372
...
...
8 1
8 0




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.05.9906250116260.2002-100000>