From 3c7c79944c1990a219cbe79b2998e2e4faf11259 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Tue, 9 Mar 2004 23:29:48 +0000 Subject: [PATCH] - oopsie, forgot some files --- sysdeps/common/README.fsusage | 9 +++++ sysdeps/common/fsusage-frontend.c | 67 +++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 sysdeps/common/README.fsusage create mode 100644 sysdeps/common/fsusage-frontend.c diff --git a/sysdeps/common/README.fsusage b/sysdeps/common/README.fsusage new file mode 100644 index 00000000..9c2edf0d --- /dev/null +++ b/sysdeps/common/README.fsusage @@ -0,0 +1,9 @@ +The files fsusage.c and fsusage.h have been stolen from the GNU +Coreutils package (version 5.0) and are the actual implementation of +the fsusage function. + +The only changes that have been made to these files is that some code +for SVR2 has been ripped out since it depended on some more code (SVR3 +was released in 1986 and introduced shared libraries), and the +functions have been prefixed with glibtop_private to avoid name +clashes with user code. diff --git a/sysdeps/common/fsusage-frontend.c b/sysdeps/common/fsusage-frontend.c new file mode 100644 index 00000000..c1d35cbf --- /dev/null +++ b/sysdeps/common/fsusage-frontend.c @@ -0,0 +1,67 @@ +/* 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 +#endif + +#if HAVE_CONFIG_H +# include +#endif + +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif +#ifndef UINTMAX_MAX +# define UINTMAX_MAX ((uintmax_t) -1) +#endif + +#include "fsusage.h" + +#include +#include +#include + +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; +}