Motr  M0
m0ctl_main.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2011-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 
24 #include <linux/module.h> /* MODULE_XXX */
25 #include <linux/init.h> /* module_init */
26 #include <linux/debugfs.h> /* debugfs_create_dir */
27 #include <linux/kernel.h> /* pr_err */
28 
29 #include "lib/thread.h" /* M0_THREAD_ENTER */
31 #include "utils/linux_kernel/finject_debugfs.h" /* fi_dfs_init */
32 #include "utils/linux_kernel/trace_debugfs.h" /* trc_dfs_init */
33 #include "utils/linux_kernel/core_debugfs.h" /* core_dfs_init */
34 
48 #if 0
49 struct dentry *dfs_root_dir;
50 const char dfs_root_name[] = "motr";
51 
52 int dfs_init(void)
53 {
54  int rc;
55 
56  pr_info(KBUILD_MODNAME ": init\n");
57 
58  /* create motr's main debugfs directory */
59  dfs_root_dir = debugfs_create_dir(dfs_root_name, NULL);
60  if (dfs_root_dir == NULL) {
61  pr_err(KBUILD_MODNAME ": failed to create debugfs dir '%s'\n",
63  return -EPERM;
64  }
65 
66  rc = fi_dfs_init();
67  if (rc != 0)
68  goto err;
69 
70  rc = trc_dfs_init();
71  if (rc != 0)
72  goto err;
73 
74  rc = core_dfs_init();
75  if (rc != 0)
76  goto err;
77 
78  return 0;
79 err:
80  debugfs_remove_recursive(dfs_root_dir);
81  dfs_root_dir = 0;
82  return rc;
83 }
84 
85 void dfs_cleanup(void)
86 {
87  pr_info(KBUILD_MODNAME ": cleanup\n");
88 
92 
93  /*
94  * remove all orphaned debugfs files (if any) and motr's debugfs root
95  * directroy itself
96  */
97  if (dfs_root_dir != 0) {
98  debugfs_remove_recursive(dfs_root_dir);
99  dfs_root_dir = 0;
100  }
101 }
102 
103 int __init m0ctl_init(void)
104 {
106  return dfs_init();
107 }
108 
109 void __exit m0ctl_exit(void)
110 {
112  dfs_cleanup();
113 }
114 
115 #endif
116 
117 int __init m0ctl_init(void)
118 {
119  return 0;
120 }
121 
122 void __exit m0ctl_exit(void)
123 {
124 }
125 
128 
129 /*
130  * Local variables:
131  * c-indentation-style: "K&R"
132  * c-basic-offset: 8
133  * tab-width: 8
134  * fill-column: 80
135  * scroll-step: 1
136  * End:
137  */
#define NULL
Definition: misc.h:38
struct dentry * dfs_root_dir
int trc_dfs_init(void)
int __init m0ctl_init(void)
Definition: m0ctl_main.c:117
int core_dfs_init(void)
void fi_dfs_cleanup(void)
void trc_dfs_cleanup(void)
static int struct dentry * dentry
Definition: dir.c:589
M0_THREAD_ENTER
Definition: dir.c:336
module_init(m0ctl_init)
int fi_dfs_init(void)
module_exit(m0ctl_exit)
void __exit m0ctl_exit(void)
Definition: m0ctl_main.c:122
const char dfs_root_name[]
void core_dfs_cleanup(void)
int32_t rc
Definition: trigger_fop.h:47