diff options
author | Pavel Polacek <xpolish@gmail.com> | 2020-10-31 00:14:00 +0100 |
---|---|---|
committer | Andreas Gruenbacher <agruenba@redhat.com> | 2020-11-14 20:45:37 +0100 |
commit | a966a2b55bb13e22d9b1e6da8182655948d209ae (patch) | |
tree | 932893cdf22457d3c6f69f7dfafe78e3feedefcb | |
parent | 33564fd260d5b1c01dff3d2a26cba09c714eb4f7 (diff) | |
download | acl-a966a2b55bb13e22d9b1e6da8182655948d209ae.tar.gz |
getfacl: Add --one-file-system optionnext
Add a --one-filesystem option to getfacl. With this option, getfacl will not
cross mount points, similar to "tar --one-file-system".
(Patch modified by Andreas Gruenbacher.)
-rw-r--r-- | include/walk_tree.h | 1 | ||||
-rw-r--r-- | libmisc/walk_tree.c | 10 | ||||
-rw-r--r-- | tools/getfacl.c | 6 |
3 files changed, 17 insertions, 0 deletions
diff --git a/include/walk_tree.h b/include/walk_tree.h index 9f1ec34..b19ec23 100644 --- a/include/walk_tree.h +++ b/include/walk_tree.h @@ -25,6 +25,7 @@ #define WALK_TREE_LOGICAL 0x04 #define WALK_TREE_DEREFERENCE 0x08 #define WALK_TREE_DEREFERENCE_TOPLEVEL 0x10 +#define WALK_TREE_ONE_FILESYSTEM 0x20 #define WALK_TREE_TOPLEVEL 0x100 #define WALK_TREE_SYMLINK 0x200 diff --git a/libmisc/walk_tree.c b/libmisc/walk_tree.c index e712dcb..97e574c 100644 --- a/libmisc/walk_tree.c +++ b/libmisc/walk_tree.c @@ -48,6 +48,7 @@ struct walk_tree_args { struct entry_handle *closed; unsigned int num_dir_handles; struct stat st; + dev_t dev; }; static int walk_tree_visited(struct entry_handle *dirs, dev_t dev, ino_t ino) @@ -80,6 +81,14 @@ static int walk_tree_rec(struct walk_tree_args *args) if (lstat(args->path, &args->st) != 0) return args->func(args->path, NULL, flags | WALK_TREE_FAILED, args->arg); + + if (flags & WALK_TREE_ONE_FILESYSTEM) { + if (args->dev == 0) + args->dev = args->st.st_dev; + else if (args->st.st_dev != args->dev) + return 0; + } + if (S_ISLNK(args->st.st_mode)) { flags |= WALK_TREE_SYMLINK; if ((flags & WALK_TREE_DEREFERENCE) || @@ -243,6 +252,7 @@ int walk_tree(const char *path, int walk_flags, unsigned int num, args.func = func; args.arg = arg; args.depth = 0; + args.dev = 0; return walk_tree_rec(&args); } diff --git a/tools/getfacl.c b/tools/getfacl.c index e3df09c..aec08d8 100644 --- a/tools/getfacl.c +++ b/tools/getfacl.c @@ -59,6 +59,7 @@ struct option long_options[] = { { "tabular", 0, 0, 't' }, { "absolute-names", 0, 0, 'p' }, { "numeric", 0, 0, 'n' }, + { "one-file-system", 0, 0, 1 }, #endif { "default", 0, 0, 'd' }, { "version", 0, 0, 'v' }, @@ -588,6 +589,7 @@ void help(void) " -P, --physical physical walk, do not follow symbolic links\n" " -t, --tabular use tabular output format\n" " -n, --numeric print numeric user/group identifiers\n" +" --one-file-system skip files on different filesystems\n" " -p, --absolute-names don't strip leading '/' in pathnames\n")); } #endif @@ -699,6 +701,10 @@ int main(int argc, char *argv[]) print_options |= TEXT_NUMERIC_IDS; break; + case 1: /* one filesystem */ + walk_flags |= WALK_TREE_ONE_FILESYSTEM; + break; + case 'v': /* print version */ printf("%s " VERSION "\n", progname); return 0; |