From 39f2d9e66b76c701467bb211a0229ee63fced5a5 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 1 Apr 2009 00:11:34 +0000 Subject: [PATCH] Parse the FUSE library options. They aren't used yet, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29844 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../userlandfs/server/fuse/FUSEFileSystem.cpp | 4 +- .../userlandfs/server/fuse/FUSEFileSystem.h | 8 ++- .../userlandfs/server/fuse/Jamfile | 1 + .../userlandfs/server/fuse/fuse_api.h | 1 + .../userlandfs/server/fuse/fuse_config.c | 67 +++++++++++++++++++ .../userlandfs/server/fuse/fuse_config.h | 51 ++++++++++++++ .../userlandfs/server/fuse/fuse_main.cpp | 15 ++++- 7 files changed, 141 insertions(+), 6 deletions(-) create mode 100644 src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_config.c create mode 100644 src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_config.h diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/FUSEFileSystem.cpp b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/FUSEFileSystem.cpp index 0af54e2553..ec9f4570c5 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/FUSEFileSystem.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/FUSEFileSystem.cpp @@ -237,8 +237,8 @@ FUSEFileSystem::ExitClientFS(status_t status) status_t -FUSEFileSystem::FinishInitClientFS(const fuse_operations* ops, size_t opSize, - void* userData) +FUSEFileSystem::FinishInitClientFS(fuse_config* config, + const fuse_operations* ops, size_t opSize, void* userData) { PRINT(("FUSEFileSystem::FinishInitClientFS()\n")); fExitStatus = B_ERROR; diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/FUSEFileSystem.h b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/FUSEFileSystem.h index e1ebd97f5b..536ecaa9a6 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/FUSEFileSystem.h +++ b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/FUSEFileSystem.h @@ -10,6 +10,9 @@ #include "fuse_api.h" +struct fuse_config; + + namespace UserlandFS { class FUSEFileSystem : public FileSystem { @@ -38,8 +41,9 @@ public: status_t InitClientFS(const char* parameters); void ExitClientFS(status_t status); - status_t FinishInitClientFS(const fuse_operations* ops, - size_t opSize, void* userData); + status_t FinishInitClientFS(fuse_config* config, + const fuse_operations* ops, size_t opSize, + void* userData); private: class ArgumentVector; diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/Jamfile b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/Jamfile index db7eb06300..67d6c6ff12 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/Jamfile +++ b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/Jamfile @@ -21,6 +21,7 @@ DEFINES += _FILE_OFFSET_BITS=64 ; # the library providing the FUSE interface for add-ons SharedLibrary libuserlandfs_fuse.so : + fuse_config.c fuse_fs.cpp fuse_main.cpp fuse_opt.c diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_api.h b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_api.h index ebe13d2f0c..dca679f081 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_api.h +++ b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_api.h @@ -9,5 +9,6 @@ #include #include +#include #endif // USERLAND_FS_FUSE_FUSE_API_H diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_config.c b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_config.c new file mode 100644 index 0000000000..271cc07f2e --- /dev/null +++ b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_config.c @@ -0,0 +1,67 @@ +/* + FUSE: Filesystem in Userspace + Copyright (C) 2001-2007 Miklos Szeredi + + This program can be distributed under the terms of the GNU LGPLv2. + See the file COPYING.LIB +*/ + +#include "fuse_config.h" + + +enum { + KEY_HELP, +}; + +#define FUSE_LIB_OPT(t, p, v) { t, offsetof(struct fuse_config, p), v } + +static const struct fuse_opt fuse_lib_opts[] = { + FUSE_OPT_KEY("-h", KEY_HELP), + FUSE_OPT_KEY("--help", KEY_HELP), + FUSE_OPT_KEY("debug", FUSE_OPT_KEY_KEEP), + FUSE_OPT_KEY("-d", FUSE_OPT_KEY_KEEP), + FUSE_LIB_OPT("debug", debug, 1), + FUSE_LIB_OPT("-d", debug, 1), + FUSE_LIB_OPT("hard_remove", hard_remove, 1), + FUSE_LIB_OPT("use_ino", use_ino, 1), + FUSE_LIB_OPT("readdir_ino", readdir_ino, 1), + FUSE_LIB_OPT("direct_io", direct_io, 1), + FUSE_LIB_OPT("kernel_cache", kernel_cache, 1), + FUSE_LIB_OPT("auto_cache", auto_cache, 1), + FUSE_LIB_OPT("noauto_cache", auto_cache, 0), + FUSE_LIB_OPT("umask=", set_mode, 1), + FUSE_LIB_OPT("umask=%o", umask, 0), + FUSE_LIB_OPT("uid=", set_uid, 1), + FUSE_LIB_OPT("uid=%d", uid, 0), + FUSE_LIB_OPT("gid=", set_gid, 1), + FUSE_LIB_OPT("gid=%d", gid, 0), + FUSE_LIB_OPT("entry_timeout=%lf", entry_timeout, 0), + FUSE_LIB_OPT("attr_timeout=%lf", attr_timeout, 0), + FUSE_LIB_OPT("ac_attr_timeout=%lf", ac_attr_timeout, 0), + FUSE_LIB_OPT("ac_attr_timeout=", ac_attr_timeout_set, 1), + FUSE_LIB_OPT("negative_timeout=%lf", negative_timeout, 0), + FUSE_LIB_OPT("intr", intr, 1), + FUSE_LIB_OPT("intr_signal=%d", intr_signal, 0), + FUSE_LIB_OPT("modules=%s", modules, 0), + FUSE_OPT_END +}; + + +static int +fuse_lib_opt_proc(void *data, const char *arg, int key, + struct fuse_args *outargs) +{ + (void)data; + (void)arg; + (void)key; + (void)outargs; + + return 1; +} + + +int +fuse_parse_config_args(struct fuse_args* args, struct fuse_config* config) +{ + return fuse_opt_parse(args, config, fuse_lib_opts, fuse_lib_opt_proc) == 0; +} diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_config.h b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_config.h new file mode 100644 index 0000000000..456a639ee9 --- /dev/null +++ b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_config.h @@ -0,0 +1,51 @@ +/* + FUSE: Filesystem in Userspace + Copyright (C) 2001-2007 Miklos Szeredi + + This program can be distributed under the terms of the GNU LGPLv2. + See the file COPYING.LIB +*/ +#ifndef USERLAND_FS_FUSE_CONFIG_H +#define USERLAND_FS_FUSE_CONFIG_H + +#include "fuse_api.h" + + +struct fuse_config { + unsigned int uid; + unsigned int gid; + unsigned int umask; + double entry_timeout; + double negative_timeout; + double attr_timeout; + double ac_attr_timeout; + int ac_attr_timeout_set; + int debug; + int hard_remove; + int use_ino; + int readdir_ino; + int set_mode; + int set_uid; + int set_gid; + int direct_io; + int kernel_cache; + int auto_cache; + int intr; + int intr_signal; + int help; + char *modules; +}; + + +#ifdef __cplusplus +extern "C" { +#endif + +int fuse_parse_config_args(struct fuse_args* args, struct fuse_config* config); + +#ifdef __cplusplus +} +#endif + + +#endif // USERLAND_FS_FUSE_CONFIG_H diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_main.cpp b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_main.cpp index ed3f00f517..6de6e24ea9 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_main.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/fuse_main.cpp @@ -8,6 +8,7 @@ #include #include "fuse_api.h" +#include "fuse_config.h" #include "FUSEFileSystem.h" @@ -18,9 +19,19 @@ fuse_main_real(int argc, char* argv[], const struct fuse_operations* op, printf("fuse_main_real(%d, %p, %p, %ld, %p)\n", argc, argv, op, opSize, userData); + // parse args + struct fuse_args args = FUSE_ARGS_INIT(argc, argv); + fuse_config config; + bool success = fuse_parse_config_args(&args, &config); + fuse_opt_free_args(&args); + + if (!success) + return 1; + // run the main loop - status_t error = FUSEFileSystem::GetInstance()->FinishInitClientFS(op, - opSize, userData); + status_t error = FUSEFileSystem::GetInstance()->FinishInitClientFS(&config, + op, opSize, userData); + return error == B_OK ? 0 : 1; }