]> git.tuebingen.mpg.de Git - adu.git/commitdiff
Implement --one-file-system (-x).
authorAndre Noll <maan@systemlinux.org>
Sun, 1 Jun 2008 13:18:56 +0000 (15:18 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 1 Jun 2008 13:18:56 +0000 (15:18 +0200)
adu.c
adu.ggo

diff --git a/adu.c b/adu.c
index 97d55e115774a1373791b5a4fa0f7c1e89df8510..dad9d8c17f83db81d62ef4116f181fd394320825 100644 (file)
--- 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 bb8e2a6ef123788ac47f135d4d1a96b3391747b0..0875bad73bdd16adb0b868a5b6627a594f5fe7b7 100644 (file)
--- 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"