]> git.tuebingen.mpg.de Git - adu.git/blobdiff - adu.c
Implement --one-file-system (-x).
[adu.git] / adu.c
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();