diff options
author | Vivek Goyal <vgoyal@redhat.com> | 2018-08-14 21:37:02 +0200 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2018-10-10 10:49:48 +0100 |
commit | e164f3ddb59716fac1243b018d6fe035d6b5779c (patch) | |
tree | cd2264bf52dc3353b2361be6c572da2168a825c6 /example | |
parent | 4a92a82f2e2ca8889a0874847cd970e678461f12 (diff) | |
download | libfuse-e164f3ddb59716fac1243b018d6fe035d6b5779c.tar.gz |
passthrough_ll: add source option
Right now, passthrough_ll will use "/" as source directory for passthrough.
We need more flexibility where user can specify path of directory to be
passed through. Hence add an option "source=<source-dir>".
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'example')
-rw-r--r-- | example/passthrough_ll.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/example/passthrough_ll.c b/example/passthrough_ll.c index 400d004..0c496de 100644 --- a/example/passthrough_ll.c +++ b/example/passthrough_ll.c @@ -79,6 +79,7 @@ struct lo_data { pthread_mutex_t mutex; int debug; int writeback; + const char *source; struct lo_inode root; /* protected by lo->mutex */ }; @@ -87,6 +88,9 @@ static const struct fuse_opt lo_opts[] = { offsetof(struct lo_data, writeback), 1 }, { "no_writeback", offsetof(struct lo_data, writeback), 0 }, + { "source=%s", + offsetof(struct lo_data, source), 0 }, + FUSE_OPT_END }; @@ -937,10 +941,23 @@ int main(int argc, char *argv[]) lo.debug = opts.debug; lo.root.refcount = 2; + if (lo.source) { + struct stat stat; + int res; + + res = lstat(lo.source, &stat); + if (res == -1) + err(1, "failed to stat source (\"%s\")", lo.source); + if (!S_ISDIR(stat.st_mode)) + errx(1, "source is not a directory"); + + } else { + lo.source = "/"; + } lo.root.is_symlink = false; - lo.root.fd = open("/", O_PATH); + lo.root.fd = open(lo.source, O_PATH); if (lo.root.fd == -1) - err(1, "open(\"/\", O_PATH)"); + err(1, "open(\"%s\", O_PATH)", lo.source); se = fuse_session_new(&args, &lo_oper, sizeof(lo_oper), &lo); if (se == NULL) |