From 64578c0589a3a741f81fb55c16eeb882128da00b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 29 Jul 1998 03:08:05 +0000 Subject: merge from the autoconf2 branch to the main branch (This used to be commit 3bda7ac417107a7b01d91805ca71c4330657ed21) --- source3/smbd/dfree.c | 231 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 source3/smbd/dfree.c (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c new file mode 100644 index 0000000000..799ff6a24c --- /dev/null +++ b/source3/smbd/dfree.c @@ -0,0 +1,231 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + functions to calculate the free disk space + Copyright (C) Andrew Tridgell 1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + + +extern int DEBUGLEVEL; + +/**************************************************************************** +normalise for DOS usage +****************************************************************************/ +static void disk_norm(int *bsize,int *dfree,int *dsize) +{ + /* check if the disk is beyond the max disk size */ + int maxdisksize = lp_maxdisksize(); + if (maxdisksize) { + /* convert to blocks - and don't overflow */ + maxdisksize = ((maxdisksize*1024)/(*bsize))*1024; + if (*dsize > maxdisksize) *dsize = maxdisksize; + if (*dfree > maxdisksize) *dfree = maxdisksize-1; + /* 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; + } + } +} + + +/* 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) +{ + 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); +} + +/* this does all of the system specific guff to get the free disk space. + It is derived from code in the GNU fileutils package, but has been + considerably mangled for use here + + results are returned in *dfree and *dsize, in 512 byte units +*/ +static int fsusage(const char *path, int *dfree, int *dsize) +{ +#ifdef STAT_STATFS3_OSF1 +#define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512) + struct statfs fsd; + + if (statfs (path, &fsd, sizeof (struct statfs)) != 0) + return -1; +#endif /* STAT_STATFS3_OSF1 */ + +#ifdef STAT_STATFS2_FS_DATA /* Ultrix */ +#define CONVERT_BLOCKS(B) adjust_blocks ((B), 1024, 512) + struct fs_data fsd; + + if (statfs (path, &fsd) != 1) + return -1; + + (*dsize) = CONVERT_BLOCKS (fsd.fd_req.btot); + (*dfree) = CONVERT_BLOCKS (fsd.fd_req.bfreen); +#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) + struct statfs fsd; + + if (statfs (path, &fsd) < 0) + return -1; + +#ifdef STATFS_TRUNCATES_BLOCK_COUNTS + /* In SunOS 4.1.2, 4.1.3, and 4.1.3_U1, the block counts in the + struct statfs are truncated to 2GB. These conditions detect that + truncation, presumably without botching the 4.1.1 case, in which + the values are not truncated. The correct counts are stored in + undocumented spare fields. */ + if (fsd.f_blocks == 0x1fffff && fsd.f_spare[0] > 0) { + fsd.f_blocks = fsd.f_spare[0]; + fsd.f_bfree = fsd.f_spare[1]; + fsd.f_bavail = fsd.f_spare[2]; + } +#endif /* STATFS_TRUNCATES_BLOCK_COUNTS */ +#endif /* STAT_STATFS2_BSIZE */ + + +#ifdef STAT_STATFS2_FSIZE /* 4.4BSD */ +#define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512) + + struct statfs fsd; + + if (statfs (path, &fsd) < 0) + return -1; +#endif /* STAT_STATFS2_FSIZE */ + +#ifdef STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */ +# if _AIX || defined(_CRAY) +# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_bsize, 512) +# ifdef _CRAY +# define f_bavail f_bfree +# endif +# else +# define CONVERT_BLOCKS(B) (B) +# ifndef _SEQUENT_ /* _SEQUENT_ is DYNIX/ptx */ +# ifndef DOLPHIN /* DOLPHIN 3.8.alfa/7.18 has f_bavail */ +# define f_bavail f_bfree +# endif +# endif +# endif + + struct statfs fsd; + + if (statfs (path, &fsd, sizeof fsd, 0) < 0) + return -1; + /* Empirically, the block counts on most SVR3 and SVR3-derived + systems seem to always be in terms of 512-byte blocks, + no matter what value f_bsize has. */ + +#endif /* STAT_STATFS4 */ + +#ifdef STAT_STATVFS /* SVR4 */ +# define CONVERT_BLOCKS(B) \ + adjust_blocks ((B), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512) + + struct statvfs fsd; + + if (statvfs (path, &fsd) < 0) + return -1; + /* f_frsize isn't guaranteed to be supported. */ + +#endif /* STAT_STATVFS */ + +#ifndef CONVERT_BLOCKS + /* we don't have any dfree code! */ + return -1; +#else +#if !defined(STAT_STATFS2_FS_DATA) + /* !Ultrix */ + (*dsize) = CONVERT_BLOCKS (fsd.f_blocks); + (*dfree) = CONVERT_BLOCKS (fsd.f_bavail); +#endif /* not STAT_STATFS2_FS_DATA */ +#endif + + return 0; +} + +/**************************************************************************** + return number of 1K blocks available on a path and total number +****************************************************************************/ +static int disk_free(char *path,int *bsize,int *dfree,int *dsize) +{ + int dfree_retval; + + (*dfree) = (*dsize) = 0; + (*bsize) = 512; + + fsusage(path, dfree, dsize); + + if (*bsize < 256) { + *bsize = 512; + } + + if ((*dsize)<1) { + static int done; + if (!done) { + DEBUG(0,("WARNING: dfree is broken on this system\n")); + done=1; + } + *dsize = 20*1024*1024/(*bsize); + *dfree = MAX(1,*dfree); + } + + disk_norm(bsize,dfree,dsize); + + if ((*bsize) < 1024) { + dfree_retval = (*dfree)/(1024/(*bsize)); + } else { + dfree_retval = ((*bsize)/1024)*(*dfree); + } + + return(dfree_retval); +} + + +/**************************************************************************** +wrap it to get filenames right +****************************************************************************/ +int sys_disk_free(char *path,int *bsize,int *dfree,int *dsize) +{ + return(disk_free(dos_to_unix(path,False),bsize,dfree,dsize)); +} + + -- cgit 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 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'source3/smbd/dfree.c') 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)); } - - -- cgit From d1a82e643b2e75db8e0c5afa7280ca383917ba64 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 18 Sep 1998 03:53:14 +0000 Subject: got rid of SMB_STRUCT_STATVFS. I don't think we should be defining structures that only apply on some platforms. (This used to be commit 926591067cd8646426ca06df0b00a1d6f6dd5752) --- source3/smbd/dfree.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 499d089260..c96a599e77 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -156,10 +156,14 @@ static int fsusage(const char *path, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) # define CONVERT_BLOCKS(B) \ 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) - SMB_STRUCT_STATVFS fsd; +#ifdef STAT_STATVFS64 + struct statvfs64 fsd; + if (statvfs64(path, &fsd) < 0) return -1; +#else + struct statvfs fsd; + if (statvfs(path, &fsd) < 0) return -1; +#endif - if (sys_statvfs (path, &fsd) < 0) - return -1; /* f_frsize isn't guaranteed to be supported. */ #endif /* STAT_STATVFS */ -- cgit From 4bd1feb68c4f5134293d87433da932c20cded915 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 6 Nov 1998 18:40:51 +0000 Subject: lib/charcnv.c: Improved debug comment. libsmb/namequery.c: Fix to remove 2 second wait is we are doing a unicast and got a reply. smbd/dfree.c: smbd/noquotas.c: smbd/quotas.c: Fixes from Dejan Ilic for the quota code. utils/smbpasswd.c: Fixes to allow smbpasswd to be called from swat. Jeremy. (This used to be commit b5981c0149ad8c6f13ea87db450080616538b5d5) --- source3/smbd/dfree.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index c96a599e77..020386645c 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -188,13 +188,24 @@ static int fsusage(const char *path, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) static SMB_BIG_UINT disk_free(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { int dfree_retval; + SMB_BIG_UINT dfree_q = 0; + SMB_BIG_UINT bsize_q = 0; + SMB_BIG_UINT dsize_q = 0; (*dfree) = (*dsize) = 0; (*bsize) = 512; fsusage(path, dfree, dsize); + if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) { + (*bsize) = bsize_q; + (*dfree) = MIN(*dfree,dfree_q); + (*dsize) = MIN(*dsize,dsize_q); + } + + /* FIXME : Any reason for this assumption ? */ if (*bsize < 256) { + DEBUG(5,("disk_free:Warning: bsize == %d < 256 . Changing to assumed correct bsize = 512\n",*bsize)); *bsize = 512; } -- cgit From 8c62b28e0ef1e012ebb0713701916d82ffc7661e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 9 Nov 1998 03:45:49 +0000 Subject: converted smbclient to use clientgen.c rather than clientutil.c I did this when I saw yet another bug report complaining about smbclient intermittently missing files. Rather than applying more patches to smbclient it was better to move to the more robust clientgen.c code. The conversion wasn't perfect, I probably lost some features of smbclient while doing it, but at least smbclient should be consistent now. It if fails it should _always_ fail rather than giving people the false impression of a reliable utility. the tar stuff seems to work, but hasn't had much testing as I never use it myself. I'm sure someone will find bugs in my conversion of smbtar.c. It was quite tricky as it did a lot of its own SMB calls. It now uses clientgen.c exclusively. smbclient is still quite messy, but at least it doesn't build its own SMB packets. I haven't touched smbmount as I never use it. Mike, do you want to convert smbmount to use clientgen.c? (This used to be commit e14ca7765ace1b721dad8eca4a527a4e4a8f1ab8) --- source3/smbd/dfree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 020386645c..8cba8d0644 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -205,7 +205,7 @@ static SMB_BIG_UINT disk_free(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree /* FIXME : Any reason for this assumption ? */ if (*bsize < 256) { - DEBUG(5,("disk_free:Warning: bsize == %d < 256 . Changing to assumed correct bsize = 512\n",*bsize)); + DEBUG(5,("disk_free:Warning: bsize == %d < 256 . Changing to assumed correct bsize = 512\n",(int)*bsize)); *bsize = 512; } -- cgit From 3db52feb1f3b2c07ce0b06ad4a7099fa6efe3fc7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:27:58 +0000 Subject: first pass at updating head branch to be to be the same as the SAMBA_2_0 branch (This used to be commit 453a822a76780063dff23526c35408866d0c0154) --- source3/smbd/dfree.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 8cba8d0644..86a155f526 100644 --- a/source3/smbd/dfree.c +++ b/source3/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 small_query, 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(small_query) { + /* + * Force max to fit in 16 bit fields. + */ + if (*bsize > (WORDMAX*512)) { + *bsize = (WORDMAX*512); + if (*dsize > WORDMAX) + *dsize = WORDMAX; + if (*dfree > WORDMAX) + *dfree = WORDMAX; + break; + } } } } @@ -152,7 +157,7 @@ static int fsusage(const char *path, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) #endif /* STAT_STATFS4 */ -#ifdef STAT_STATVFS /* SVR4 */ +#if defined(STAT_STATVFS) || defined(STAT_STATVFS64) /* SVR4 */ # define CONVERT_BLOCKS(B) \ 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) @@ -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 small_query, + 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(small_query,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 small_query, + 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),small_query, bsize,dfree,dsize)); } -- cgit From 8bd94c178ff108bbc6e686e33b99588876ab8a5a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 6 Jan 2000 01:41:27 +0000 Subject: Re-added "dfree command" functionality that was described in the man pages but was not in the code. Jeremy. (This used to be commit f4898a1f16a2dbc25d062b0088d6c589a34c93a0) --- source3/smbd/dfree.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 86a155f526..ddb91ab498 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -198,11 +198,58 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, SMB_BIG_UINT dfree_q = 0; SMB_BIG_UINT bsize_q = 0; SMB_BIG_UINT dsize_q = 0; + char *dfree_command; (*dfree) = (*dsize) = 0; (*bsize) = 512; - fsusage(path, dfree, dsize); + + /* + * If external disk calculation specified, use it. + */ + + dfree_command = lp_dfree_command(); + if (dfree_command && *dfree_command) { + pstring line; + char *p; + FILE *pp; + + snprintf (line, sizeof(pstring), "%s %s", dfree_command, path); + pp = popen(line, "r"); + if (pp) { + fgets(line, sizeof(pstring), pp); + line[sizeof(pstring)-1] = '\0'; + if (strlen(line) > 0) + line[strlen(line)-1] = '\0'; + + DEBUG (3, ("Read input from dfree, \"%s\"\n", line)); + + *dsize = (SMB_BIG_UINT)strtoul(line, &p, 10); + while (p && *p & isspace(*p)) + p++; + if (p && *p) + *dfree = (SMB_BIG_UINT)strtoul(p, &p, 10); + while (p && *p & isspace(*p)) + p++; + if (p && *p) + *bsize = (SMB_BIG_UINT)strtoul(p, NULL, 10); + else + *bsize = 1024; + pclose (pp); + DEBUG (3, ("Parsed output of dfree, dsize=%u, dfree=%u, bsize=%u\n", + (unsigned int)*dsize, (unsigned int)*dfree, (unsigned int)*bsize)); + + if (!*dsize) + *dsize = 2048; + if (!*dfree) + *dfree = 1024; + } else { + DEBUG (0, ("disk_free: popen() failed for command %s. Error was : %s\n", + line, strerror(errno) )); + fsusage(path, dfree, dsize); + } + } else + fsusage(path, dfree, dsize); if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) { (*bsize) = bsize_q; -- cgit From a2dac5f8f22ac58fbc3178e90288444f24190c8b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 12 Jan 2000 02:52:42 +0000 Subject: Use slprintf not snprintf. Jeremy. (This used to be commit b0a5ba9e01e71a64c7e693b6bf3f9bd499d3e095) --- source3/smbd/dfree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index ddb91ab498..bd06d3f235 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -214,7 +214,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, char *p; FILE *pp; - snprintf (line, sizeof(pstring), "%s %s", dfree_command, path); + slprintf (line, sizeof(pstring) - 1, "%s %s", dfree_command, path); pp = popen(line, "r"); if (pp) { fgets(line, sizeof(pstring), pp); -- cgit From 21df01ff7d8f520aa5de2b737bd84ba2460d76b8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 29 Jan 2000 00:23:40 +0000 Subject: Wrapped popen calls in HAVE_POPEN - needed if we are to add the env patch. Jeremy. (This used to be commit 94c075faee88538e48d1898f1694500b8a5d4c8b) --- source3/smbd/dfree.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index bd06d3f235..7838080461 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -208,6 +208,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, * If external disk calculation specified, use it. */ +#ifdef HAVE_POPEN dfree_command = lp_dfree_command(); if (dfree_command && *dfree_command) { pstring line; @@ -249,6 +250,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, fsusage(path, dfree, dsize); } } else +#endif /* HAVE_POPEN */ fsusage(path, dfree, dsize); if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) { -- cgit From 3cf31a194f5721b67b1255e3f168d4bc87d433fc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 15 Feb 2000 19:36:47 +0000 Subject: Added replacement functions sys_popen and sys_pclose. These are based on the glibc source code and are safer than the traditional popen as they don't use a shell to exec the requested command. Now we have these functions they can be tightened up (environment etc.) as required to make a safe popen. It should now be safe to add the environement variable loading code to loadparm.c Jeremy. (This used to be commit b52e92b09d4ca3b66e534f520468dee27065d048) --- source3/smbd/dfree.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 7838080461..7866d60277 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -208,7 +208,6 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, * If external disk calculation specified, use it. */ -#ifdef HAVE_POPEN dfree_command = lp_dfree_command(); if (dfree_command && *dfree_command) { pstring line; @@ -216,7 +215,9 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, FILE *pp; slprintf (line, sizeof(pstring) - 1, "%s %s", dfree_command, path); - pp = popen(line, "r"); + DEBUG (3, ("disk_free: Running command %s\n", line)); + + pp = sys_popen(line, "r"); if (pp) { fgets(line, sizeof(pstring), pp); line[sizeof(pstring)-1] = '\0'; @@ -236,7 +237,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, *bsize = (SMB_BIG_UINT)strtoul(p, NULL, 10); else *bsize = 1024; - pclose (pp); + sys_pclose (pp); DEBUG (3, ("Parsed output of dfree, dsize=%u, dfree=%u, bsize=%u\n", (unsigned int)*dsize, (unsigned int)*dfree, (unsigned int)*bsize)); @@ -245,12 +246,11 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, if (!*dfree) *dfree = 1024; } else { - DEBUG (0, ("disk_free: popen() failed for command %s. Error was : %s\n", + DEBUG (0, ("disk_free: sys_popen() failed for command %s. Error was : %s\n", line, strerror(errno) )); fsusage(path, dfree, dsize); } } else -#endif /* HAVE_POPEN */ fsusage(path, dfree, dsize); if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) { -- cgit From e601c0259e9e6a48e04ce3e0ff793cb564a89716 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 16 Mar 2000 20:55:37 +0000 Subject: Fixes to add "paranoid" option to popen. Checks some basic things. Jeremy (This used to be commit 3b8cbb10de322fd7a1063fb5b681790b10d24ab0) --- source3/smbd/dfree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 7866d60277..0a892bad05 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -217,7 +217,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, slprintf (line, sizeof(pstring) - 1, "%s %s", dfree_command, path); DEBUG (3, ("disk_free: Running command %s\n", line)); - pp = sys_popen(line, "r"); + pp = sys_popen(line, "r", False); if (pp) { fgets(line, sizeof(pstring), pp); line[sizeof(pstring)-1] = '\0'; -- cgit From 19f946ba6fe442544ac9b0f71bcd33112fc79995 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 16 Apr 2000 11:00:21 +0000 Subject: converted a bunch more functions to use a fd instead of a FILE* to support some of this I added the following functions in util_file.c file_lines_pload : load lines from a pipe file_pload : load a pipe into memory (This used to be commit a09470817c5b21dba42f9ef4ce5e8b768a254c0b) --- source3/smbd/dfree.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 0a892bad05..eff718b148 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -203,24 +203,22 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, (*dfree) = (*dsize) = 0; (*bsize) = 512; - /* * If external disk calculation specified, use it. */ dfree_command = lp_dfree_command(); if (dfree_command && *dfree_command) { - pstring line; char *p; - FILE *pp; + char **lines; + pstring syscmd; - slprintf (line, sizeof(pstring) - 1, "%s %s", dfree_command, path); - DEBUG (3, ("disk_free: Running command %s\n", line)); + slprintf(syscmd, sizeof(syscmd), "%s %s", dfree_command, path); + DEBUG (3, ("disk_free: Running command %s\n", syscmd)); - pp = sys_popen(line, "r", False); - if (pp) { - fgets(line, sizeof(pstring), pp); - line[sizeof(pstring)-1] = '\0'; + lines = file_lines_pload(syscmd, NULL); + if (lines) { + char *line = lines[0]; if (strlen(line) > 0) line[strlen(line)-1] = '\0'; @@ -237,7 +235,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, *bsize = (SMB_BIG_UINT)strtoul(p, NULL, 10); else *bsize = 1024; - sys_pclose (pp); + file_lines_free(lines); DEBUG (3, ("Parsed output of dfree, dsize=%u, dfree=%u, bsize=%u\n", (unsigned int)*dsize, (unsigned int)*dfree, (unsigned int)*bsize)); @@ -247,7 +245,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, *dfree = 1024; } else { DEBUG (0, ("disk_free: sys_popen() failed for command %s. Error was : %s\n", - line, strerror(errno) )); + syscmd, strerror(errno) )); fsusage(path, dfree, dsize); } } else -- cgit From f074d6ef57de28a2855fb2f8d3357ec46cbe8be0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 19 Apr 2000 08:23:13 +0000 Subject: split fsusage() into a separate module (to fix linking problems with spoolssd in tng) (This used to be commit e2eacdd74c369fbbcd118148149321e36f3d0010) --- source3/smbd/dfree.c | 129 +-------------------------------------------------- 1 file changed, 2 insertions(+), 127 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index eff718b148..ee5722acd5 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -61,131 +61,6 @@ static void disk_norm(BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree, } -/* Return the number of TOSIZE-byte blocks used by - BLOCKS FROMSIZE-byte blocks, rounding away from zero. -*/ -static SMB_BIG_UINT adjust_blocks(SMB_BIG_UINT blocks, SMB_BIG_UINT fromsize, SMB_BIG_UINT tosize) -{ - 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 + 1) / (tosize / fromsize); -} - -/* this does all of the system specific guff to get the free disk space. - It is derived from code in the GNU fileutils package, but has been - considerably mangled for use here - - results are returned in *dfree and *dsize, in 512 byte units -*/ -static int fsusage(const char *path, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) -{ -#ifdef STAT_STATFS3_OSF1 -#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) - return -1; -#endif /* STAT_STATFS3_OSF1 */ - -#ifdef STAT_STATFS2_FS_DATA /* Ultrix */ -#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) - return -1; - - (*dsize) = CONVERT_BLOCKS (fsd.fd_req.btot); - (*dfree) = CONVERT_BLOCKS (fsd.fd_req.bfreen); -#endif /* STAT_STATFS2_FS_DATA */ - -#ifdef STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */ -#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) - return -1; - -#ifdef STATFS_TRUNCATES_BLOCK_COUNTS - /* In SunOS 4.1.2, 4.1.3, and 4.1.3_U1, the block counts in the - struct statfs are truncated to 2GB. These conditions detect that - truncation, presumably without botching the 4.1.1 case, in which - the values are not truncated. The correct counts are stored in - undocumented spare fields. */ - if (fsd.f_blocks == 0x1fffff && fsd.f_spare[0] > 0) { - fsd.f_blocks = fsd.f_spare[0]; - fsd.f_bfree = fsd.f_spare[1]; - fsd.f_bavail = fsd.f_spare[2]; - } -#endif /* STATFS_TRUNCATES_BLOCK_COUNTS */ -#endif /* STAT_STATFS2_BSIZE */ - - -#ifdef STAT_STATFS2_FSIZE /* 4.4BSD */ -#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) < 0) - return -1; -#endif /* STAT_STATFS2_FSIZE */ - -#ifdef STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */ -# if _AIX || defined(_CRAY) -# 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) ((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 -# endif -# endif -# endif - - struct statfs fsd; - - if (statfs (path, &fsd, sizeof fsd, 0) < 0) - return -1; - /* Empirically, the block counts on most SVR3 and SVR3-derived - systems seem to always be in terms of 512-byte blocks, - no matter what value f_bsize has. */ - -#endif /* STAT_STATFS4 */ - -#if defined(STAT_STATVFS) || defined(STAT_STATVFS64) /* SVR4 */ -# define CONVERT_BLOCKS(B) \ - 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) - -#ifdef STAT_STATVFS64 - struct statvfs64 fsd; - if (statvfs64(path, &fsd) < 0) return -1; -#else - struct statvfs fsd; - if (statvfs(path, &fsd) < 0) return -1; -#endif - - /* f_frsize isn't guaranteed to be supported. */ - -#endif /* STAT_STATVFS */ - -#ifndef CONVERT_BLOCKS - /* we don't have any dfree code! */ - return -1; -#else -#if !defined(STAT_STATFS2_FS_DATA) - /* !Ultrix */ - (*dsize) = CONVERT_BLOCKS (fsd.f_blocks); - (*dfree) = CONVERT_BLOCKS (fsd.f_bavail); -#endif /* not STAT_STATFS2_FS_DATA */ -#endif - - return 0; -} /**************************************************************************** return number of 1K blocks available on a path and total number @@ -246,10 +121,10 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, } else { DEBUG (0, ("disk_free: sys_popen() failed for command %s. Error was : %s\n", syscmd, strerror(errno) )); - fsusage(path, dfree, dsize); + sys_fsusage(path, dfree, dsize); } } else - fsusage(path, dfree, dsize); + sys_fsusage(path, dfree, dsize); if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) { (*bsize) = bsize_q; -- cgit From cf5b71994d6cdb2f81c390579f4a0e676926c6b9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 7 Dec 2000 19:26:04 +0000 Subject: file_lines_load/file_lines_pload can now optionally convert unix_to_dos() on read. Jeremy. (This used to be commit 76b8dd376d13eb4469417be217c966d54d333367) --- source3/smbd/dfree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index ee5722acd5..c8c4437155 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -91,7 +91,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, slprintf(syscmd, sizeof(syscmd), "%s %s", dfree_command, path); DEBUG (3, ("disk_free: Running command %s\n", syscmd)); - lines = file_lines_pload(syscmd, NULL); + lines = file_lines_pload(syscmd, NULL, True); if (lines) { char *line = lines[0]; if (strlen(line) > 0) -- cgit From 40890119643b6a44ff381d50db4f446c334ce75e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 12 Dec 2000 19:44:50 +0000 Subject: Fixed processing of dfree script (was truncating). Jeremy. (This used to be commit 1e719a807669876b4d11f4653e9712f25fcba20b) --- source3/smbd/dfree.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index c8c4437155..c523f2cab4 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -94,8 +94,6 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, lines = file_lines_pload(syscmd, NULL, True); if (lines) { char *line = lines[0]; - if (strlen(line) > 0) - line[strlen(line)-1] = '\0'; DEBUG (3, ("Read input from dfree, \"%s\"\n", line)); -- cgit From f9a15ce1a69f905e94db7650f0a4805720cd9c88 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 8 Apr 2001 20:22:39 +0000 Subject: Got "medieval on our ass" about adding the -1 to slprintf. Jeremy. (This used to be commit 94747b4639ed9b19f7d0fb896e43aa392a84989a) --- source3/smbd/dfree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index c523f2cab4..64c6182cd8 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -88,7 +88,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, char **lines; pstring syscmd; - slprintf(syscmd, sizeof(syscmd), "%s %s", dfree_command, path); + slprintf(syscmd, sizeof(syscmd)-1, "%s %s", dfree_command, path); DEBUG (3, ("disk_free: Running command %s\n", syscmd)); lines = file_lines_pload(syscmd, NULL, True); -- cgit From 87fbb7092b8f8b2f0db0f361c3d625e19de57cd9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 4 Jul 2001 07:15:53 +0000 Subject: The big character set handling changeover! This commit gets rid of all our old codepage handling and replaces it with iconv. All internal strings in Samba are now in "unix" charset, which may be multi-byte. See internals.doc and my posting to samba-technical for a more complete explanation. (This used to be commit debb471267960e56005a741817ebd227ecfc512a) --- source3/smbd/dfree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 64c6182cd8..7848309a5e 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -66,7 +66,7 @@ static void disk_norm(BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree, return number of 1K blocks available on a path and total number ****************************************************************************/ -static SMB_BIG_UINT disk_free(char *path, BOOL small_query, +static SMB_BIG_UINT disk_free(const char *path, BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { int dfree_retval; @@ -91,7 +91,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, slprintf(syscmd, sizeof(syscmd)-1, "%s %s", dfree_command, path); DEBUG (3, ("disk_free: Running command %s\n", syscmd)); - lines = file_lines_pload(syscmd, NULL, True); + lines = file_lines_pload(syscmd, NULL); if (lines) { char *line = lines[0]; @@ -161,8 +161,8 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query, /**************************************************************************** wrap it to get filenames right ****************************************************************************/ -SMB_BIG_UINT sys_disk_free(char *path, BOOL small_query, +SMB_BIG_UINT sys_disk_free(const char *path, BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { - return(disk_free(dos_to_unix(path,False),small_query, bsize,dfree,dsize)); + return disk_free(path,small_query, bsize,dfree,dsize); } -- cgit From dc1fc3ee8ec2199bc73bb5d7ec711c6800f61d65 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Oct 2001 04:29:50 +0000 Subject: Removed 'extern int DEBUGLEVEL' as it is now in the smb.h header. (This used to be commit 2d0922b0eabfdc0aaf1d0797482fef47ed7fde8e) --- source3/smbd/dfree.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 7848309a5e..51f0614941 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -21,9 +21,6 @@ #include "includes.h" - -extern int DEBUGLEVEL; - /**************************************************************************** normalise for DOS usage ****************************************************************************/ -- cgit From 3ea349271355b39f7b877ce67530cc58e7db0ee8 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Tue, 23 Oct 2001 19:10:30 +0000 Subject: get rid of compiler warnings (casts and delete unused variables) (This used to be commit 51cb4411df61d1caec9d84809b1a53a6a632f808) --- source3/smbd/dfree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 51f0614941..13a3e86c6e 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -121,7 +121,7 @@ static SMB_BIG_UINT disk_free(const char *path, BOOL small_query, } else sys_fsusage(path, dfree, dsize); - if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) { + if (disk_quotas((char *)path, &bsize_q, &dfree_q, &dsize_q)) { (*bsize) = bsize_q; (*dfree) = MIN(*dfree,dfree_q); (*dsize) = MIN(*dsize,dsize_q); -- cgit From f8e2baf39eb864481dd48f61404136b325cd73c2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Nov 2001 23:34:24 +0000 Subject: Added NT_USER_TOKEN into server_info to fix extra groups problem. Got "medieval on our ass" about const warnings (as many as I could :-). Jeremy. (This used to be commit ee5e7ca547eff016818ba5c43b8ea0c9fa69b808) --- source3/smbd/dfree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 13a3e86c6e..51f0614941 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -121,7 +121,7 @@ static SMB_BIG_UINT disk_free(const char *path, BOOL small_query, } else sys_fsusage(path, dfree, dsize); - if (disk_quotas((char *)path, &bsize_q, &dfree_q, &dsize_q)) { + if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) { (*bsize) = bsize_q; (*dfree) = MIN(*dfree,dfree_q); (*dsize) = MIN(*dsize,dsize_q); -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/smbd/dfree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 51f0614941..71b3f2bf77 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -1,6 +1,5 @@ /* - Unix SMB/Netbios implementation. - Version 1.9. + Unix SMB/CIFS implementation. functions to calculate the free disk space Copyright (C) Andrew Tridgell 1998 -- cgit From e8573c8fa928602fd979d5ac45c692e7464f0aad Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Mon, 12 May 2003 01:20:17 +0000 Subject: Add NT quota support. Patch from Stefan (metze) Metzemacher 1. Allows to change quota settings for shared mount points from Win2K and WinXP from Explorer properties tab 2. Disabled by default and when requested, will be probed and enabled only on Linux where it works 3. Was tested for approx. two weeks now on Linux by two independent QA teams, have not found any bugs so far Documentation to follow (This used to be commit 4bf022ce9e45be85609426762ba2644ac2031326) --- source3/smbd/dfree.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 71b3f2bf77..f93cdf3791 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -80,7 +80,7 @@ static SMB_BIG_UINT disk_free(const char *path, BOOL small_query, dfree_command = lp_dfree_command(); if (dfree_command && *dfree_command) { - char *p; + const char *p; char **lines; pstring syscmd; @@ -93,15 +93,15 @@ static SMB_BIG_UINT disk_free(const char *path, BOOL small_query, DEBUG (3, ("Read input from dfree, \"%s\"\n", line)); - *dsize = (SMB_BIG_UINT)strtoul(line, &p, 10); - while (p && *p & isspace(*p)) + *dsize = STR_TO_SMB_BIG_UINT(line, &p); + while (p && *p && isspace(*p)) p++; if (p && *p) - *dfree = (SMB_BIG_UINT)strtoul(p, &p, 10); - while (p && *p & isspace(*p)) + *dfree = STR_TO_SMB_BIG_UINT(p, &p); + while (p && *p && isspace(*p)) p++; if (p && *p) - *bsize = (SMB_BIG_UINT)strtoul(p, NULL, 10); + *bsize = STR_TO_SMB_BIG_UINT(p, NULL); else *bsize = 1024; file_lines_free(lines); -- cgit From d09914d218c53b92ffcd4a276c3ce3f33ef5389f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 7 Feb 2005 22:06:49 +0000 Subject: r5268: Fix bug #2310, only do 16-bit normalization on small dfree request. Jeremy. (This used to be commit 96dfec739a7ab6ac082d530ca2b771f9d6acabc6) --- source3/smbd/dfree.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index f93cdf3791..c556c8c8ab 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -36,11 +36,11 @@ static void disk_norm(BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree, errors */ } - while (*dfree > WORDMAX || *dsize > WORDMAX || *bsize < 512) { - *dfree /= 2; - *dsize /= 2; - *bsize *= 2; - if(small_query) { + if(small_query) { + while (*dfree > WORDMAX || *dsize > WORDMAX || *bsize < 512) { + *dfree /= 2; + *dsize /= 2; + *bsize *= 2; /* * Force max to fit in 16 bit fields. */ -- cgit From 7dcbde86ae22379b67d0a571c93aa34b2a1311aa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 16 Mar 2005 01:41:21 +0000 Subject: r5822: Actually return an error message if disk_free fails ! Pointed out by Ying Li . Jeremy. (This used to be commit b5d31b2caf5c4739607bf57cb7e4e0569b57012b) --- source3/smbd/dfree.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index c556c8c8ab..81a48b94fc 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -115,10 +115,19 @@ static SMB_BIG_UINT disk_free(const char *path, BOOL small_query, } else { DEBUG (0, ("disk_free: sys_popen() failed for command %s. Error was : %s\n", syscmd, strerror(errno) )); - sys_fsusage(path, dfree, dsize); + if (sys_fsusage(path, dfree, dsize) != 0) { + DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n", + strerror(errno) )); + return (SMB_BIG_UINT)-1; + } + } + } else { + if (sys_fsusage(path, dfree, dsize) != 0) { + DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n", + strerror(errno) )); + return (SMB_BIG_UINT)-1; } - } else - sys_fsusage(path, dfree, dsize); + } if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) { (*bsize) = bsize_q; -- cgit From c6aea6ef2d97982263b1652b7c186df269bf0de6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 19 Oct 2005 20:02:12 +0000 Subject: r11190: Fix enhancement request #3192. This does 2 things. 1). Makes dfree command a per-share parameter (it should be anyway IMHO). 2). Adds a "dfree cache time" parameter in seconds that specifies how long a dfree command output should be cached for. Default is zero (no caching). Jeremy. (This used to be commit 49ef8b88a3e12883148eb28d8e86fb07dbc3d12d) --- source3/smbd/dfree.c | 63 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 10 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 81a48b94fc..dad7d917e8 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -21,8 +21,9 @@ #include "includes.h" /**************************************************************************** -normalise for DOS usage + Normalise for DOS usage. ****************************************************************************/ + static void disk_norm(BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { /* check if the disk is beyond the max disk size */ @@ -59,17 +60,17 @@ static void disk_norm(BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree, /**************************************************************************** - return number of 1K blocks available on a path and total number + Return number of 1K blocks available on a path and total number. ****************************************************************************/ -static SMB_BIG_UINT disk_free(const char *path, BOOL small_query, +SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { int dfree_retval; SMB_BIG_UINT dfree_q = 0; SMB_BIG_UINT bsize_q = 0; SMB_BIG_UINT dsize_q = 0; - char *dfree_command; + const char *dfree_command; (*dfree) = (*dsize) = 0; (*bsize) = 512; @@ -78,7 +79,7 @@ static SMB_BIG_UINT disk_free(const char *path, BOOL small_query, * If external disk calculation specified, use it. */ - dfree_command = lp_dfree_command(); + dfree_command = lp_dfree_command(SNUM(conn)); if (dfree_command && *dfree_command) { const char *p; char **lines; @@ -162,12 +163,54 @@ static SMB_BIG_UINT disk_free(const char *path, BOOL small_query, return(dfree_retval); } - /**************************************************************************** -wrap it to get filenames right + Potentially returned cached dfree info. ****************************************************************************/ -SMB_BIG_UINT sys_disk_free(const char *path, BOOL small_query, - SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) + +SMB_BIG_UINT get_dfree_info(connection_struct *conn, + const char *path, + BOOL small_query, + SMB_BIG_UINT *bsize, + SMB_BIG_UINT *dfree, + SMB_BIG_UINT *dsize) { - return disk_free(path,small_query, bsize,dfree,dsize); + int dfree_cache_time = lp_dfree_cache_time(SNUM(conn)); + struct dfree_cached_info *dfc = conn->dfree_info; + SMB_BIG_UINT dfree_ret; + + if (!dfree_cache_time) { + return SMB_VFS_DISK_FREE(conn,path,small_query,bsize,dfree,dsize); + } + + if (dfc && (conn->lastused - dfc->last_dfree_time < dfree_cache_time)) { + /* Return cached info. */ + *bsize = dfc->bsize; + *dfree = dfc->dfree; + *dsize = dfc->dsize; + return dfc->dfree_ret; + } + + dfree_ret = SMB_VFS_DISK_FREE(conn,path,small_query,bsize,dfree,dsize); + + if (dfree_ret == (SMB_BIG_UINT)-1) { + /* Don't cache bad data. */ + return dfree_ret; + } + + /* No cached info or time to refresh. */ + if (!dfc) { + dfc = TALLOC_P(conn->mem_ctx, struct dfree_cached_info); + if (!dfc) { + return dfree_ret; + } + conn->dfree_info = dfc; + } + + dfc->bsize = *bsize; + dfc->dfree = *dfree; + dfc->dsize = *dsize; + dfc->dfree_ret = dfree_ret; + dfc->last_dfree_time = conn->lastused; + + return dfree_ret; } -- cgit From 29b6971da7270a119adf7ed3818f540c89814973 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 15 Feb 2007 16:50:14 +0000 Subject: r21369: sys_disk_free return type is SMB_BIG_UINT. Fix dfree_retval to be SMB_BIG_UINT as well, otherwise we may wrap up on > 2T file systems. Simo. (This used to be commit 0bb7f6492ccf4a965d70d43ee1483959c71bcdba) --- source3/smbd/dfree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index dad7d917e8..c488add227 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -66,7 +66,7 @@ static void disk_norm(BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree, SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { - int dfree_retval; + SMB_BIG_UINT dfree_retval; SMB_BIG_UINT dfree_q = 0; SMB_BIG_UINT bsize_q = 0; SMB_BIG_UINT dsize_q = 0; -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/smbd/dfree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index c488add227..5eca7a85ab 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/smbd/dfree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 5eca7a85ab..2290558f0a 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From d5c9d87946263b5f3e3c072aa99e8ac6a6c728b9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 12 Sep 2007 23:50:21 +0000 Subject: r25118: More pstring elimination. Jeremy. (This used to be commit 7632f8fb4003657591778d2b55f546d1737859d1) --- source3/smbd/dfree.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 2290558f0a..9439468600 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -81,10 +81,18 @@ SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, BOOL small dfree_command = lp_dfree_command(SNUM(conn)); if (dfree_command && *dfree_command) { const char *p; - char **lines; - pstring syscmd; + char **lines = NULL; + char *syscmd = NULL; + + syscmd = talloc_asprintf(talloc_tos(), + "%s %s", + dfree_command, + path); + + if (!syscmd) { + return (SMB_BIG_UINT)-1; + } - slprintf(syscmd, sizeof(syscmd)-1, "%s %s", dfree_command, path); DEBUG (3, ("disk_free: Running command %s\n", syscmd)); lines = file_lines_pload(syscmd, NULL); -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/smbd/dfree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 9439468600..31eb9fbd60 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -23,7 +23,7 @@ Normalise for DOS usage. ****************************************************************************/ -static void disk_norm(BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) +static void disk_norm(bool small_query, 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(); @@ -62,7 +62,7 @@ static void disk_norm(BOOL small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree, Return number of 1K blocks available on a path and total number. ****************************************************************************/ -SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, BOOL small_query, +SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, bool small_query, SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize) { SMB_BIG_UINT dfree_retval; @@ -176,7 +176,7 @@ SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, BOOL small SMB_BIG_UINT get_dfree_info(connection_struct *conn, const char *path, - BOOL small_query, + bool small_query, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) -- cgit From e9e33adc7c959e5ccfd605dcc0456265e0cffc1d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 5 Dec 2007 20:58:25 +0100 Subject: int->bool (This used to be commit 874258195278bc8c6bb3011c153c5d646fff9e75) --- source3/smbd/dfree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 31eb9fbd60..9e7f18a130 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -150,10 +150,10 @@ SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, bool small } if ((*dsize)<1) { - static int done; + static bool done = false; if (!done) { DEBUG(0,("WARNING: dfree is broken on this system\n")); - done=1; + done=true; } *dsize = 20*1024*1024/(*bsize); *dfree = MAX(1,*dfree); -- cgit From d62563342e8c83d67dbcfb0c4b8e2ed886742006 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 28 Apr 2008 10:31:49 +0200 Subject: Remove connection_struct->mem_ctx, connection_struct is its own parent (This used to be commit 559180f7d30606d1999399d954ceedc798c669a4) --- source3/smbd/dfree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/dfree.c') diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 9e7f18a130..1ddcd48d40 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -206,7 +206,7 @@ SMB_BIG_UINT get_dfree_info(connection_struct *conn, /* No cached info or time to refresh. */ if (!dfc) { - dfc = TALLOC_P(conn->mem_ctx, struct dfree_cached_info); + dfc = TALLOC_P(conn, struct dfree_cached_info); if (!dfc) { return dfree_ret; } -- cgit