Removed files.
* Makefile.am: * fsusage-frontend.c: * fsusage.h: Removed files. * fsusage.c: (glibtop_get_fsusage_s), (statfs): Merged and cleaned.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2004-06-12 Benoît Dejean <tazforever@dlfp.org>
|
||||
|
||||
* Makefile.am:
|
||||
* fsusage-frontend.c:
|
||||
* fsusage.h: Removed files.
|
||||
|
||||
* fsusage.c: (glibtop_get_fsusage_s), (statfs): Merged and cleaned.
|
||||
|
||||
2004-06-12 Benoît Dejean <tazforever@dlfp.org>
|
||||
|
||||
* mountlist.c: (xatoi) Removed, replaced by ISO strtoull.
|
||||
|
@@ -14,7 +14,7 @@ CFLAGS = @CFLAGS@ $(inodedb_DEFS)
|
||||
noinst_LTLIBRARIES = libgtop_common-2.0.la libgtop_suid_common-2.0.la
|
||||
|
||||
libgtop_common_2_0_la_SOURCES = error.c gnuslib.c \
|
||||
fsusage.c fsusage.h fsusage-frontend.c \
|
||||
fsusage.c \
|
||||
mountlist.c mountlist.h \
|
||||
$(inodedb_SRCLIST)
|
||||
|
||||
|
@@ -1,67 +0,0 @@
|
||||
/* fsusage-frontend.c -- return space usage of mounted filesystems.
|
||||
|
||||
Copyright (C) 2003 Ole Laursen.
|
||||
|
||||
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This code is simply a front-end for the actual code in fsusage.[ch] which
|
||||
is stolen directly from the GNU Coreutils package. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#else
|
||||
# if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
# endif
|
||||
#endif
|
||||
#ifndef UINTMAX_MAX
|
||||
# define UINTMAX_MAX ((uintmax_t) -1)
|
||||
#endif
|
||||
|
||||
#include "fsusage.h"
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/error.h>
|
||||
#include <glibtop/fsusage.h>
|
||||
|
||||
void
|
||||
glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf,
|
||||
const char *disk)
|
||||
{
|
||||
struct fs_usage fsp;
|
||||
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_fsusage));
|
||||
memset (&fsp, 0, sizeof (struct fs_usage));
|
||||
|
||||
if (glibtop_private_get_fs_usage (disk, disk, &fsp) != 0)
|
||||
return;
|
||||
|
||||
buf->blocks = fsp.fsu_blocks;
|
||||
buf->bfree = fsp.fsu_bfree;
|
||||
buf->bavail = fsp.fsu_bavail;
|
||||
buf->files = fsp.fsu_files;
|
||||
buf->ffree = fsp.fsu_ffree;
|
||||
buf->block_size = fsp.fsu_blocksize;
|
||||
}
|
@@ -20,9 +20,11 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/fsusage.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "fsusage.h"
|
||||
|
||||
#if HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
@@ -99,17 +101,30 @@ int statvfs ();
|
||||
Return 0 if successful, -1 if not. When returning -1, ensure that
|
||||
ERRNO is either a system error value, or zero if DISK is NULL
|
||||
on a system that requires a non-NULL value. */
|
||||
int
|
||||
glibtop_private_get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp)
|
||||
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_fsusage =
|
||||
(1L << GLIBTOP_FSUSAGE_BLOCKS) + (1L << GLIBTOP_FSUSAGE_BFREE)
|
||||
+ (1L << GLIBTOP_FSUSAGE_BAVAIL) + (1L << GLIBTOP_FSUSAGE_FILES)
|
||||
+ (1L << GLIBTOP_FSUSAGE_FFREE) + (1L << GLIBTOP_FSUSAGE_BLOCK_SIZE);
|
||||
|
||||
|
||||
void
|
||||
glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf,
|
||||
const char *path)
|
||||
{
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
memset (buf, 0, sizeof (glibtop_fsusage));
|
||||
|
||||
#ifdef STAT_STATFS3_OSF1
|
||||
|
||||
struct statfs fsd;
|
||||
|
||||
if (statfs (path, &fsd, sizeof (struct statfs)) != 0)
|
||||
return -1;
|
||||
return;
|
||||
|
||||
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
|
||||
buf->block_size = PROPAGATE_ALL_ONES (fsd.f_fsize);
|
||||
|
||||
#endif /* STAT_STATFS3_OSF1 */
|
||||
|
||||
@@ -118,15 +133,15 @@ glibtop_private_get_fs_usage (const char *path, const char *disk, struct fs_usag
|
||||
struct fs_data fsd;
|
||||
|
||||
if (statfs (path, &fsd) != 1)
|
||||
return -1;
|
||||
return;
|
||||
|
||||
fsp->fsu_blocksize = 1024;
|
||||
fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.fd_req.btot);
|
||||
fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.fd_req.bfree);
|
||||
fsp->fsu_bavail = PROPAGATE_TOP_BIT (fsd.fd_req.bfreen);
|
||||
fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.fd_req.bfreen) != 0;
|
||||
fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.fd_req.gtot);
|
||||
fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.fd_req.gfree);
|
||||
buf->block_size = 1024;
|
||||
buf->blocks = PROPAGATE_ALL_ONES (fsd.fd_req.btot);
|
||||
buf->bfree = PROPAGATE_ALL_ONES (fsd.fd_req.bfree);
|
||||
buf->bavail = PROPAGATE_TOP_BIT (fsd.fd_req.bfreen);
|
||||
// buf->bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.fd_req.bfreen) != 0;
|
||||
buf->files = PROPAGATE_ALL_ONES (fsd.fd_req.gtot);
|
||||
buf->ffree = PROPAGATE_ALL_ONES (fsd.fd_req.gfree);
|
||||
|
||||
#endif /* STAT_STATFS2_FS_DATA */
|
||||
|
||||
@@ -135,9 +150,9 @@ glibtop_private_get_fs_usage (const char *path, const char *disk, struct fs_usag
|
||||
struct statfs fsd;
|
||||
|
||||
if (statfs (path, &fsd) < 0)
|
||||
return -1;
|
||||
return;
|
||||
|
||||
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_bsize);
|
||||
buf->block_size = PROPAGATE_ALL_ONES (fsd.f_bsize);
|
||||
|
||||
# ifdef STATFS_TRUNCATES_BLOCK_COUNTS
|
||||
|
||||
@@ -161,9 +176,9 @@ glibtop_private_get_fs_usage (const char *path, const char *disk, struct fs_usag
|
||||
struct statfs fsd;
|
||||
|
||||
if (statfs (path, &fsd) < 0)
|
||||
return -1;
|
||||
return;
|
||||
|
||||
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
|
||||
buf->block_size = PROPAGATE_ALL_ONES (fsd.f_fsize);
|
||||
|
||||
#endif /* STAT_STATFS2_FSIZE */
|
||||
|
||||
@@ -176,15 +191,15 @@ glibtop_private_get_fs_usage (const char *path, const char *disk, struct fs_usag
|
||||
struct statfs fsd;
|
||||
|
||||
if (statfs (path, &fsd, sizeof fsd, 0) < 0)
|
||||
return -1;
|
||||
return;
|
||||
|
||||
/* 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. */
|
||||
# if _AIX || defined _CRAY
|
||||
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_bsize);
|
||||
buf->block_size = PROPAGATE_ALL_ONES (fsd.f_bsize);
|
||||
# else
|
||||
fsp->fsu_blocksize = 512;
|
||||
buf->block_size = 512;
|
||||
# endif
|
||||
|
||||
#endif /* STAT_STATFS4 */
|
||||
@@ -194,10 +209,10 @@ glibtop_private_get_fs_usage (const char *path, const char *disk, struct fs_usag
|
||||
struct statvfs fsd;
|
||||
|
||||
if (statvfs (path, &fsd) < 0)
|
||||
return -1;
|
||||
return;
|
||||
|
||||
/* f_frsize isn't guaranteed to be supported. */
|
||||
fsp->fsu_blocksize = (fsd.f_frsize
|
||||
buf->block_size = (fsd.f_frsize
|
||||
? PROPAGATE_ALL_ONES (fsd.f_frsize)
|
||||
: PROPAGATE_ALL_ONES (fsd.f_bsize));
|
||||
|
||||
@@ -206,23 +221,23 @@ glibtop_private_get_fs_usage (const char *path, const char *disk, struct fs_usag
|
||||
#if !defined STAT_STATFS2_FS_DATA && !defined STAT_READ_FILSYS
|
||||
/* !Ultrix && !SVR2 */
|
||||
|
||||
fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.f_blocks);
|
||||
fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.f_bfree);
|
||||
fsp->fsu_bavail = PROPAGATE_TOP_BIT (fsd.f_bavail);
|
||||
fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.f_bavail) != 0;
|
||||
fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.f_files);
|
||||
fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.f_ffree);
|
||||
buf->blocks = PROPAGATE_ALL_ONES (fsd.f_blocks);
|
||||
buf->bfree = PROPAGATE_ALL_ONES (fsd.f_bfree);
|
||||
buf->bavail = PROPAGATE_TOP_BIT (fsd.f_bavail);
|
||||
// buf->bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.f_bavail) != 0;
|
||||
buf->files = PROPAGATE_ALL_ONES (fsd.f_files);
|
||||
buf->ffree = PROPAGATE_ALL_ONES (fsd.f_ffree);
|
||||
|
||||
#endif /* not STAT_STATFS2_FS_DATA && not STAT_READ_FILSYS */
|
||||
|
||||
return 0;
|
||||
buf->flags= _glibtop_sysdeps_fsusage;
|
||||
}
|
||||
|
||||
#if defined _AIX && defined _I386
|
||||
/* AIX PS/2 does not supply statfs. */
|
||||
|
||||
static int
|
||||
statfs (char *path, struct statfs *fsb)
|
||||
statfs (const char *path, struct statfs *fsb)
|
||||
{
|
||||
struct stat stats;
|
||||
struct dustat fsd;
|
||||
|
@@ -1,47 +0,0 @@
|
||||
/* fsusage.h -- declarations for filesystem space usage info
|
||||
Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
|
||||
|
||||
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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* Space usage statistics for a filesystem. Blocks are 512-byte. */
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#if !defined FSUSAGE_H_
|
||||
# define FSUSAGE_H_
|
||||
|
||||
struct fs_usage
|
||||
{
|
||||
int fsu_blocksize; /* Size of a block. */
|
||||
guint64 fsu_blocks; /* Total blocks. */
|
||||
guint64 fsu_bfree; /* Free blocks available to superuser. */
|
||||
guint64 fsu_bavail; /* Free blocks available to non-superuser. */
|
||||
int fsu_bavail_top_bit_set; /* 1 if fsu_bavail represents a value < 0. */
|
||||
guint64 fsu_files; /* Total file nodes. */
|
||||
guint64 fsu_ffree; /* Free file nodes. */
|
||||
};
|
||||
|
||||
# ifndef PARAMS
|
||||
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
|
||||
# define PARAMS(Args) Args
|
||||
# else
|
||||
# define PARAMS(Args) ()
|
||||
# endif
|
||||
# endif
|
||||
|
||||
int glibtop_private_get_fs_usage PARAMS ((const char *path, const char *disk,
|
||||
struct fs_usage *fsp));
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user