aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-06-01 08:44:14 -0400
committerArtem Bityutskiy <dedekind1@gmail.com>2011-07-04 03:54:32 -0400
commit7dae997de62bbd78f12305bf10019ec8f1103bd4 (patch)
tree0f26a540ea6f2857d4d0f0cbb5212b1618f9f241 /fs/ubifs
parent24a4f8009ee9e259a412d86373e0d2aac3a80333 (diff)
UBIFS: re-arrange debugging code a bit
Move 'dbg_debugfs_init()' and 'dbg_debugfs_exit()' functions which initialize debugfs for whole UBIFS subsystem below the code which initializes debugfs for a particular UBIFS instance. And do the same for 'ubifs_debugging_init()' and 'ubifs_debugging_exit()' functions. This layout is a bit better for the next patches, so this is just a preparation. Also, rename 'open_debugfs_file()' into 'dfs_file_open()' for consistency. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs')
-rw-r--r--fs/ubifs/debug.c118
1 files changed, 59 insertions, 59 deletions
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index e4a3630eb520..24a85073ac6c 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -2808,70 +2808,13 @@ int dbg_leb_map(struct ubi_volume_desc *desc, int lnum, int dtype)
2808 return 0; 2808 return 0;
2809} 2809}
2810 2810
2811/**
2812 * ubifs_debugging_init - initialize UBIFS debugging.
2813 * @c: UBIFS file-system description object
2814 *
2815 * This function initializes debugging-related data for the file system.
2816 * Returns zero in case of success and a negative error code in case of
2817 * failure.
2818 */
2819int ubifs_debugging_init(struct ubifs_info *c)
2820{
2821 c->dbg = kzalloc(sizeof(struct ubifs_debug_info), GFP_KERNEL);
2822 if (!c->dbg)
2823 return -ENOMEM;
2824
2825 failure_mode_init(c);
2826 return 0;
2827}
2828
2829/**
2830 * ubifs_debugging_exit - free debugging data.
2831 * @c: UBIFS file-system description object
2832 */
2833void ubifs_debugging_exit(struct ubifs_info *c)
2834{
2835 failure_mode_exit(c);
2836 kfree(c->dbg);
2837}
2838
2839/* 2811/*
2840 * Root directory for UBIFS stuff in debugfs. Contains sub-directories which 2812 * Root directory for UBIFS stuff in debugfs. Contains sub-directories which
2841 * contain the stuff specific to particular file-system mounts. 2813 * contain the stuff specific to particular file-system mounts.
2842 */ 2814 */
2843static struct dentry *dfs_rootdir; 2815static struct dentry *dfs_rootdir;
2844 2816
2845/** 2817static int dfs_file_open(struct inode *inode, struct file *file)
2846 * dbg_debugfs_init - initialize debugfs file-system.
2847 *
2848 * UBIFS uses debugfs file-system to expose various debugging knobs to
2849 * user-space. This function creates "ubifs" directory in the debugfs
2850 * file-system. Returns zero in case of success and a negative error code in
2851 * case of failure.
2852 */
2853int dbg_debugfs_init(void)
2854{
2855 dfs_rootdir = debugfs_create_dir("ubifs", NULL);
2856 if (IS_ERR_OR_NULL(dfs_rootdir)) {
2857 int err = dfs_rootdir ? PTR_ERR(dfs_rootdir) : -ENODEV;
2858 ubifs_err("cannot create \"ubifs\" debugfs directory, "
2859 "error %d\n", err);
2860 return err;
2861 }
2862
2863 return 0;
2864}
2865
2866/**
2867 * dbg_debugfs_exit - remove the "ubifs" directory from debugfs file-system.
2868 */
2869void dbg_debugfs_exit(void)
2870{
2871 debugfs_remove(dfs_rootdir);
2872}
2873
2874static int open_debugfs_file(struct inode *inode, struct file *file)
2875{ 2818{
2876 file->private_data = inode->i_private; 2819 file->private_data = inode->i_private;
2877 return nonseekable_open(inode, file); 2820 return nonseekable_open(inode, file);
@@ -2978,7 +2921,7 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u,
2978} 2921}
2979 2922
2980static const struct file_operations dfs_fops = { 2923static const struct file_operations dfs_fops = {
2981 .open = open_debugfs_file, 2924 .open = dfs_file_open,
2982 .read = dfs_file_read, 2925 .read = dfs_file_read,
2983 .write = dfs_file_write, 2926 .write = dfs_file_write,
2984 .owner = THIS_MODULE, 2927 .owner = THIS_MODULE,
@@ -3099,4 +3042,61 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c)
3099 debugfs_remove_recursive(c->dbg->dfs_dir); 3042 debugfs_remove_recursive(c->dbg->dfs_dir);
3100} 3043}
3101 3044
3045/**
3046 * dbg_debugfs_init - initialize debugfs file-system.
3047 *
3048 * UBIFS uses debugfs file-system to expose various debugging knobs to
3049 * user-space. This function creates "ubifs" directory in the debugfs
3050 * file-system. Returns zero in case of success and a negative error code in
3051 * case of failure.
3052 */
3053int dbg_debugfs_init(void)
3054{
3055 dfs_rootdir = debugfs_create_dir("ubifs", NULL);
3056 if (IS_ERR_OR_NULL(dfs_rootdir)) {
3057 int err = dfs_rootdir ? PTR_ERR(dfs_rootdir) : -ENODEV;
3058 ubifs_err("cannot create \"ubifs\" debugfs directory, "
3059 "error %d\n", err);
3060 return err;
3061 }
3062
3063 return 0;
3064}
3065
3066/**
3067 * dbg_debugfs_exit - remove the "ubifs" directory from debugfs file-system.
3068 */
3069void dbg_debugfs_exit(void)
3070{
3071 debugfs_remove(dfs_rootdir);
3072}
3073
3074/**
3075 * ubifs_debugging_init - initialize UBIFS debugging.
3076 * @c: UBIFS file-system description object
3077 *
3078 * This function initializes debugging-related data for the file system.
3079 * Returns zero in case of success and a negative error code in case of
3080 * failure.
3081 */
3082int ubifs_debugging_init(struct ubifs_info *c)
3083{
3084 c->dbg = kzalloc(sizeof(struct ubifs_debug_info), GFP_KERNEL);
3085 if (!c->dbg)
3086 return -ENOMEM;
3087
3088 failure_mode_init(c);
3089 return 0;
3090}
3091
3092/**
3093 * ubifs_debugging_exit - free debugging data.
3094 * @c: UBIFS file-system description object
3095 */
3096void ubifs_debugging_exit(struct ubifs_info *c)
3097{
3098 failure_mode_exit(c);
3099 kfree(c->dbg);
3100}
3101
3102#endif /* CONFIG_UBIFS_FS_DEBUG */ 3102#endif /* CONFIG_UBIFS_FS_DEBUG */