[Samba] Re: missing directory entries on irix

Cale Fairchild cale at brocku.ca
Tue Apr 19 15:08:12 GMT 2005

Thanks for the patch, unfortunately when I installed it I had a lot more 
files missing from the directory listing and I have not taken much time to 
look at why. But it certainly is the cast that off_t on the IRIX box is 8 bytes 
in the current OS, however the compilers seem to convert the long values 
properly so long as overflow does not occur.

Thanks to your suggestion on looking at the 'xfs_growfs -n' output I think that 
I have finally tracked down the problem with the missing file. In IRIX systems 
that have version 1 naming the last entry in that directory listing has a 
dirent->d_off value of -1 if you treat it as a long. On systems with version 2 
naming the value is not set to -1. In samba 3.0.11 there was no apparent test 
of the dirent->d_off field, but in 3.0.12 it performs a telldir after reading 
the last name and returns NULL if the offset it -1.

My understanding is that if you preform a telldir after the readdir, as is 
found in ReadDirName() in dir.c for 3.0.12+ you are just getting the offset for 
the next entry. So after the last entry in the directory you will be getting 
the offset of a non-existent entry, in which case the next readdir would return 
NULL anyways. Is it necessary to test the offset inside the loop after the 
readdir or would it be sufficient to test it before the SeekDir on the next 

Unfortunately you can not convert between version 1 naming and version 2 
naming on the XFS filesystem without a full dump and restore. So I am 
wondering is someone can come up with a workaround for this.

Thanks for your time in this concern.

   Cale Fairchild
   Systems Administrator
   Computer Science
   Brock University

   cale at brocku.ca

On Mon, 18 Apr 2005, James Peach wrote:

> Hi all,
> I had a look into Jeremy's idea that this could be due to using a 32bit
> long to represent directory offsets. It turns out that there is a
> truncation issue, though I can't prove that this is the root cause of
> the missing directory entries.
> Historically, IRIX has roots in both SysV and BSD, and SGI take
> compatibility _very_ seriously in th 6.5 series. So there is a BSD
> telldir which is an alias to BSDtelldir and returns 32bit long. There
> is also a SysV telldir which returns 64bit off_t. Samba uses the SysV
> version, but casts the result to a 32bit long. By default, the dirent.h
> header file says that telldir returns a long, but AFAICT by grovelling
> in libc, it actually doesn't.
> I've attached a diff against svn HEAD that extends the offset field
> width to sizeof(off_t), which is 64bits on Irix. There's also an
> addition for "smbd -b" to print the sizes of off_t and size_t, and some
> compilation fixes that I now need for svn HEAD.
> The calls to dptr_fetch and dptr_fill are still bad. They attempt to
> save a potentially 8 byte offset into a 5 byte packet field. Jeremy will
> have to advise on what to do about these.
> Finally, can you please provide the output of "smbd -b" and xfs_growfs
> -n /path" for each system that is showing the problem. Please make sure
> that the smbd you run "smbd -b" with is the patched one.
> Lemme know if this diff helps. I'll be away from email for the rest of
> the week, so my response will be somwehat belated.
> -- 
> James Peach | jpeach at sgi.com | SGI Australian Software Group
> I don't speak for SGI.

More information about the samba mailing list