diff options
author | Martin Pärtel <martin.partel@gmail.com> | 2012-04-05 12:56:05 +0300 |
---|---|---|
committer | Martin Pärtel <martin.partel@gmail.com> | 2012-04-05 12:56:05 +0300 |
commit | 2ee96eccd49c8f7f722b6dc21b60147a6c4997ec (patch) | |
tree | 935773238e6a137bfa694bf23e664f9d9f41c8a1 | |
parent | cfb79b08a1e0b72b8d905b24b565485eef13bd3e (diff) | |
download | bindfs-2ee96eccd49c8f7f722b6dc21b60147a6c4997ec.tar.gz |
Made -ouse_ino and -oreaddir_ino the default to mirror inodes.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/bindfs.c | 4 | ||||
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rw-r--r-- | tests/readdir_inode.c | 36 | ||||
-rwxr-xr-x | tests/test_bindfs.rb | 23 |
6 files changed, 72 insertions, 0 deletions
@@ -29,4 +29,5 @@ Makefile # Products src/bindfs +tests/readdir_inode @@ -1,3 +1,8 @@ +2012-04-05 Martin Pärtel <martin dot partel at gmail dot com> + + * Made -ouse_ino and -oreaddir_ino the default to + mirror inodes. + 2012-03-26 Martin Pärtel <martin dot partel at gmail dot com> * Made --map affect chown/chgrp results. diff --git a/src/bindfs.c b/src/bindfs.c index 35b1b48..3bda72f 100644 --- a/src/bindfs.c +++ b/src/bindfs.c @@ -1501,6 +1501,10 @@ int main(int argc, char *argv[]) /* We want the kernel to do our access checks for us based on what getattr gives it. */ fuse_opt_add_arg(&args, "-odefault_permissions"); + /* We want to mirror inodes. */ + fuse_opt_add_arg(&args, "-ouse_ino"); + fuse_opt_add_arg(&args, "-oreaddir_ino"); + /* We need to disable the attribute cache whenever two users can see different attributes. For now, only mirroring can do that. */ if (is_mirroring_enabled()) { diff --git a/tests/Makefile.am b/tests/Makefile.am index 79b8dee..ce11f95 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,2 +1,5 @@ +noinst_PROGRAMS = readdir_inode +readdir_inode_SOURCES = readdir_inode.c + TESTS = test_bindfs.rb diff --git a/tests/readdir_inode.c b/tests/readdir_inode.c new file mode 100644 index 0000000..a216c7e --- /dev/null +++ b/tests/readdir_inode.c @@ -0,0 +1,36 @@ + +#include <stdio.h> +#include <sys/types.h> +#include <dirent.h> +#include <errno.h> + +int main(int argc, char* argv[]) +{ + DIR* dirp; + struct dirent* dent; + + if (argc != 2) { + fprintf(stderr, "Usage: readdir_inode dir\n"); + return 1; + } + + dirp = opendir(argv[1]); + if (dirp == NULL) { + perror("failed to open directory"); + return 2; + } + + dent = readdir(dirp); + while (dent != NULL) { + if (errno != 0) { + perror("failed to read directory entry"); + return 3; + } + printf("%llu %s\n", (unsigned long long)dent->d_ino, dent->d_name); + dent = readdir(dirp); + } + + closedir(dirp); + + return 0; +} diff --git a/tests/test_bindfs.rb b/tests/test_bindfs.rb index ef732ff..ff1ee24 100755 --- a/tests/test_bindfs.rb +++ b/tests/test_bindfs.rb @@ -41,6 +41,8 @@ $only_these_tests = ARGV unless ARGV.empty? $nobody_uid = nobody_uid = Etc.getpwnam('nobody').uid $nogroup_gid = nogroup_gid = Etc.getgrnam('nogroup').gid +$tests_dir = File.dirname(File.realpath(__FILE__)) + testenv("") do assert { File.basename(pwd) == TESTDIR_NAME } @@ -307,3 +309,24 @@ root_testenv("--map=0/1:@0/@1", :title => "--map and chown/chgrp") do assert { File.stat('mnt/file1').uid == 1 } assert { File.stat('mnt/file1').gid == 1 } end + +testenv("", :title => "preserves inode numbers") do + touch('src/file') + mkdir('src/dir') + assert { File.stat('mnt/file').ino == File.stat('src/file').ino } + assert { File.stat('mnt/dir').ino == File.stat('src/dir').ino } +end + +testenv("", :title => "has readdir inode numbers") do + touch('src/file') + mkdir('src/dir') + + inodes = {} + for line in `#{$tests_dir}/readdir_inode mnt`.split("\n").reject(&:empty?) + inode, name = line.split(" ") + inodes[name] = inode.to_i + end + + assert { inodes['file'] == File.stat('src/file').ino } + assert { inodes['dir'] == File.stat('src/dir').ino } +end |