hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/ubifs/debug.c
....@@ -1,20 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * This file is part of UBIFS.
34 *
45 * 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.
9
- *
10
- * This program is distributed in the hope that it will be useful, but WITHOUT
11
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
- * more details.
14
- *
15
- * You should have received a copy of the GNU General Public License along with
16
- * this program; if not, write to the Free Software Foundation, Inc., 51
17
- * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
186 *
197 * Authors: Artem Bityutskiy (Битюцкий Артём)
208 * Adrian Hunter
....@@ -165,6 +153,8 @@
165153 return "commit start node";
166154 case UBIFS_ORPH_NODE:
167155 return "orphan node";
156
+ case UBIFS_AUTH_NODE:
157
+ return "auth node";
168158 default:
169159 return "unknown node";
170160 }
....@@ -542,6 +532,10 @@
542532 (unsigned long long)le64_to_cpu(orph->inos[i]));
543533 break;
544534 }
535
+ case UBIFS_AUTH_NODE:
536
+ {
537
+ break;
538
+ }
545539 default:
546540 pr_err("node type %d was not recognized\n",
547541 (int)ch->node_type);
....@@ -821,7 +815,7 @@
821815
822816 pr_err("(pid %d) start dumping LEB %d\n", current->pid, lnum);
823817
824
- buf = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
818
+ buf = __vmalloc(c->leb_size, GFP_NOFS);
825819 if (!buf) {
826820 ubifs_err(c, "cannot allocate memory for dumping LEB %d", lnum);
827821 return;
....@@ -1598,7 +1592,6 @@
15981592 err = PTR_ERR(child);
15991593 goto out_unlock;
16001594 }
1601
- zbr->znode = child;
16021595 }
16031596
16041597 znode = child;
....@@ -2745,18 +2738,6 @@
27452738 struct dentry *dent = file->f_path.dentry;
27462739 int val;
27472740
2748
- /*
2749
- * TODO: this is racy - the file-system might have already been
2750
- * unmounted and we'd oops in this case. The plan is to fix it with
2751
- * help of 'iterate_supers_type()' which we should have in v3.0: when
2752
- * a debugfs opened, we rember FS's UUID in file->private_data. Then
2753
- * whenever we access the FS via a debugfs file, we iterate all UBIFS
2754
- * superblocks and fine the one with the same UUID, and take the
2755
- * locking right.
2756
- *
2757
- * The other way to go suggested by Al Viro is to create a separate
2758
- * 'ubifs-debug' file-system instead.
2759
- */
27602741 if (file->f_path.dentry == d->dfs_dump_lprops) {
27612742 ubifs_dump_lprops(c);
27622743 return count;
....@@ -2808,115 +2789,68 @@
28082789 * dbg_debugfs_init_fs - initialize debugfs for UBIFS instance.
28092790 * @c: UBIFS file-system description object
28102791 *
2811
- * This function creates all debugfs files for this instance of UBIFS. Returns
2812
- * zero in case of success and a negative error code in case of failure.
2792
+ * This function creates all debugfs files for this instance of UBIFS.
28132793 *
28142794 * Note, the only reason we have not merged this function with the
28152795 * 'ubifs_debugging_init()' function is because it is better to initialize
28162796 * debugfs interfaces at the very end of the mount process, and remove them at
28172797 * the very beginning of the mount process.
28182798 */
2819
-int dbg_debugfs_init_fs(struct ubifs_info *c)
2799
+void dbg_debugfs_init_fs(struct ubifs_info *c)
28202800 {
2821
- int err, n;
2801
+ int n;
28222802 const char *fname;
2823
- struct dentry *dent;
28242803 struct ubifs_debug_info *d = c->dbg;
2825
-
2826
- if (!IS_ENABLED(CONFIG_DEBUG_FS))
2827
- return 0;
28282804
28292805 n = snprintf(d->dfs_dir_name, UBIFS_DFS_DIR_LEN + 1, UBIFS_DFS_DIR_NAME,
28302806 c->vi.ubi_num, c->vi.vol_id);
28312807 if (n == UBIFS_DFS_DIR_LEN) {
28322808 /* The array size is too small */
2833
- fname = UBIFS_DFS_DIR_NAME;
2834
- dent = ERR_PTR(-EINVAL);
2835
- goto out;
2809
+ return;
28362810 }
28372811
28382812 fname = d->dfs_dir_name;
2839
- dent = debugfs_create_dir(fname, dfs_rootdir);
2840
- if (IS_ERR_OR_NULL(dent))
2841
- goto out;
2842
- d->dfs_dir = dent;
2813
+ d->dfs_dir = debugfs_create_dir(fname, dfs_rootdir);
28432814
28442815 fname = "dump_lprops";
2845
- dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops);
2846
- if (IS_ERR_OR_NULL(dent))
2847
- goto out_remove;
2848
- d->dfs_dump_lprops = dent;
2816
+ d->dfs_dump_lprops = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c,
2817
+ &dfs_fops);
28492818
28502819 fname = "dump_budg";
2851
- dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops);
2852
- if (IS_ERR_OR_NULL(dent))
2853
- goto out_remove;
2854
- d->dfs_dump_budg = dent;
2820
+ d->dfs_dump_budg = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c,
2821
+ &dfs_fops);
28552822
28562823 fname = "dump_tnc";
2857
- dent = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c, &dfs_fops);
2858
- if (IS_ERR_OR_NULL(dent))
2859
- goto out_remove;
2860
- d->dfs_dump_tnc = dent;
2824
+ d->dfs_dump_tnc = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c,
2825
+ &dfs_fops);
28612826
28622827 fname = "chk_general";
2863
- dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, d->dfs_dir, c,
2864
- &dfs_fops);
2865
- if (IS_ERR_OR_NULL(dent))
2866
- goto out_remove;
2867
- d->dfs_chk_gen = dent;
2828
+ d->dfs_chk_gen = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
2829
+ d->dfs_dir, c, &dfs_fops);
28682830
28692831 fname = "chk_index";
2870
- dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, d->dfs_dir, c,
2871
- &dfs_fops);
2872
- if (IS_ERR_OR_NULL(dent))
2873
- goto out_remove;
2874
- d->dfs_chk_index = dent;
2832
+ d->dfs_chk_index = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
2833
+ d->dfs_dir, c, &dfs_fops);
28752834
28762835 fname = "chk_orphans";
2877
- dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, d->dfs_dir, c,
2878
- &dfs_fops);
2879
- if (IS_ERR_OR_NULL(dent))
2880
- goto out_remove;
2881
- d->dfs_chk_orph = dent;
2836
+ d->dfs_chk_orph = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
2837
+ d->dfs_dir, c, &dfs_fops);
28822838
28832839 fname = "chk_lprops";
2884
- dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, d->dfs_dir, c,
2885
- &dfs_fops);
2886
- if (IS_ERR_OR_NULL(dent))
2887
- goto out_remove;
2888
- d->dfs_chk_lprops = dent;
2840
+ d->dfs_chk_lprops = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
2841
+ d->dfs_dir, c, &dfs_fops);
28892842
28902843 fname = "chk_fs";
2891
- dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, d->dfs_dir, c,
2892
- &dfs_fops);
2893
- if (IS_ERR_OR_NULL(dent))
2894
- goto out_remove;
2895
- d->dfs_chk_fs = dent;
2844
+ d->dfs_chk_fs = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
2845
+ d->dfs_dir, c, &dfs_fops);
28962846
28972847 fname = "tst_recovery";
2898
- dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, d->dfs_dir, c,
2899
- &dfs_fops);
2900
- if (IS_ERR_OR_NULL(dent))
2901
- goto out_remove;
2902
- d->dfs_tst_rcvry = dent;
2848
+ d->dfs_tst_rcvry = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
2849
+ d->dfs_dir, c, &dfs_fops);
29032850
29042851 fname = "ro_error";
2905
- dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, d->dfs_dir, c,
2906
- &dfs_fops);
2907
- if (IS_ERR_OR_NULL(dent))
2908
- goto out_remove;
2909
- d->dfs_ro_error = dent;
2910
-
2911
- return 0;
2912
-
2913
-out_remove:
2914
- debugfs_remove_recursive(d->dfs_dir);
2915
-out:
2916
- err = dent ? PTR_ERR(dent) : -ENODEV;
2917
- ubifs_err(c, "cannot create \"%s\" debugfs file or directory, error %d\n",
2918
- fname, err);
2919
- return err;
2852
+ d->dfs_ro_error = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
2853
+ d->dfs_dir, c, &dfs_fops);
29202854 }
29212855
29222856 /**
....@@ -2925,8 +2859,7 @@
29252859 */
29262860 void dbg_debugfs_exit_fs(struct ubifs_info *c)
29272861 {
2928
- if (IS_ENABLED(CONFIG_DEBUG_FS))
2929
- debugfs_remove_recursive(c->dbg->dfs_dir);
2862
+ debugfs_remove_recursive(c->dbg->dfs_dir);
29302863 }
29312864
29322865 struct ubifs_global_debug_info ubifs_dbg;
....@@ -3002,75 +2935,38 @@
30022935 *
30032936 * UBIFS uses debugfs file-system to expose various debugging knobs to
30042937 * user-space. This function creates "ubifs" directory in the debugfs
3005
- * file-system. Returns zero in case of success and a negative error code in
3006
- * case of failure.
2938
+ * file-system.
30072939 */
3008
-int dbg_debugfs_init(void)
2940
+void dbg_debugfs_init(void)
30092941 {
3010
- int err;
30112942 const char *fname;
3012
- struct dentry *dent;
3013
-
3014
- if (!IS_ENABLED(CONFIG_DEBUG_FS))
3015
- return 0;
30162943
30172944 fname = "ubifs";
3018
- dent = debugfs_create_dir(fname, NULL);
3019
- if (IS_ERR_OR_NULL(dent))
3020
- goto out;
3021
- dfs_rootdir = dent;
2945
+ dfs_rootdir = debugfs_create_dir(fname, NULL);
30222946
30232947 fname = "chk_general";
3024
- dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, dfs_rootdir, NULL,
3025
- &dfs_global_fops);
3026
- if (IS_ERR_OR_NULL(dent))
3027
- goto out_remove;
3028
- dfs_chk_gen = dent;
2948
+ dfs_chk_gen = debugfs_create_file(fname, S_IRUSR | S_IWUSR, dfs_rootdir,
2949
+ NULL, &dfs_global_fops);
30292950
30302951 fname = "chk_index";
3031
- dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, dfs_rootdir, NULL,
3032
- &dfs_global_fops);
3033
- if (IS_ERR_OR_NULL(dent))
3034
- goto out_remove;
3035
- dfs_chk_index = dent;
2952
+ dfs_chk_index = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
2953
+ dfs_rootdir, NULL, &dfs_global_fops);
30362954
30372955 fname = "chk_orphans";
3038
- dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, dfs_rootdir, NULL,
3039
- &dfs_global_fops);
3040
- if (IS_ERR_OR_NULL(dent))
3041
- goto out_remove;
3042
- dfs_chk_orph = dent;
2956
+ dfs_chk_orph = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
2957
+ dfs_rootdir, NULL, &dfs_global_fops);
30432958
30442959 fname = "chk_lprops";
3045
- dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, dfs_rootdir, NULL,
3046
- &dfs_global_fops);
3047
- if (IS_ERR_OR_NULL(dent))
3048
- goto out_remove;
3049
- dfs_chk_lprops = dent;
2960
+ dfs_chk_lprops = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
2961
+ dfs_rootdir, NULL, &dfs_global_fops);
30502962
30512963 fname = "chk_fs";
3052
- dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, dfs_rootdir, NULL,
3053
- &dfs_global_fops);
3054
- if (IS_ERR_OR_NULL(dent))
3055
- goto out_remove;
3056
- dfs_chk_fs = dent;
2964
+ dfs_chk_fs = debugfs_create_file(fname, S_IRUSR | S_IWUSR, dfs_rootdir,
2965
+ NULL, &dfs_global_fops);
30572966
30582967 fname = "tst_recovery";
3059
- dent = debugfs_create_file(fname, S_IRUSR | S_IWUSR, dfs_rootdir, NULL,
3060
- &dfs_global_fops);
3061
- if (IS_ERR_OR_NULL(dent))
3062
- goto out_remove;
3063
- dfs_tst_rcvry = dent;
3064
-
3065
- return 0;
3066
-
3067
-out_remove:
3068
- debugfs_remove_recursive(dfs_rootdir);
3069
-out:
3070
- err = dent ? PTR_ERR(dent) : -ENODEV;
3071
- pr_err("UBIFS error (pid %d): cannot create \"%s\" debugfs file or directory, error %d\n",
3072
- current->pid, fname, err);
3073
- return err;
2968
+ dfs_tst_rcvry = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
2969
+ dfs_rootdir, NULL, &dfs_global_fops);
30742970 }
30752971
30762972 /**
....@@ -3078,8 +2974,7 @@
30782974 */
30792975 void dbg_debugfs_exit(void)
30802976 {
3081
- if (IS_ENABLED(CONFIG_DEBUG_FS))
3082
- debugfs_remove_recursive(dfs_rootdir);
2977
+ debugfs_remove_recursive(dfs_rootdir);
30832978 }
30842979
30852980 void ubifs_assert_failed(struct ubifs_info *c, const char *expr,