diff options
author | Bernd Schubert <bernd.schubert@fastmail.fm> | 2010-06-01 20:24:43 +0200 |
---|---|---|
committer | Bernd Schubert <bernd.schubert@fastmail.fm> | 2010-06-01 20:24:43 +0200 |
commit | 483d9ae51c59d4a45ec2144f2d69ae85b3e31cab (patch) | |
tree | 5b3df0bfaeacc036c87adff9ff823397a74f0219 /src | |
parent | 180329d563bc61ab71e84e290062458f2ced15d2 (diff) | |
download | unionfs-fuse-483d9ae51c59d4a45ec2144f2d69ae85b3e31cab.tar.gz |
Also hide fuse meta files. Note: -o hide_meta_dir is now deprecated in favour of -o hide_meta_files
Thanks go to Wolf Geldmacher <wolf@womaro.ch> in Ubuntu bug 587917 for reporting this issue.
Diffstat (limited to 'src')
-rw-r--r-- | src/opts.c | 10 | ||||
-rw-r--r-- | src/opts.h | 3 | ||||
-rw-r--r-- | src/readdir.c | 19 | ||||
-rw-r--r-- | src/unionfs.c | 1 | ||||
-rw-r--r-- | src/unionfs.h | 4 |
5 files changed, 27 insertions, 10 deletions
@@ -232,8 +232,9 @@ static void print_help(const char *progname) { " mountpoint\n" " -d Enable debug output\n" " -o debug_file file to write debug information into\n" - " -o hide_meta_dir \".unionfs\" is a secret directory not\n" - " print by readdir()\n" + " -o hide_meta_files \".unionfs\" is a secret directory not\n" + " visible by readdir(), and so are\n" + " .fuse_hidden* files\n" " -o max_files=number Increase the maximum number of open files\n" " -o relaxed_permissions Disable permissions checks, but only if\n" " running neither as UID=0 or GID=0\n" @@ -319,8 +320,11 @@ int unionfs_opt_proc(void *data, const char *arg, int key, struct fuse_args *out fuse_opt_add_arg(outargs, "-ho"); uopt.doexit = 1; return 0; + case KEY_HIDE_META_FILES: + uopt.hide_meta_files = true; + return 0; case KEY_HIDE_METADIR: - uopt.hide_meta_dir = true; + uopt.hide_meta_files = true; return 0; case KEY_MAX_FILES: set_max_open_files(arg); @@ -28,7 +28,7 @@ typedef struct { char *chroot; // chroot we might go into bool debug; // enable debugging char *dbgpath; // debug file we write debug information into - bool hide_meta_dir; + bool hide_meta_files; bool relaxed_permissions; } uopt_t; @@ -39,6 +39,7 @@ enum { KEY_DEBUG, KEY_DEBUG_FILE, KEY_HELP, + KEY_HIDE_META_FILES, KEY_HIDE_METADIR, KEY_MAX_FILES, KEY_NOINITGROUPS, diff --git a/src/readdir.c b/src/readdir.c index d5c3d01..cc1c072 100644 --- a/src/readdir.c +++ b/src/readdir.c @@ -33,22 +33,29 @@ /** - * Hide our METADIR (.unionfs). As is causes a slight slowndown this is optional + * Hide metadata. As is causes a slight slowndown this is optional + * */ -static bool hide_meta_dir(int branch, const char *path, struct dirent *de) +static bool hide_meta_files(int branch, const char *path, struct dirent *de) { - if (uopt.hide_meta_dir == false) return false; + if (uopt.hide_meta_files == false) return false; fprintf(stderr, "uopt.branches[branch].path = %s path = %s\n", uopt.branches[branch].path, path); fprintf(stderr, "METANAME = %s, de->d_name = %s\n", METANAME, de->d_name); - // TODO Would it be faster to add hash comparison here? + // TODO Would it be faster to add hash comparison? + + // HIDE out .unionfs directory if (strcmp(uopt.branches[branch].path, path) == 0 && strcmp(METANAME, de->d_name) == 0) { return true; } + // HIDE fuse META files + if (strncmp(FUSE_META_FILE, de->d_name, FUSE_META_LENGTH) == 0) + return true; + return false; } @@ -154,7 +161,7 @@ int unionfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t o if (hashtable_search(whiteouts, de->d_name) != NULL) continue; } - if (hide_meta_dir(i, p, de) == true) continue; + if (hide_meta_files(i, p, de) == true) continue; // fill with something dummy, we're interested in key existence only hashtable_insert(files, strdup(de->d_name), malloc(1)); @@ -241,7 +248,7 @@ int dir_not_empty(const char *path) { if (hashtable_search(whiteouts, de->d_name) != NULL) continue; } - if (hide_meta_dir(i, p, de) == true) continue; + if (hide_meta_files(i, p, de) == true) continue; // When we arrive here, a valid entry was found not_empty = 1; diff --git a/src/unionfs.c b/src/unionfs.c index 55eda85..cd58a83 100644 --- a/src/unionfs.c +++ b/src/unionfs.c @@ -58,6 +58,7 @@ static struct fuse_opt unionfs_opts[] = { FUSE_OPT_KEY("--help", KEY_HELP), FUSE_OPT_KEY("-h", KEY_HELP), FUSE_OPT_KEY("hide_meta_dir", KEY_HIDE_METADIR), + FUSE_OPT_KEY("hide_meta_files", KEY_HIDE_META_FILES), FUSE_OPT_KEY("max_files=%s", KEY_MAX_FILES), FUSE_OPT_KEY("noinitgroups", KEY_NOINITGROUPS), FUSE_OPT_KEY("relaxed_permissions", KEY_RELAXED_PERMISSIONS), diff --git a/src/unionfs.h b/src/unionfs.h index 592a725..74b824f 100644 --- a/src/unionfs.h +++ b/src/unionfs.h @@ -13,6 +13,10 @@ #define METANAME ".unionfs" #define METADIR (METANAME "/") // string concetanation! +// fuse meta files, we might want to hide those +#define FUSE_META_FILE ".fuse_hidden" +#define FUSE_META_LENGTH 12 + // file access protection mask #define S_PROT_MASK (S_ISUID| S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) |