Motr  M0
core_debugfs.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-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 #if 0
23 
24 #include <linux/kernel.h> /* pr_info */
25 #include <linux/debugfs.h> /* debugfs_create_dir */
26 #include <linux/module.h> /* THIS_MODULE */
27 #include <linux/version.h>
28 
29 #include "lib/misc.h" /* bool */
33 
34 
41 static struct dentry *core_file;
42 static const char core_name[] = "core";
43 static bool core_file_is_opened = false;
44 
45 
46 static int core_open(struct inode *i, struct file *f)
47 {
48  if (core_file_is_opened)
49  return -EBUSY;
50 
51  core_file_is_opened = true;
52 
53  return 0;
54 }
55 
56 static int core_release(struct inode *i, struct file *f)
57 {
58  core_file_is_opened = false;
59  return 0;
60 }
61 
62 static ssize_t core_read(struct file *file, char __user *ubuf,
63  size_t ubuf_size, loff_t *ppos)
64 {
65  const struct module *m = m0_motr_ko_get_module();
66 
67  return simple_read_from_buffer(ubuf, ubuf_size, ppos,
70 }
71 
72 static const struct file_operations core_fops = {
73  .owner = THIS_MODULE,
74  .open = core_open,
75  .release = core_release,
76  .read = core_read,
77 };
78 
79 /******************************* init/fini ************************************/
80 
81 int core_dfs_init(void)
82 {
83  core_file = debugfs_create_file(core_name, S_IRUSR, dfs_root_dir, NULL,
84  &core_fops);
85  if (core_file == NULL) {
86  pr_err(KBUILD_MODNAME ": failed to create debugfs file"
87  " '%s/%s'\n", dfs_root_name, core_name);
88  return -EPERM;
89  }
90 
91  return 0;
92 }
93 
94 void core_dfs_cleanup(void)
95 {
96  debugfs_remove(core_file);
97 }
98 
100 #endif
101 
102 /*
103  * Local variables:
104  * c-indentation-style: "K&R"
105  * c-basic-offset: 8
106  * tab-width: 8
107  * fill-column: 80
108  * scroll-step: 1
109  * End:
110  */
111 /*
112  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
113  */
#define NULL
Definition: misc.h:38
static struct m0_addb2_mach * m
Definition: consumer.c:38
static FILE * f
Definition: adieu.c:79
struct m0_file file
Definition: di.c:36
struct dentry * dfs_root_dir
#define M0_MOTR_KO_SIZE(module)
Definition: module.h:34
struct inode * inode
Definition: dir.c:624
int core_dfs_init(void)
M0_INTERNAL const struct module * m0_motr_ko_get_module(void)
Definition: module.c:28
int i
Definition: dir.c:1033
static int struct dentry * dentry
Definition: dir.c:589
const char dfs_root_name[]
#define M0_MOTR_KO_BASE(module)
Definition: module.h:33
void core_dfs_cleanup(void)