summaryrefslogtreecommitdiff
path: root/source3/smbd/dfree.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-09-17 23:06:57 +0000
committerJeremy Allison <jra@samba.org>1998-09-17 23:06:57 +0000
commitb8b67f4fab4a6fd686c5796c2701882197a7bd9d (patch)
tree3f465f69a283a44e5c8414a3326f53caea4664d0 /source3/smbd/dfree.c
parentac9b687cc2496409e1c8d86393812faf94ec7550 (diff)
downloadsamba-b8b67f4fab4a6fd686c5796c2701882197a7bd9d.tar.gz
samba-b8b67f4fab4a6fd686c5796c2701882197a7bd9d.tar.bz2
samba-b8b67f4fab4a6fd686c5796c2701882197a7bd9d.zip
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)
Diffstat (limited to 'source3/smbd/dfree.c')
-rw-r--r--source3/smbd/dfree.c40
1 files changed, 17 insertions, 23 deletions
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));
}
-
-