From d9b45dcaca85d050b0da1f0f08d9b045a1c6f4da Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 1 Jun 2008 15:18:56 +0200 Subject: [PATCH] Implement --one-file-system (-x). --- adu.c | 16 ++++++++++++++-- adu.ggo | 9 +++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/adu.c b/adu.c index 97d55e1..dad9d8c 100644 --- a/adu.c +++ b/adu.c @@ -576,6 +576,9 @@ static uint64_t num_dirs; static uint64_t num_files; static uint64_t num_bytes; +/* id of the device containing the base dir. */ +static dev_t device_id; + static int scan_dir(char *dirname, uint64_t *parent_dir_num) { DIR *dir; @@ -613,6 +616,8 @@ static int scan_dir(char *dirname, uint64_t *parent_dir_num) if (!S_ISREG(m) && !S_ISDIR(m)) continue; if (S_ISDIR(m)) { + if (conf.one_file_system_given && s.st_dev != device_id) + continue; ret = scan_dir(entry->d_name, &this_dir_num); if (ret < 0) goto out; @@ -1113,8 +1118,15 @@ static int open_dir_table(void) static int com_create() { uint64_t zero = 0ULL; - int ret = create_tables(); - + int ret; + struct stat statbuf; + + if (lstat(conf.base_dir_arg, &statbuf) == -1) + return -ERRNO_TO_ERROR(errno); + if (!S_ISDIR(statbuf.st_mode)) + return -ERRNO_TO_ERROR(ENOTDIR); + device_id = statbuf.st_dev; + ret = create_tables(); if (ret < 0) return ret; check_signals(); diff --git a/adu.ggo b/adu.ggo index bb8e2a6..0875bad 100644 --- a/adu.ggo +++ b/adu.ggo @@ -133,6 +133,15 @@ details=" will be ignored when computing statistics. " +option "one-file-system" x +#~~~~~~~~~~~~~~~~~~~~~~~~~ +"do not dive into other file systems" +flag off +dependon="create" +details=" + Skip directories that are on different filesystems from the + one that the argument being processed is on. +" ############################## section "Options for --select" -- 2.39.2