From b8b67f4fab4a6fd686c5796c2701882197a7bd9d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 17 Sep 1998 23:06:57 +0000 Subject: configure configure.in: Added checks for statvfs64. Last bit of 64 bit widening (I hope :-). include/config.h.in: Added #undef STAT_STATVFS64. include/includes.h: Added SMB_STRUCT_STATVFS type, Changed SMB_BIG_INTEGER to SMB_BIG_UINT and SMB_BIG_INT types. include/smb.h: Added flag defines from CIFS spec. lib/debug.c: Fixed one more mode_t issue. lib/system.c: Added sys_statvfs wrapper. lib/util.c: Changed trim_string to use size_t. param/loadparm.c: Moved "blocking locks" into locking section. Alphabetised locking options. Question - shuld we do this for all options ? passdb/ldap.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT. passdb/nispass.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT. passdb/smbpass.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT. smbd/dfree.c: Changed to use 64 bit types if available. Moved to use unsigned types. smbd/dosmode.c: Fixed one more mode_t issue. smbd/negprot.c: Changed literals to be FLAG_ #defines. smbd/nttrans.c: Removed dead code. smbd/open.c: Changed disk_free call. smbd/process.c: Changed literals to be FLAG_ #defines. smbd/reply.c: Changed disk_free call. smbd/trans2.c: Fixed but in SMB_QUERY_FS_VOLUME_INFO call. Was using UNICODE - should use ascii. tests/summary.c: Added STAT_STATVFS64 check. Jeremy. (This used to be commit c512b1b91fb7f2a7a93b9033a33e06d966daadb4) --- source3/smbd/dfree.c | 40 +++++++++++++++++----------------------- source3/smbd/dosmode.c | 2 +- source3/smbd/negprot.c | 10 ++++++---- source3/smbd/nttrans.c | 3 +-- source3/smbd/open.c | 7 +++---- source3/smbd/process.c | 4 ++-- source3/smbd/reply.c | 2 +- source3/smbd/trans2.c | 23 ++++++++++++++++------- 8 files changed, 47 insertions(+), 44 deletions(-) (limited to 'source3/smbd') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 799ff6a24c..499d089260 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -27,10 +27,10 @@ extern int DEBUGLEVEL; /**************************************************************************** normalise for DOS usage ****************************************************************************/ -static void disk_norm(int *bsize,int *dfree,int *dsize) +static void disk_norm(SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { /* check if the disk is beyond the max disk size */ - int maxdisksize = lp_maxdisksize(); + SMB_BIG_UINT maxdisksize = lp_maxdisksize(); if (maxdisksize) { /* convert to blocks - and don't overflow */ maxdisksize = ((maxdisksize*1024)/(*bsize))*1024; @@ -58,19 +58,15 @@ static void disk_norm(int *bsize,int *dfree,int *dsize) /* Return the number of TOSIZE-byte blocks used by BLOCKS FROMSIZE-byte blocks, rounding away from zero. - TOSIZE must be positive. Return -1 if FROMSIZE is not positive. */ -static int adjust_blocks(int blocks, int fromsize, int tosize) +*/ +static SMB_BIG_UINT adjust_blocks(SMB_BIG_UINT blocks, SMB_BIG_UINT fromsize, SMB_BIG_UINT tosize) { - if (tosize <= 0 || fromsize <= 0) { - return -1; - } - if (fromsize == tosize) /* e.g., from 512 to 512 */ return blocks; else if (fromsize > tosize) /* e.g., from 2048 to 512 */ return blocks * (fromsize / tosize); else /* e.g., from 256 to 512 */ - return (blocks + (blocks < 0 ? -1 : 1)) / (tosize / fromsize); + return (blocks + 1) / (tosize / fromsize); } /* this does all of the system specific guff to get the free disk space. @@ -79,10 +75,10 @@ static int adjust_blocks(int blocks, int fromsize, int tosize) results are returned in *dfree and *dsize, in 512 byte units */ -static int fsusage(const char *path, int *dfree, int *dsize) +static int fsusage(const char *path, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) { #ifdef STAT_STATFS3_OSF1 -#define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512) +#define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_fsize, (SMB_BIG_UINT)512) struct statfs fsd; if (statfs (path, &fsd, sizeof (struct statfs)) != 0) @@ -90,7 +86,7 @@ static int fsusage(const char *path, int *dfree, int *dsize) #endif /* STAT_STATFS3_OSF1 */ #ifdef STAT_STATFS2_FS_DATA /* Ultrix */ -#define CONVERT_BLOCKS(B) adjust_blocks ((B), 1024, 512) +#define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)1024, (SMB_BIG_UINT)512) struct fs_data fsd; if (statfs (path, &fsd) != 1) @@ -101,7 +97,7 @@ static int fsusage(const char *path, int *dfree, int *dsize) #endif /* STAT_STATFS2_FS_DATA */ #ifdef STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */ -#define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_bsize, 512) +#define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_bsize, (SMB_BIG_UINT)512) struct statfs fsd; if (statfs (path, &fsd) < 0) @@ -123,7 +119,7 @@ static int fsusage(const char *path, int *dfree, int *dsize) #ifdef STAT_STATFS2_FSIZE /* 4.4BSD */ -#define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512) +#define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_fsize, (SMB_BIG_UINT)512) struct statfs fsd; @@ -133,12 +129,12 @@ static int fsusage(const char *path, int *dfree, int *dsize) #ifdef STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */ # if _AIX || defined(_CRAY) -# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_bsize, 512) +# define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_bsize, (SMB_BIG_UINT)512) # ifdef _CRAY # define f_bavail f_bfree # endif # else -# define CONVERT_BLOCKS(B) (B) +# define CONVERT_BLOCKS(B) ((SMB_BIG_UINT)B) # ifndef _SEQUENT_ /* _SEQUENT_ is DYNIX/ptx */ # ifndef DOLPHIN /* DOLPHIN 3.8.alfa/7.18 has f_bavail */ # define f_bavail f_bfree @@ -158,11 +154,11 @@ static int fsusage(const char *path, int *dfree, int *dsize) #ifdef STAT_STATVFS /* SVR4 */ # define CONVERT_BLOCKS(B) \ - adjust_blocks ((B), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512) + adjust_blocks ((SMB_BIG_UINT)(B), fsd.f_frsize ? (SMB_BIG_UINT)fsd.f_frsize : (SMB_BIG_UINT)fsd.f_bsize, (SMB_BIG_UINT)512) - struct statvfs fsd; + SMB_STRUCT_STATVFS fsd; - if (statvfs (path, &fsd) < 0) + if (sys_statvfs (path, &fsd) < 0) return -1; /* f_frsize isn't guaranteed to be supported. */ @@ -185,7 +181,7 @@ static int fsusage(const char *path, int *dfree, int *dsize) /**************************************************************************** return number of 1K blocks available on a path and total number ****************************************************************************/ -static int disk_free(char *path,int *bsize,int *dfree,int *dsize) +static SMB_BIG_UINT disk_free(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { int dfree_retval; @@ -223,9 +219,7 @@ static int disk_free(char *path,int *bsize,int *dfree,int *dsize) /**************************************************************************** wrap it to get filenames right ****************************************************************************/ -int sys_disk_free(char *path,int *bsize,int *dfree,int *dsize) +SMB_BIG_UINT sys_disk_free(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { return(disk_free(dos_to_unix(path,False),bsize,dfree,dsize)); } - - diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index c2c9cc2373..b74e11e643 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -143,7 +143,7 @@ int file_chmod(connection_struct *conn,char *fname,int dosmode,SMB_STRUCT_STAT * { SMB_STRUCT_STAT st1; int mask=0; - int tmp; + mode_t tmp; mode_t unixmode; if (!st) { diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c index e9dd4614c4..e79743cfd4 100644 --- a/source3/smbd/negprot.c +++ b/source3/smbd/negprot.c @@ -50,7 +50,8 @@ static int reply_coreplus(char *outbuf) int outsize = set_message(outbuf,13,0,True); SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support readbraw and writebraw (possibly) */ - CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */ + /* Reply, SMBlockread, SMBwritelock supported. */ + SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); SSVAL(outbuf,smb_vwv1,0x1); /* user level security, don't encrypt */ Protocol = PROTOCOL_COREPLUS; @@ -80,7 +81,8 @@ static int reply_lanman1(char *outbuf) Protocol = PROTOCOL_LANMAN1; - CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */ + /* Reply, SMBlockread, SMBwritelock supported. */ + SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); SSVAL(outbuf,smb_vwv2,max_recv); SSVAL(outbuf,smb_vwv3,lp_maxmux()); /* maxmux */ SSVAL(outbuf,smb_vwv4,1); @@ -138,7 +140,8 @@ static int reply_lanman2(char *outbuf) Protocol = PROTOCOL_LANMAN2; - CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */ + /* Reply, SMBlockread, SMBwritelock supported. */ + SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD); SSVAL(outbuf,smb_vwv2,max_recv); SSVAL(outbuf,smb_vwv3,lp_maxmux()); SSVAL(outbuf,smb_vwv4,1); @@ -417,4 +420,3 @@ int reply_negprot(connection_struct *conn, return(outsize); } - diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index d6d60c45cd..ca977c39dc 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -712,7 +712,7 @@ static int call_nt_transact_create(connection_struct *conn, int oplock_request = 0; mode_t unixmode; int pnum = -1; - int fmode=0,mtime=0,rmode=0; + int fmode=0,rmode=0; off_t file_len = 0; SMB_STRUCT_STAT sbuf; int smb_action = 0; @@ -834,7 +834,6 @@ static int call_nt_transact_create(connection_struct *conn, fmode = dos_mode(conn,fname,&sbuf); if(fmode == 0) fmode = FILE_ATTRIBUTE_NORMAL; - mtime = sbuf.st_mtime; if (fmode & aDIR) { close_file(fsp,False); diff --git a/source3/smbd/open.c b/source3/smbd/open.c index ad4dd9f52f..108ef814ee 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -444,13 +444,12 @@ static void open_file(files_struct *fsp,connection_struct *conn, if ((fd_ptr->fd >=0) && conn->printer && lp_minprintspace(SNUM(conn))) { pstring dname; - int dum1,dum2,dum3; + SMB_BIG_UINT dum1,dum2,dum3; char *p; pstrcpy(dname,fname); p = strrchr(dname,'/'); if (p) *p = 0; - if (sys_disk_free(dname,&dum1,&dum2,&dum3) < - lp_minprintspace(SNUM(conn))) { + if (sys_disk_free(dname,&dum1,&dum2,&dum3) < (SMB_BIG_UINT)lp_minprintspace(SNUM(conn))) { if(fd_attempt_close(fd_ptr) == 0) dos_unlink(fname); fsp->fd_ptr = 0; @@ -957,7 +956,7 @@ dev = %x, inode = %.0f\n", oplock_request, fname, (unsigned int)dev, (double)ino Open a directory from an NT SMB call. ****************************************************************************/ int open_directory(files_struct *fsp,connection_struct *conn, - char *fname, int smb_ofun, int unixmode, int *action) + char *fname, int smb_ofun, mode_t unixmode, int *action) { extern struct current_user current_user; SMB_STRUCT_STAT st; diff --git a/source3/smbd/process.c b/source3/smbd/process.c index b72178013d..1d6de37df0 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -501,9 +501,9 @@ void construct_reply_common(char *inbuf,char *outbuf) memcpy(outbuf+4,inbuf+4,4); CVAL(outbuf,smb_rcls) = SMB_SUCCESS; CVAL(outbuf,smb_reh) = 0; - CVAL(outbuf,smb_flg) = 0x80 | (CVAL(inbuf,smb_flg) & 0x8); /* bit 7 set + SCVAL(outbuf,smb_flg, FLAG_REPLY | (CVAL(inbuf,smb_flg) & FLAG_CASELESS_PATHNAMES)); /* bit 7 set means a reply */ - SSVAL(outbuf,smb_flg2,1); /* say we support long filenames */ + SSVAL(outbuf,smb_flg2,FLAGS2_LONG_PATH_COMPONENTS); /* say we support long filenames */ SSVAL(outbuf,smb_err,SMB_SUCCESS); SSVAL(outbuf,smb_tid,SVAL(inbuf,smb_tid)); SSVAL(outbuf,smb_pid,SVAL(inbuf,smb_pid)); diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index d7f29b60c6..93beb12af3 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -921,7 +921,7 @@ int reply_setatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size int reply_dskattr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) { int outsize = 0; - int dfree,dsize,bsize; + SMB_BIG_UINT dfree,dsize,bsize; sys_disk_free(".",&bsize,&dfree,&dsize); diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index fb93fd9e10..49687d4cca 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -1094,7 +1094,7 @@ static int call_trans2qfsinfo(connection_struct *conn, { case 1: { - int dfree,dsize,bsize; + SMB_BIG_UINT dfree,dsize,bsize; data_len = 18; sys_disk_free(".",&bsize,&dfree,&dsize); SIVAL(pdata,l1_idFileSystem,st.st_dev); @@ -1102,8 +1102,9 @@ static int call_trans2qfsinfo(connection_struct *conn, SIVAL(pdata,l1_cUnit,dsize); SIVAL(pdata,l1_cUnitAvail,dfree); SSVAL(pdata,l1_cbSector,512); - DEBUG(5,("call_trans2qfsinfo : bsize=%d, id=%x, cSectorUnit=%d, cUnit=%d, cUnitAvail=%d, cbSector=%d\n", - bsize, (unsigned)st.st_dev, bsize/512, dsize, dfree, 512)); + DEBUG(5,("call_trans2qfsinfo : bsize=%u, id=%x, cSectorUnit=%u, cUnit=%u, cUnitAvail=%u, cbSector=%d\n", + (unsigned int)bsize, (unsigned int)st.st_dev, ((unsigned int)bsize)/512, (unsigned int)dsize, + (unsigned int)dfree, 512)); break; } case 2: @@ -1132,6 +1133,7 @@ static int call_trans2qfsinfo(connection_struct *conn, SIVAL(pdata,4,128); /* Max filename component length */ SIVAL(pdata,8,2*strlen(FSTYPE_STRING)); PutUniCode(pdata+12,FSTYPE_STRING); + SSVAL(outbuf,smb_flg2,SVAL(outbuf,smb_flg2)|FLAGS2_UNICODE_STRINGS); break; case SMB_QUERY_FS_LABEL_INFO: data_len = 4 + strlen(vname); @@ -1139,20 +1141,27 @@ static int call_trans2qfsinfo(connection_struct *conn, pstrcpy(pdata+4,vname); break; case SMB_QUERY_FS_VOLUME_INFO: - data_len = 18 + 2*strlen(vname); + + /* + * NB: The earlier CIFS spec that says this always + * uses UNICODE is incorrect ! JRA. + */ + + data_len = 18 + strlen(vname); + /* * Add volume serial number - hash of a combination of * the called hostname and the service name. */ SIVAL(pdata,8,str_checksum(lp_servicename(snum)) ^ (str_checksum(local_machine)<<16) ); - SIVAL(pdata,12,2*strlen(vname)); - PutUniCode(pdata+18,vname); + SIVAL(pdata,12,strlen(vname)); + pstrcpy(pdata+18,vname); DEBUG(5,("call_trans2qfsinfo : SMB_QUERY_FS_VOLUME_INFO namelen = %d, vol = %s\n", strlen(vname), vname)); break; case SMB_QUERY_FS_SIZE_INFO: { - int dfree,dsize,bsize; + SMB_BIG_UINT dfree,dsize,bsize; data_len = 24; sys_disk_free(".",&bsize,&dfree,&dsize); SIVAL(pdata,0,dsize); -- cgit