1
1

* 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.
Этот коммит содержится в:
Pavel Roskin 2001-06-18 22:24:04 +00:00
родитель f76a2c4576
Коммит 521a886013
7 изменённых файлов: 108 добавлений и 96 удалений

Просмотреть файл

@ -1,3 +1,12 @@
2001-06-18 Pavel Roskin <proski@gnu.org>
* 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 <dmartina@excite.es>
* hotlist.c (init_movelist): Don't assume English word ordering

Просмотреть файл

@ -34,6 +34,7 @@
#include "layout.h"
#include "key.h" /* is_idle() */
#include "x.h"
#include "mountlist.h"
#ifndef VERSION
# define VERSION "undefined"

Просмотреть файл

@ -22,8 +22,6 @@
#include <stdio.h>
#include <sys/types.h>
#include "mountlist.h"
#ifdef STDC_HEADERS
#include <stdlib.h>
#else
@ -84,6 +82,10 @@ void free (void *ptr);
#include <sys/vfs.h>
#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;
}
}

Просмотреть файл

@ -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 */

Просмотреть файл

@ -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++)

Просмотреть файл

@ -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);

Просмотреть файл

@ -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 <sys/procstats.h>