[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#210861: libc6: readdir always returns dtype as unknown



On Sun, Sep 14, 2003 at 05:20:59PM +0200, Jacob Kolding wrote:
> On Sun, 2003-09-14 at 17:08, Philip Blundell wrote:
> > On Sun, 2003-09-14 at 16:02, Jacob Kolding wrote:
> > > But a friend of mine has the same problem with kernel 2.4.22 and
> > > reiserfs so how can it be a kernel problem. unless it's at kernel config
> > > option?
> > >
> > > attached is the strace from my friend.
> > 
> > In this case, getdents64() is indeed being used correctly.  But reiserfs
> > doesn't provide d_type information, so again you will get DT_UNKNOWN. 
> > Your friend needs to change to a different filesystem.
> 
> In that case readdir seems like a rather useless function if it is so
> dependent on kernel versions an fs types.
> 
> Do you know of any other functions that can be used instead?
> My goal is to have a program that works with any 
> fs type and kernel version.

>From the glibc manual:
    `unsigned char d_type'
          This is the type of the file, possibly unknown.  The
          following constants are defined for its value:

         `DT_UNKNOWN'
               The type is unknown.  On some systems this is the only
               value returned.

and

          This member is a BSD extension.  The symbol
          `_DIRENT_HAVE_D_TYPE' is defined if this member is available.
          On systems where it is used, it corresponds to the file type
          bits in the `st_mode' member of `struct statbuf'.  If the
          value cannot be determine the member value is DT_UNKNOWN.
          These two macros convert between `d_type' values and
          `st_mode' values:

I.E. if d_type == DT_UNKNOWN, you must call stat.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer



Reply to: