From f96d190facbbd33b09163b77ba4e681ca48a5d17 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sun, 1 Aug 2010 12:18:46 +0000 Subject: Lookup jail size from file system if directory matches a mount. --- tools/jail-measure.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 */ +#include "config.h" + #include #include +#include +#include #include #include @@ -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); -- cgit v1.2.3