diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/jail-measure.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tools/jail-measure.c b/tools/jail-measure.c index 9c57ded..55a34b1 100644 --- a/tools/jail-measure.c +++ b/tools/jail-measure.c @@ -35,8 +35,12 @@ * Stef Walter <stef@memberwebs.com> */ +#include "config.h" + #include <sys/types.h> #include <sys/stat.h> +#include <sys/param.h> +#include <sys/mount.h> #include <err.h> #include <errno.h> @@ -97,7 +101,7 @@ check_skip_link (FTSENT *f) } static void -measure_jail (const char *path) +iterate_jail_fs (const char *path) { const char *paths[2] = { path, NULL }; FTS *fts; @@ -105,6 +109,7 @@ measure_jail (const char *path) jail_blocks = 0; jail_bytes = 0; + hsh_clear (jail_inodes); fts = fts_open ((char**)paths, FTS_COMFOLLOW | FTS_PHYSICAL | FTS_XDEV, NULL); @@ -141,6 +146,21 @@ measure_jail (const char *path) } fts_close (fts); +} + +static void +measure_jail (const char *path) +{ + struct statfs sf; + + /* See if this is a mount point, and if not iterate all files */ + if (statfs (path, &sf) != 0 || strcmp (path, sf.f_mntonname) != 0) { + iterate_jail_fs (path); + + } else { + jail_files = sf.f_files - sf.f_ffree; + jail_blocks = sf.f_blocks - sf.f_bfree; + } printf ("jail-space: %llu %s\n", (long long unsigned)(jail_blocks * 512), path); printf ("jail-files: %llu %s\n", (long long unsigned)jail_files, path); |