From 521a8860132424de1e8fd319c071eacafc51bb2f Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Mon, 18 Jun 2001 22:24:04 +0000 Subject: [PATCH] * utilunix.c (init_my_statfs): Move this ... * util.c (my_statfs): ... and this ... * mountlist.c: ... here. * util.h: Move mountlist-related declarations ... * mountlist.h: ... here. * info.c: Include mountlist.h. --- src/ChangeLog | 9 ++++++ src/info.c | 1 + src/mountlist.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++-- src/mountlist.h | 16 ++++++++++ src/util.c | 9 ------ src/util.h | 15 --------- src/utilunix.c | 70 ----------------------------------------- 7 files changed, 108 insertions(+), 96 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index eb1351636..ef398a606 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2001-06-18 Pavel Roskin + + * utilunix.c (init_my_statfs): Move this ... + * util.c (my_statfs): ... and this ... + * mountlist.c: ... here. + * util.h: Move mountlist-related declarations ... + * mountlist.h: ... here. + * info.c: Include mountlist.h. + 2001-06-17 David Martin * hotlist.c (init_movelist): Don't assume English word ordering diff --git a/src/info.c b/src/info.c index 5a1ab4681..a13049d9c 100644 --- a/src/info.c +++ b/src/info.c @@ -34,6 +34,7 @@ #include "layout.h" #include "key.h" /* is_idle() */ #include "x.h" +#include "mountlist.h" #ifndef VERSION # define VERSION "undefined" diff --git a/src/mountlist.c b/src/mountlist.c index ba4b0eba3..af8888f36 100644 --- a/src/mountlist.c +++ b/src/mountlist.c @@ -22,8 +22,6 @@ #include #include -#include "mountlist.h" - #ifdef STDC_HEADERS #include #else @@ -84,6 +82,10 @@ void free (void *ptr); #include #endif +#include "mountlist.h" +#include "fsusage.h" +#include "util.h" + /* void error (void); FIXME -- needed? */ #ifdef DOLPHIN @@ -97,6 +99,8 @@ void free (void *ptr); No prefix (like '0x') or suffix (like 'h') is expected to be part of CP. */ +static struct mount_entry *mount_list = NULL; + static int xatoi (char *cp) { int val; @@ -535,3 +539,79 @@ struct mount_entry *read_filesystem_list(int need_fs_type, int all_fs) } #endif /* __QNX__ */ +void init_my_statfs (void) +{ +#ifndef NO_INFOMOUNT + mount_list = read_filesystem_list (1, 1); +#endif +} + +void my_statfs (struct my_statfs *myfs_stats, char *path) +{ + int i, len = 0; + +#ifndef NO_INFOMOUNT + struct mount_entry *entry = NULL; + struct mount_entry *temp = mount_list; + struct fs_usage fs_use; + + while (temp){ + i = strlen (temp->me_mountdir); + if (i > len && (strncmp (path, temp->me_mountdir, i) == 0)) + if (!entry || (path [i] == PATH_SEP || path [i] == 0)){ + len = i; + entry = temp; + } + temp = temp->me_next; + } + + if (entry){ + get_fs_usage (entry->me_mountdir, &fs_use); + + myfs_stats->type = entry->me_dev; + myfs_stats->typename = entry->me_type; + myfs_stats->mpoint = entry->me_mountdir; + myfs_stats->device = entry->me_devname; + myfs_stats->avail = getuid () ? fs_use.fsu_bavail/2 : fs_use.fsu_bfree/2; + myfs_stats->total = fs_use.fsu_blocks/2; + myfs_stats->nfree = fs_use.fsu_ffree; + myfs_stats->nodes = fs_use.fsu_files; + } else +#endif +#if defined(NO_INFOMOUNT) && defined(__QNX__) +/* +** This is the "other side" of the hack to read_filesystem_list() in +** mountlist.c. +** It's not the most efficient approach, but consumes less memory. It +** also accomodates QNX's ability to mount filesystems on the fly. +*/ + struct mount_entry *entry; + struct fs_usage fs_use; + + if ((entry = read_filesystem_list(0, 0)) != NULL) + { + get_fs_usage(entry->me_mountdir, &fs_use); + + myfs_stats->type = entry->me_dev; + myfs_stats->typename = entry->me_type; + myfs_stats->mpoint = entry->me_mountdir; + myfs_stats->device = entry->me_devname; + + myfs_stats->avail = fs_use.fsu_bfree / 2; + myfs_stats->total = fs_use.fsu_blocks / 2; + myfs_stats->nfree = fs_use.fsu_ffree; + myfs_stats->nodes = fs_use.fsu_files; + } + else +#endif + { + myfs_stats->type = 0; + myfs_stats->mpoint = "unknown"; + myfs_stats->device = "unknown"; + myfs_stats->avail = 0; + myfs_stats->total = 0; + myfs_stats->nfree = 0; + myfs_stats->nodes = 0; + } +} + diff --git a/src/mountlist.h b/src/mountlist.h index 0dea1d80b..2c9dc2304 100644 --- a/src/mountlist.h +++ b/src/mountlist.h @@ -29,4 +29,20 @@ struct mount_entry }; struct mount_entry *read_filesystem_list (int need_fs_type, int all_fs); + +/* Filesystem status */ +struct my_statfs { + int type; + char *typename; + char *mpoint; + char *device; + int avail; + int total; + int nfree; + int nodes; +}; + +void init_my_statfs (void); +void my_statfs (struct my_statfs *myfs_stats, char *path); + #endif /* __MOUNTLIST_H */ diff --git a/src/util.c b/src/util.c index 649a0a32e..e9d7d1c97 100644 --- a/src/util.c +++ b/src/util.c @@ -91,8 +91,6 @@ int easy_patterns = 1; int align_extensions = 1; int tilde_trunc = 1; -struct mount_entry *mount_list = NULL; - #ifndef VFS_STANDALONE int is_printable (int c) { @@ -814,13 +812,6 @@ long blocks2kilos (int blocks, int bsize) return blocks; } -void init_my_statfs (void) -{ -#ifndef NO_INFOMOUNT - mount_list = read_filesystem_list (1, 1); -#endif -} - char *skip_separators (char *s) { for (;*s; s++) diff --git a/src/util.h b/src/util.h index 4615c5455..8650456a8 100644 --- a/src/util.h +++ b/src/util.h @@ -125,21 +125,6 @@ char *get_current_wd (char *buffer, int size); int my_mkdir (char *s, mode_t mode); int my_rmdir (char *s); -/* Filesystem status */ -struct my_statfs { - int type; - char *typename; - char *mpoint; - char *device; - int avail; - int total; - int nfree; - int nodes; -}; - -void init_my_statfs (void); -void my_statfs (struct my_statfs *myfs_stats, char *path); - /* Rotating dash routines */ void use_dash (int flag); /* Disable/Enable rotate_dash routines */ void rotate_dash (void); diff --git a/src/utilunix.c b/src/utilunix.c index 4a729ece4..e43e23586 100644 --- a/src/utilunix.c +++ b/src/utilunix.c @@ -69,7 +69,6 @@ #include "x.h" struct sigaction startup_handler; -extern struct mount_entry *mount_list; uid_t current_user_uid; user_in_groups *current_user_gid; @@ -763,75 +762,6 @@ putenv (const char *string) } #endif /* !HAVE_PUTENV */ -void my_statfs (struct my_statfs *myfs_stats, char *path) -{ - int i, len = 0; - -#ifndef NO_INFOMOUNT - struct mount_entry *entry = NULL; - struct mount_entry *temp = mount_list; - struct fs_usage fs_use; - - while (temp){ - i = strlen (temp->me_mountdir); - if (i > len && (strncmp (path, temp->me_mountdir, i) == 0)) - if (!entry || (path [i] == PATH_SEP || path [i] == 0)){ - len = i; - entry = temp; - } - temp = temp->me_next; - } - - if (entry){ - get_fs_usage (entry->me_mountdir, &fs_use); - - myfs_stats->type = entry->me_dev; - myfs_stats->typename = entry->me_type; - myfs_stats->mpoint = entry->me_mountdir; - myfs_stats->device = entry->me_devname; - myfs_stats->avail = getuid () ? fs_use.fsu_bavail/2 : fs_use.fsu_bfree/2; - myfs_stats->total = fs_use.fsu_blocks/2; - myfs_stats->nfree = fs_use.fsu_ffree; - myfs_stats->nodes = fs_use.fsu_files; - } else -#endif -#if defined(NO_INFOMOUNT) && defined(__QNX__) -/* -** This is the "other side" of the hack to read_filesystem_list() in -** mountlist.c. -** It's not the most efficient approach, but consumes less memory. It -** also accomodates QNX's ability to mount filesystems on the fly. -*/ - struct mount_entry *entry; - struct fs_usage fs_use; - - if ((entry = read_filesystem_list(0, 0)) != NULL) - { - get_fs_usage(entry->me_mountdir, &fs_use); - - myfs_stats->type = entry->me_dev; - myfs_stats->typename = entry->me_type; - myfs_stats->mpoint = entry->me_mountdir; - myfs_stats->device = entry->me_devname; - - myfs_stats->avail = fs_use.fsu_bfree / 2; - myfs_stats->total = fs_use.fsu_blocks / 2; - myfs_stats->nfree = fs_use.fsu_ffree; - myfs_stats->nodes = fs_use.fsu_files; - } - else -#endif - { - myfs_stats->type = 0; - myfs_stats->mpoint = "unknown"; - myfs_stats->device = "unknown"; - myfs_stats->avail = 0; - myfs_stats->total = 0; - myfs_stats->nfree = 0; - myfs_stats->nodes = 0; - } -} - #ifdef HAVE_GET_PROCESS_STATS # include