[Issue 283] incorrect std.c.linux.linux.dirent definition / listdir does not decend into subdirs on linux

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 29 00:09:24 PDT 2007


http://d.puremagic.com/issues/show_bug.cgi?id=283


thomas-dloop at kuehne.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |major
            Summary|listdir does not decend into|incorrect
                   |subdirs on linux            |std.c.linux.linux.dirent
                   |                            |definition / listdir does
                   |                            |not decend into subdirs on
                   |                            |linux




------- Comment #1 from thomas-dloop at kuehne.cn  2007-04-29 02:09 -------
std.c.linux.linux.dirent is defined as

#   struct dirent
#    {
#       int d_ino;
#       off_t d_off;
#       ushort d_reclen;
#       ubyte d_type;
#       char[256] d_name;
#    }

It is just luck that the current std.file.listdir functions don't segfault on 
Linux
because the above structure should be named dirent64 not dirent.

/usr/include/linux/dirent.h :

# #ifndef _LINUX_DIRENT_H
# #define _LINUX_DIRENT_H
#
# #include <linux/types.h>
#
# struct dirent {
#    long      d_ino;
#    __kernel_off_t   d_off;
#    unsigned short   d_reclen;
#    char      d_name[256]; /* We must not include limits.h! */
# };
#
# struct dirent64 {
#    __u64      d_ino;
#    __s64      d_off;
#    unsigned short   d_reclen;
#    unsigned char   d_type;
#    char      d_name[256];
# };
#
#
# #endif

Either rename the structure to dirent64 and use readdir64 in std.file.listdir 
or fix the definition
and rewrite std.file.DirEntry.init/isdir/isfile


-- 



More information about the Digitalmars-d-bugs mailing list