From 71fa7753a8515e75f0e7ccb36b3d367fbdc42b0b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 1 Feb 1999 21:03:43 +0000 Subject: locking/locking_shm.c: Added printf to help track down negative share mode problem. printing/print_svid.c: Fix for DG/UX lpstat. smbd/dfree.c: Added 'max_four_gig' parameter to normalize to 4GB when asked (used to be the default). smbd/open.c smbd/reply.c smbd/trans2.c: Changed to allow a <4GB volume size to be returned on a trans2 qfsinfo level 1 call. NT clients refuse to do the correct call to Samba servers (Herb recons it's the unicode bit) - this allows even a level 1 to return a volume size up to 9444732961341243916800 bytes (should be enough for now, until we get the unicode support added :-). Jeremy. --- source/include/proto.h | 3 ++- source/locking/locking_shm.c | 2 +- source/printing/print_svid.c | 12 +++++++++++- source/smbd/dfree.c | 34 +++++++++++++++++++++------------- source/smbd/open.c | 2 +- source/smbd/reply.c | 2 +- source/smbd/trans2.c | 4 ++-- 7 files changed, 39 insertions(+), 20 deletions(-) diff --git a/source/include/proto.h b/source/include/proto.h index b05923dc597..5bdd846d46a 100644 --- a/source/include/proto.h +++ b/source/include/proto.h @@ -2307,7 +2307,8 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO /*The following definitions come from smbd/dfree.c */ -SMB_BIG_UINT sys_disk_free(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize); +SMB_BIG_UINT sys_disk_free(char *path, BOOL max_four_gigs, + SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize); /*The following definitions come from smbd/dir.c */ diff --git a/source/locking/locking_shm.c b/source/locking/locking_shm.c index 8429ab8f7b1..5d0fc2dbf66 100644 --- a/source/locking/locking_shm.c +++ b/source/locking/locking_shm.c @@ -165,7 +165,7 @@ static int shm_get_share_modes(connection_struct *conn, malloc(num_entries * sizeof(share_mode_entry)); if(*old_shares == 0) { - DEBUG(0,("get_share_modes: malloc fail!\n")); + DEBUG(0,("get_share_modes: malloc fail for size 0x%x!\n", num_entries * sizeof(share_mode_entry))); return 0; } } diff --git a/source/printing/print_svid.c b/source/printing/print_svid.c index 5c5eebeb502..2b615a5c49f 100644 --- a/source/printing/print_svid.c +++ b/source/printing/print_svid.c @@ -60,7 +60,17 @@ static void populate_printers(void) if (((tmp = strchr(buf, ' ')) == NULL) || ((tmp = strchr(++tmp, ' ')) == NULL)) continue; - name = ++tmp; + + /* + * In case we're only at the "for ". + */ + + if(!strncmp("for ",++tmp,4)) + { + tmp=strchr(tmp, ' '); + tmp++; + } + name = tmp; /* truncate the ": ..." */ if ((tmp = strchr(name, ':')) != NULL) diff --git a/source/smbd/dfree.c b/source/smbd/dfree.c index 9f5675f4748..11a83c752d8 100644 --- a/source/smbd/dfree.c +++ b/source/smbd/dfree.c @@ -27,7 +27,7 @@ extern int DEBUGLEVEL; /**************************************************************************** normalise for DOS usage ****************************************************************************/ -static void disk_norm(SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) +static void disk_norm(BOOL max_four_gigs, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { /* check if the disk is beyond the max disk size */ SMB_BIG_UINT maxdisksize = lp_maxdisksize(); @@ -39,18 +39,23 @@ static void disk_norm(SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsiz /* the -1 should stop applications getting div by 0 errors */ } - + while (*dfree > WORDMAX || *dsize > WORDMAX || *bsize < 512) { *dfree /= 2; *dsize /= 2; *bsize *= 2; - if (*bsize > WORDMAX) { - *bsize = WORDMAX; - if (*dsize > WORDMAX) - *dsize = WORDMAX; - if (*dfree > WORDMAX) - *dfree = WORDMAX; - break; + if(max_four_gigs) { + /* + * Force max to be 4GB only. + */ + if (*bsize > WORDMAX) { + *bsize = WORDMAX; + if (*dsize > WORDMAX) + *dsize = WORDMAX; + if (*dfree > WORDMAX) + *dfree = WORDMAX; + break; + } } } } @@ -185,7 +190,9 @@ static int fsusage(const char *path, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) /**************************************************************************** return number of 1K blocks available on a path and total number ****************************************************************************/ -static SMB_BIG_UINT disk_free(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) + +static SMB_BIG_UINT disk_free(char *path, BOOL max_four_gigs, + SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { int dfree_retval; SMB_BIG_UINT dfree_q = 0; @@ -219,7 +226,7 @@ static SMB_BIG_UINT disk_free(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree *dfree = MAX(1,*dfree); } - disk_norm(bsize,dfree,dsize); + disk_norm(max_four_gigs, bsize,dfree,dsize); if ((*bsize) < 1024) { dfree_retval = (*dfree)/(1024/(*bsize)); @@ -234,7 +241,8 @@ static SMB_BIG_UINT disk_free(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree /**************************************************************************** wrap it to get filenames right ****************************************************************************/ -SMB_BIG_UINT sys_disk_free(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) +SMB_BIG_UINT sys_disk_free(char *path, BOOL max_four_gigs, + SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { - return(disk_free(dos_to_unix(path,False),bsize,dfree,dsize)); + return(disk_free(dos_to_unix(path,False),max_four_gigs, bsize,dfree,dsize)); } diff --git a/source/smbd/open.c b/source/smbd/open.c index 9dd03e17039..6fa1838397c 100644 --- a/source/smbd/open.c +++ b/source/smbd/open.c @@ -486,7 +486,7 @@ static void open_file(files_struct *fsp,connection_struct *conn, pstrcpy(dname,fname); p = strrchr(dname,'/'); if (p) *p = 0; - if (sys_disk_free(dname,&dum1,&dum2,&dum3) < (SMB_BIG_UINT)lp_minprintspace(SNUM(conn))) { + if (sys_disk_free(dname,False,&dum1,&dum2,&dum3) < (SMB_BIG_UINT)lp_minprintspace(SNUM(conn))) { int err; if(fd_attempt_close(fd_ptr, &err) == 0) dos_unlink(fname); diff --git a/source/smbd/reply.c b/source/smbd/reply.c index d338e288ecf..ec2bdcb55cd 100644 --- a/source/smbd/reply.c +++ b/source/smbd/reply.c @@ -1054,7 +1054,7 @@ int reply_dskattr(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz int outsize = 0; SMB_BIG_UINT dfree,dsize,bsize; - sys_disk_free(".",&bsize,&dfree,&dsize); + sys_disk_free(".",True,&bsize,&dfree,&dsize); outsize = set_message(outbuf,5,0,True); diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c index 886eb26e31b..53d247ba1cc 100644 --- a/source/smbd/trans2.c +++ b/source/smbd/trans2.c @@ -1090,7 +1090,7 @@ static int call_trans2qfsinfo(connection_struct *conn, { SMB_BIG_UINT dfree,dsize,bsize; data_len = 18; - sys_disk_free(".",&bsize,&dfree,&dsize); + sys_disk_free(".",False,&bsize,&dfree,&dsize); SIVAL(pdata,l1_idFileSystem,st.st_dev); SIVAL(pdata,l1_cSectorUnit,bsize/512); SIVAL(pdata,l1_cUnit,dsize); @@ -1163,7 +1163,7 @@ static int call_trans2qfsinfo(connection_struct *conn, { SMB_BIG_UINT dfree,dsize,bsize; data_len = 24; - sys_disk_free(".",&bsize,&dfree,&dsize); + sys_disk_free(".",False,&bsize,&dfree,&dsize); SBIG_UINT(pdata,0,dsize); SBIG_UINT(pdata,8,dfree); SIVAL(pdata,16,bsize/512); -- cgit