Unix Extension & "du"

Peter Waechtler peter at helios.de
Fri Sep 17 07:53:00 GMT 2004


Am Freitag, 17. September 2004 01:44 schrieb Jeremy Allison:
> On Fri, Sep 17, 2004 at 12:52:46AM +0200, Samuel Thibault wrote:
> > Hi,
> >
> > When smbmounting some samba-served share and running du on linux with
> > smbfs, one gets crazy results:
[..]
> > What happens is that samba & kernel's smbfs don't agree on the meaning
> > of the 2nd 64-bit value in unix extension: samba/smbd/trans2.c tells
> > (and has always told since addition, cvs rev 1.149.4.47):
> > SOFF_T(p,0,get_allocation_size(NULL,&sbuf)); /* Number of bytes used on
> > disk - 64 Bit while the kernel does (and has always been doing since
> > addition to 2.5.40)
> >         fattr->f_blocks = LVAL(p, 8);
> > I.e. takes it as a number of sectors.
>
> I changed this to number of bytes on disk, not number of sectors, as
> there is no POSIX agreement on how many bytes per sector. This we
> report the number of bytes as a 64-bit number, and the local client can
> work that out in terms of number of sectors.
>
> > Who is wrong ? I could find some draft here:
> > http://uranus.it.swin.edu.au/~jn/linux/smbfs/Byron_Deadwiler_Paper.doc
> > which tells that:
> > CIFS Extensions for UNIX systems V1
> > LARGE_INTEGER NumOfBlocks
> > Number of file system block used to store file
> >
> > Which is on the kernel's side...
>
> And is wrong. As there is no agreement in POSIX on what that number
> means.
>

But you have stat.st_blocks and stat.st_blocksize.
GetFSattr also returns a means of the granularity of the file system.

In the ALU (allocation unit - always a multiple of FS blocksize) CIFS wants
that in terms of number of bytes.

SNIA doc: 4.1.6.4. SMB_QUERY_FS_SIZE_INFO 
InformationLevel Data Block Encoding Description 

LARGE_INTEGER Total Number of Allocation units on the Volume 
LARGE_INTEGER Number of free Allocation units on the Volume 
ULONG Number of sectors in each Allocation unit 
ULONG Number of bytes in each sector

So if your device has stat.st_blocksize of 4096, I would return
8 as "Number of sectors in each Allocation unit " and 
512 as "Number of bytes in each sector"

And I don't know what POSIX has to do with that.



More information about the samba-technical mailing list