hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/fs/incfs/main.c
....@@ -8,9 +8,8 @@
88
99 #include <uapi/linux/incrementalfs.h>
1010
11
+#include "sysfs.h"
1112 #include "vfs.h"
12
-
13
-#define INCFS_NODE_FEATURES "features"
1413
1514 static struct file_system_type incfs_fs_type = {
1615 .owner = THIS_MODULE,
....@@ -20,88 +19,24 @@
2019 .fs_flags = 0
2120 };
2221
23
-static struct kobject *sysfs_root, *featurefs_root;
24
-
25
-static ssize_t corefs_show(struct kobject *kobj,
26
- struct kobj_attribute *attr, char *buff)
27
-{
28
- return snprintf(buff, PAGE_SIZE, "supported\n");
29
-}
30
-
31
-static struct kobj_attribute corefs_attr = __ATTR_RO(corefs);
32
-
33
-static ssize_t mounter_context_for_backing_rw_show(struct kobject *kobj,
34
- struct kobj_attribute *attr, char *buff)
35
-{
36
- return snprintf(buff, PAGE_SIZE, "supported\n");
37
-}
38
-
39
-static struct kobj_attribute mounter_context_for_backing_rw_attr =
40
- __ATTR_RO(mounter_context_for_backing_rw);
41
-
42
-static struct attribute *attributes[] = {
43
- &corefs_attr.attr,
44
- &mounter_context_for_backing_rw_attr.attr,
45
- NULL,
46
-};
47
-
48
-static const struct attribute_group attr_group = {
49
- .attrs = attributes,
50
-};
51
-
52
-static int __init init_sysfs(void)
53
-{
54
- int res = 0;
55
-
56
- sysfs_root = kobject_create_and_add(INCFS_NAME, fs_kobj);
57
- if (!sysfs_root)
58
- return -ENOMEM;
59
-
60
- featurefs_root = kobject_create_and_add(INCFS_NODE_FEATURES,
61
- sysfs_root);
62
- if (!featurefs_root)
63
- return -ENOMEM;
64
-
65
- res = sysfs_create_group(featurefs_root, &attr_group);
66
- if (res) {
67
- kobject_put(sysfs_root);
68
- sysfs_root = NULL;
69
- }
70
- return res;
71
-}
72
-
73
-static void cleanup_sysfs(void)
74
-{
75
- if (featurefs_root) {
76
- sysfs_remove_group(featurefs_root, &attr_group);
77
- kobject_put(featurefs_root);
78
- featurefs_root = NULL;
79
- }
80
-
81
- if (sysfs_root) {
82
- kobject_put(sysfs_root);
83
- sysfs_root = NULL;
84
- }
85
-}
86
-
8722 static int __init init_incfs_module(void)
8823 {
8924 int err = 0;
9025
91
- err = init_sysfs();
26
+ err = incfs_init_sysfs();
9227 if (err)
9328 return err;
9429
9530 err = register_filesystem(&incfs_fs_type);
9631 if (err)
97
- cleanup_sysfs();
32
+ incfs_cleanup_sysfs();
9833
9934 return err;
10035 }
10136
10237 static void __exit cleanup_incfs_module(void)
10338 {
104
- cleanup_sysfs();
39
+ incfs_cleanup_sysfs();
10540 unregister_filesystem(&incfs_fs_type);
10641 }
10742
....@@ -109,5 +44,6 @@
10944 module_exit(cleanup_incfs_module);
11045
11146 MODULE_LICENSE("GPL v2");
47
+MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY);
11248 MODULE_AUTHOR("Eugene Zemtsov <ezemtsov@google.com>");
11349 MODULE_DESCRIPTION("Incremental File System");