diff --git a/kmod/src/options.c b/kmod/src/options.c index 9f909e62..2d468553 100644 --- a/kmod/src/options.c +++ b/kmod/src/options.c @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include #include @@ -22,12 +24,7 @@ #include "msg.h" #include "options.h" - -enum { - Opt_listen = 0, - Opt_cluster, - Opt_err, -}; +#include "super.h" static const match_table_t tokens = { {Opt_listen, "listen=%s"}, @@ -35,6 +32,20 @@ static const match_table_t tokens = { {Opt_err, NULL} }; +struct options_sb_info { + struct dentry *debugfs_dir; +}; + +u32 scoutfs_option_u32(struct super_block *sb, int token) +{ + switch(token) { + default: break; + } + + WARN_ON_ONCE(1); + return 0; +} + int scoutfs_parse_options(struct super_block *sb, char *options, struct mount_options *parsed) { @@ -79,3 +90,41 @@ int scoutfs_parse_options(struct super_block *sb, char *options, return 0; } + +int scoutfs_options_setup(struct super_block *sb) +{ + struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); + struct options_sb_info *osi; + int ret; + + osi = kzalloc(sizeof(struct options_sb_info), GFP_KERNEL); + if (!osi) + return -ENOMEM; + + sbi->options = osi; + + osi->debugfs_dir = debugfs_create_dir("options", sbi->debug_root); + if (!osi->debugfs_dir) { + ret = -ENOMEM; + goto out; + } + + ret = 0; +out: + if (ret) + scoutfs_options_destroy(sb); + return ret; +} + +void scoutfs_options_destroy(struct super_block *sb) +{ + struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); + struct options_sb_info *osi = sbi->options; + + if (osi) { + if (osi->debugfs_dir) + debugfs_remove_recursive(osi->debugfs_dir); + kfree(osi); + sbi->options = NULL; + } +} diff --git a/kmod/src/options.h b/kmod/src/options.h index 30009faf..8bf58b36 100644 --- a/kmod/src/options.h +++ b/kmod/src/options.h @@ -4,6 +4,12 @@ #include #include "format.h" +enum { + Opt_listen = 0, + Opt_cluster, + Opt_err, +}; + #define MAX_CLUSTER_NAME_LEN 17 struct mount_options { @@ -13,5 +19,10 @@ struct mount_options int scoutfs_parse_options(struct super_block *sb, char *options, struct mount_options *parsed); +int scoutfs_options_setup(struct super_block *sb); +void scoutfs_options_destroy(struct super_block *sb); + +u32 scoutfs_option_u32(struct super_block *sb, int token); +#define scoutfs_option_bool scoutfs_option_u32 #endif /* _SCOUTFS_OPTIONS_H_ */ diff --git a/kmod/src/super.c b/kmod/src/super.c index 9d97e578..fdfd4080 100644 --- a/kmod/src/super.c +++ b/kmod/src/super.c @@ -137,6 +137,7 @@ static void scoutfs_put_super(struct super_block *sb) scoutfs_lock_destroy(sb); scoutfs_destroy_triggers(sb); + scoutfs_options_destroy(sb); debugfs_remove(sbi->debug_root); scoutfs_destroy_counters(sb); scoutfs_destroy_sysfs(sb); @@ -331,6 +332,7 @@ static int scoutfs_fill_super(struct super_block *sb, void *data, int silent) scoutfs_setup_counters(sb) ?: scoutfs_read_supers(sb, &SCOUTFS_SB(sb)->super) ?: scoutfs_debugfs_setup(sb) ?: + scoutfs_options_setup(sb) ?: scoutfs_setup_triggers(sb) ?: scoutfs_seg_setup(sb) ?: scoutfs_item_setup(sb) ?: diff --git a/kmod/src/super.h b/kmod/src/super.h index 22ef0b62..195e54d0 100644 --- a/kmod/src/super.h +++ b/kmod/src/super.h @@ -21,6 +21,7 @@ struct server_info; struct inode_sb_info; struct btree_info; struct sysfs_info; +struct options_sb_info; struct scoutfs_sb_info { struct super_block *sb; @@ -64,6 +65,7 @@ struct scoutfs_sb_info { struct scoutfs_triggers *triggers; struct mount_options opts; + struct options_sb_info *options; struct dentry *debug_root;