From 0964c3d2ffaf7a31b1aec6eefb521a5fcf5ea38b Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 7 Sep 2004 02:00:59 +0000 Subject: [PATCH] file_system_list impl --- src/os/osf1/osf1_sigar.c | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/os/osf1/osf1_sigar.c b/src/os/osf1/osf1_sigar.c index ba08f460..7ca66988 100644 --- a/src/os/osf1/osf1_sigar.c +++ b/src/os/osf1/osf1_sigar.c @@ -3,6 +3,9 @@ #include "sigar_os.h" #include "sigar_util.h" +#include +#include + int sigar_os_open(sigar_t **sigar) { *sigar = malloc(sizeof(**sigar)); @@ -237,11 +240,53 @@ int sigar_os_fs_type_get(sigar_file_system_t *fsp) return SIGAR_OK; } +static int sigar_fsstat(struct statfs **fs, int *num) +{ + int size; + + if ((*num = getfsstat(NULL, 0, MNT_WAIT)) < 0) { + return errno; + } + + size = ((*num)+1) * sizeof(struct statfs); + + *fs = malloc(size); + + if ((*num = getfsstat(*fs, size, MNT_WAIT)) < 0) { + free(fs); + return errno; + } + + return SIGAR_OK; +} + int sigar_file_system_list_get(sigar_t *sigar, sigar_file_system_list_t *fslist) { + int i, num, status; + struct statfs *fs; + + if ((status = sigar_fsstat(&fs, &num)) != SIGAR_OK) { + return status; + } + sigar_file_system_list_create(fslist); + for (i=0; idata[fslist->number++]; + + SIGAR_SSTRCPY(fsp->dir_name, fs[i].f_mntonname); + SIGAR_SSTRCPY(fsp->dev_name, fs[i].f_mntfromname); + SIGAR_SSTRCPY(fsp->sys_type_name, mnt_names[fs[i].f_type]); + sigar_fs_type_init(fsp); + } + + free(fs); + return SIGAR_OK; }