diff options
Diffstat (limited to 'sysdeps/common/fsusage.c')
-rw-r--r-- | sysdeps/common/fsusage.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/sysdeps/common/fsusage.c b/sysdeps/common/fsusage.c index c0665523..f5d68df1 100644 --- a/sysdeps/common/fsusage.c +++ b/sysdeps/common/fsusage.c @@ -75,9 +75,9 @@ int safe_read (); BLOCKS FROMSIZE-byte blocks, rounding away from zero. TOSIZE must be positive. Return -1 if FROMSIZE is not positive. */ -static long +static u_int64_t adjust_blocks (blocks, fromsize, tosize) - long blocks; + u_int64_t blocks; int fromsize, tosize; { if (tosize <= 0) @@ -88,9 +88,9 @@ adjust_blocks (blocks, fromsize, 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); + return blocks * (u_int64_t)(fromsize / tosize); else /* e.g., from 256 to 512 */ - return (blocks + (blocks < 0 ? -1 : 1)) / (tosize / fromsize); + return (blocks + (blocks < 0 ? -1 : 1)) / (u_int64_t)(tosize / fromsize); } /* Fill in the fields of FSP with information about space usage for @@ -107,7 +107,7 @@ get_fs_usage (path, disk, fsp) struct fs_usage *fsp; { #ifdef STAT_STATFS3_OSF1 -# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512) +# define CONVERT_BLOCKS(B) adjust_blocks ((u_int64_t)(B), fsd.f_fsize, 512) struct statfs fsd; @@ -117,7 +117,7 @@ get_fs_usage (path, disk, fsp) #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 ((u_int64_t)(B), 1024, 512) struct fs_data fsd; @@ -136,7 +136,7 @@ get_fs_usage (path, disk, fsp) # define SUPERBOFF (SUPERB * 512) # endif # define CONVERT_BLOCKS(B) \ - adjust_blocks ((B), (fsd.s_type == Fs2b ? 1024 : 512), 512) + adjust_blocks ((u_int64_t)(B), (fsd.s_type == Fs2b ? 1024 : 512), 512) struct filsys fsd; int fd; @@ -166,7 +166,7 @@ get_fs_usage (path, disk, fsp) #endif /* STAT_READ_FILSYS */ #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 ((u_int64_t)(B), fsd.f_bsize, 512) struct statfs fsd; @@ -191,7 +191,7 @@ get_fs_usage (path, disk, fsp) #endif /* STAT_STATFS2_BSIZE */ #ifdef STAT_STATFS2_FSIZE /* 4.4BSD */ -# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512) +# define CONVERT_BLOCKS(B) adjust_blocks ((u_int64_t)(B), fsd.f_fsize, 512) struct statfs fsd; @@ -202,7 +202,7 @@ get_fs_usage (path, disk, fsp) #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 ((u_int64_t)(B), fsd.f_bsize, 512) # ifdef _CRAY # define f_bavail f_bfree # endif @@ -227,7 +227,7 @@ get_fs_usage (path, disk, fsp) #ifdef STAT_STATVFS /* SVR4 */ # define CONVERT_BLOCKS(B) \ - adjust_blocks ((B), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512) + adjust_blocks ((u_int64_t)(B), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512) struct statvfs fsd; @@ -289,6 +289,7 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, glibtop_init_r (&server, 0, 0); memset (buf, 0, sizeof (glibtop_fsusage)); + memset (&fsp, 0, sizeof (struct fs_usage)); if (get_fs_usage (disk, disk, &fsp)) return; |