Bug 564 - filesizes are incorrectly displayed in Mac OS X
filesizes are incorrectly displayed in Mac OS X
Status: CLOSED FIXED
Product: Samba 3.0
Classification: Unclassified
Component: File Services
3.0.0
Other All
: P3 normal
: 3.0.1
Assigned To: Jeremy Allison
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-10-04 18:07 UTC by Nicholas Kirsch
Modified: 2005-11-14 09:35 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicholas Kirsch 2003-10-04 18:07:12 UTC
Running Samba from Linux can result in this issue on small file sizes. 
 
i.e. 
 
The directory listing from Mac OS X will show a 1 KB file as 256 KB. 
Requesting additional information from the finder will display the size as 
correct, but the 'bytes on disk' will remain incorrect.
Comment 1 Nicholas Kirsch 2003-10-04 18:13:36 UTC
Here is a patch, borrowing code from the SMB_FS_SIZE_INFORMATION case. 
 
--- trans2.c.orig       Thu Oct  2 17:40:45 2003 
+++ trans2.c    Sat Oct  4 18:04:46 2003 
@@ -1407,9 +1407,24 @@ 
        switch (info_level) { 
                case SMB_INFO_ALLOCATION: 
                { 
-                       SMB_BIG_UINT dfree,dsize,bsize; 
+                       SMB_BIG_UINT 
dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector; 
                        data_len = 18; 
                        
SMB_VFS_DISK_FREE(conn,".",False,&bsize,&dfree,&dsize); 
+                       block_size = lp_block_size(snum); 
+                       if (bsize < block_size) { 
+                               SMB_BIG_UINT factor = block_size/bsize; 
+                               bsize = block_size; 
+                               dsize /= factor; 
+                               dfree /= factor; 
+                       } 
+                       if (bsize > block_size) { 
+                               SMB_BIG_UINT factor = bsize/block_size; 
+                               bsize = block_size; 
+                               dsize *= factor; 
+                               dfree *= factor; 
+                       } 
+                       bytes_per_sector = 512; 
+                       sectors_per_unit = bsize/bytes_per_sector; 
                        SIVAL(pdata,l1_idFileSystem,st.st_dev); 
                        SIVAL(pdata,l1_cSectorUnit,bsize/512); 
                        SIVAL(pdata,l1_cUnit,dsize); 
 
Comment 2 Milan Roubal 2003-10-04 21:18:27 UTC
GREAT JOB!!! This patch just saved my life :) Its working :) Thanx
Comment 3 Jeremy Allison 2003-10-06 17:07:14 UTC
(Varient) of this patch applied.
Thanks,
Jeremy.
Comment 4 Gerald (Jerry) Carter 2005-08-24 10:24:25 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.