debug.c (24a4f8009ee9e259a412d86373e0d2aac3a80333) | debug.c (7dae997de62bbd78f12305bf10019ec8f1103bd4) |
---|---|
1/* 2 * This file is part of UBIFS. 3 * 4 * Copyright (C) 2006-2008 Nokia Corporation 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 as published by 8 * the Free Software Foundation. --- 2794 unchanged lines hidden (view full) --- 2803 err = ubi_leb_map(desc, lnum, dtype); 2804 if (err) 2805 return err; 2806 if (do_fail(desc, lnum, 0)) 2807 return -EROFS; 2808 return 0; 2809} 2810 | 1/* 2 * This file is part of UBIFS. 3 * 4 * Copyright (C) 2006-2008 Nokia Corporation 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 as published by 8 * the Free Software Foundation. --- 2794 unchanged lines hidden (view full) --- 2803 err = ubi_leb_map(desc, lnum, dtype); 2804 if (err) 2805 return err; 2806 if (do_fail(desc, lnum, 0)) 2807 return -EROFS; 2808 return 0; 2809} 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/* 2840 * Root directory for UBIFS stuff in debugfs. Contains sub-directories which 2841 * contain the stuff specific to particular file-system mounts. 2842 */ 2843static struct dentry *dfs_rootdir; 2844 | 2811/* 2812 * Root directory for UBIFS stuff in debugfs. Contains sub-directories which 2813 * contain the stuff specific to particular file-system mounts. 2814 */ 2815static struct dentry *dfs_rootdir; 2816 |
2845/** 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) | 2817static int dfs_file_open(struct inode *inode, struct file *file) |
2854{ | 2818{ |
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{ | |
2876 file->private_data = inode->i_private; 2877 return nonseekable_open(inode, file); 2878} 2879 2880static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count, 2881 loff_t *ppos) 2882{ 2883 struct dentry *dent = file->f_path.dentry; --- 89 unchanged lines hidden (view full) --- 2973 d->tst_rcvry = val; 2974 else 2975 return -EINVAL; 2976 2977 return count; 2978} 2979 2980static const struct file_operations dfs_fops = { | 2819 file->private_data = inode->i_private; 2820 return nonseekable_open(inode, file); 2821} 2822 2823static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count, 2824 loff_t *ppos) 2825{ 2826 struct dentry *dent = file->f_path.dentry; --- 89 unchanged lines hidden (view full) --- 2916 d->tst_rcvry = val; 2917 else 2918 return -EINVAL; 2919 2920 return count; 2921} 2922 2923static const struct file_operations dfs_fops = { |
2981 .open = open_debugfs_file, | 2924 .open = dfs_file_open, |
2982 .read = dfs_file_read, 2983 .write = dfs_file_write, 2984 .owner = THIS_MODULE, 2985 .llseek = no_llseek, 2986}; 2987 2988/** 2989 * dbg_debugfs_init_fs - initialize debugfs for UBIFS instance. --- 104 unchanged lines hidden (view full) --- 3094 * dbg_debugfs_exit_fs - remove all debugfs files. 3095 * @c: UBIFS file-system description object 3096 */ 3097void dbg_debugfs_exit_fs(struct ubifs_info *c) 3098{ 3099 debugfs_remove_recursive(c->dbg->dfs_dir); 3100} 3101 | 2925 .read = dfs_file_read, 2926 .write = dfs_file_write, 2927 .owner = THIS_MODULE, 2928 .llseek = no_llseek, 2929}; 2930 2931/** 2932 * dbg_debugfs_init_fs - initialize debugfs for UBIFS instance. --- 104 unchanged lines hidden (view full) --- 3037 * dbg_debugfs_exit_fs - remove all debugfs files. 3038 * @c: UBIFS file-system description object 3039 */ 3040void dbg_debugfs_exit_fs(struct ubifs_info *c) 3041{ 3042 debugfs_remove_recursive(c->dbg->dfs_dir); 3043} 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 */ |