fix for bug 564: filesizes are incorrectly displayed in Mac O S X

Esh, Andrew Andrew_Esh at adaptec.com
Mon Oct 6 23:01:48 GMT 2003


This change is probably correct, but it is up to Jeremy to determine if it
is apt in this location. I am unfamiliar with this SMB_INFO_ALLOCATION case.
In general, this change is the same as the one I made back when the FS_SIZE
cases were parameterized. It looks to me as though this change is lifted
from the old case, and would be correct if it is intended to reply with the
same numbers.

Here's the log where you checked it in:

revision 1.149.4.86
date: 2002/06/17 21:31:48;  author: jra;  state: Exp;  lines: +52 -15
Fix from Andrew Esh to parameterize block size on disk size return.
This seems to have an effect on client write performance (maybe it
affects client buffer sizes), and so we can now test how to tune this
for optimum write speed.
Jeremy.

Here's what changed during that checkin:

Index: trans2.c
===================================================================
RCS file: /cvsroot/samba/source/smbd/trans2.c,v
retrieving revision 1.149.4.85
retrieving revision 1.149.4.86
diff -u -c -r1.149.4.85 -r1.149.4.86
cvs server: conflicting specifications of output style
*** trans2.c	12 Jun 2002 19:21:56 -0000	1.149.4.85
--- trans2.c	17 Jun 2002 21:31:48 -0000	1.149.4.86
***************
*** 1435,1467 ****
  		case SMB_QUERY_FS_SIZE_INFO:
  		case SMB_FS_SIZE_INFORMATION:
  		{
! 			SMB_BIG_UINT dfree,dsize,bsize,secs_per_unit;;
  			data_len = 24;
 
conn->vfs_ops.disk_free(conn,".",False,&bsize,&dfree,&dsize);	
! 			if (bsize < 1024) {
! 				SMB_BIG_UINT factor = 1024/bsize;
! 				bsize = 1024;
  				dsize /= factor;
  				dfree /= factor;
  			}
! 			secs_per_unit = 2;
!
SBIG_UINT(pdata,0,dsize*(bsize/(512*secs_per_unit)));
!
SBIG_UINT(pdata,8,dfree*(bsize/(512*secs_per_unit)));
! 			SIVAL(pdata,16,secs_per_unit);
! 			SIVAL(pdata,20,512);
  			break;
  		}
  
  		case SMB_FS_FULL_SIZE_INFORMATION:
  		{
! 			SMB_BIG_UINT dfree,dsize,bsize;
  			data_len = 32;
 
conn->vfs_ops.disk_free(conn,".",False,&bsize,&dfree,&dsize);	
! 			SBIG_UINT(pdata,0,dsize); /* Total Allocation units.
*/
! 			SBIG_UINT(pdata,8,dfree); /* Caller available
allocation units. */
! 			SBIG_UINT(pdata,16,dfree); /* Actual available
allocation units. */
! 			SIVAL(pdata,24,bsize/512); /* Sectors per allocation
unit. */
! 			SIVAL(pdata,28,512); /* Bytes per sector. */
  			break;
  		}
  
--- 1435,1504 ----
  		case SMB_QUERY_FS_SIZE_INFO:
  		case SMB_FS_SIZE_INFORMATION:
  		{
! 			SMB_BIG_UINT
dfree,dsize,bsize,block_size,sectors_per_unit;
! 			SMB_BIG_UINT bytes_per_sector,size_units,free_units;
  			data_len = 24;
 
conn->vfs_ops.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;
! 			size_units =
(dsize*bsize)/(bytes_per_sector*sectors_per_unit);
! 			free_units =
(dfree*bsize)/(bytes_per_sector*sectors_per_unit);
! 			DEBUG(5,("call_trans2qfsinfo :
SMB_QUERY_FS_SIZE_INFO bsize=%u, cSectorUnit=%u, \
! cBytesSector=%u, cUnitTotal=%u,cUnitAvail=%d\n", (unsigned int)bsize,
(unsigned int)sectors_per_unit,
! 				(unsigned int)bytes_per_sector, (unsigned
int)size_units,
! 				(unsigned int)free_units));
! 			SBIG_UINT(pdata,0,size_units);
! 			SBIG_UINT(pdata,8,free_units);
! 			SIVAL(pdata,16,sectors_per_unit);
! 			SIVAL(pdata,20,bytes_per_sector);
  			break;
  		}
  
  		case SMB_FS_FULL_SIZE_INFORMATION:
  		{
! 			SMB_BIG_UINT
dfree,dsize,bsize,block_size,sectors_per_unit;
! 			SMB_BIG_UINT bytes_per_sector,size_units,free_units;
  			data_len = 32;
 
conn->vfs_ops.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;
! 			size_units =
(dsize*bsize)/(bytes_per_sector*sectors_per_unit);
! 			free_units =
(dfree*bsize)/(bytes_per_sector*sectors_per_unit);
! 			DEBUG(5,("call_trans2qfsinfo :
SMB_QUERY_FS_FULL_SIZE_INFO bsize=%u, cSectorUnit=%u, \
! cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize,
(unsigned int)sectors_per_unit,
! 				(unsigned int)bytes_per_sector, (unsigned
int)size_units,
! 				(unsigned int)free_units));
! 			SBIG_UINT(pdata,0,size_units); /* Total Allocation
units. */
! 			SBIG_UINT(pdata,8,free_units); /* Caller available
allocation units. */
! 			SBIG_UINT(pdata,16,free_units); /* Actual available
allocation units. */
! 			SIVAL(pdata,24,sectors_per_unit); /* Sectors per
allocation unit. */
! 			SIVAL(pdata,28,bytes_per_sector); /* Bytes per
sector. */
  			break;
  		}
  
-----Original Message-----
From: Jeremy Allison [mailto:jra at samba.org]
Sent: Sunday, October 05, 2003 2:26 AM
To: samba-technical at samba.org
Subject: Re: fix for bug 564: filesizes are incorrectly displayed in Mac
OS X


On Sat, Oct 04, 2003 at 06:15:13PM -0700, Nicholas M. Kirsch wrote:
> --- 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);

Team - please don't anyone apply this until I've taken a good long
look at this. There are reasons the current allocation code is the
way it is.....

Jeremy.



More information about the samba-technical mailing list