VFS Linking errors

Paul Weaver paul.weaver at bbc.co.uk
Tue Oct 7 14:02:07 GMT 2008


From: Jeremy Allison [mailto:jra at samba.org] at 06 October 2008 23:54
> Subject: Re: VFS Linking errors
> This is due to the differences in definition. On Linux it's 
> defined as :
> 
>            struct dirent {
>                ino_t          d_ino;       /* inode number */
>                off_t          d_off;       /* offset to the 
> next dirent
> */
>                unsigned short d_reclen;    /* length of this record */
>                unsigned char  d_type;      /* type of file */
>                char           d_name[256]; /* filename */
>            };
> 
> On Solaris I'm guessing the last element is :
> 
> char           d_name[1];

Ahh, indeed it is
typedef struct dirent64 {
        ino64_t         d_ino;          /* "inode number" of entry */
        off64_t         d_off;          /* offset of disk directory
entry */
        unsigned short  d_reclen;       /* length of this record */
        char            d_name[1];      /* name of file */
} dirent64_t;

> It's really a variable element at the end of the struct, 
> again from the Linux man pages :
> 
> "According to POSIX, the dirent structure contains a field 
> char d_name[] of unspecified size, with at most NAME_MAX 
> characters preceding the terminating null byte."
> 
> You have to treat the struct accordingly.

The module presents a fake name for a file which matches a set pattern
(given a directory and create files "foo.bar", "donkey.woof" and
"msmMMOB.mdb", they are stored on disk as "foo.bar" and "donkey.woof",
but C has the IP address of the client appended "msmMMOB.mdb.10.2.3.4"

When you read the directory, you see "msmMMOB.mdb", but you see the copy
of the file for your IP address.

The code (roughly) is
http://ingex.cvs.sourceforge.net/viewvc/ingex/ingex/MediaHarmony/media_h
armony.c?revision=1.1&view=markup

The specific troublesome line is
static const char* MDB_FILENAME = "msmMMOB.mdb";
fstrcpy(d->d_name, MDB_FILENAME);

Sizeof MDB_FILENAME is 4, even though the content's 11 chars long, but I
think that's ok

Any hint as to what I could do better?


> > On both the solaris box and the linux SMB_STRUCT_DIRENT is 
> defined as
> > dirent64 -- which is a bit confusing at first glance as I've got a 
> > 32bit linux distro
> 
> Not really. Even on 32-bit builds we always use the 64-bit 
> API's to get the large file (>32bit) code to work correctly.

Thanks


More information about the samba-technical mailing list