]> git.sesse.net Git - bcachefs-tools-debian/blob - bcachefs-userspace-shim.c
9fd62cdbd544cda8c7542d42d65ad20e677a4894
[bcachefs-tools-debian] / bcachefs-userspace-shim.c
1
2 #include <errno.h>
3 #include <linux/types.h>
4
5 #define bch2_fmt(_c, fmt)       fmt "\n"
6
7 #include "libbcachefs.h"
8 #include "tools-util.h"
9
10 enum fsck_err_opts fsck_err_opt;
11
12 /* Returns true if error should be fixed: */
13
14 /* XXX: flag if we ignore errors */
15
16 /*
17  * If it's an error that we can't ignore, and we're running non
18  * interactively - return true and have the error fixed so that we don't have to
19  * bail out and stop the fsck early, so that the user can see all the errors
20  * present:
21  */
22 #define __fsck_err(c, _can_fix, _can_ignore, _nofix_msg, msg, ...)      \
23 ({                                                                      \
24         bool _fix = false;                                              \
25                                                                         \
26         if (_can_fix) {                                                 \
27                 switch (fsck_err_opt) {                                 \
28                 case FSCK_ERR_ASK:                                      \
29                         printf(msg ": fix?", ##__VA_ARGS__);            \
30                         _fix = ask_yn();                                \
31                                                                         \
32                         break;                                          \
33                 case FSCK_ERR_YES:                                      \
34                         bch_err(c, msg ", fixing", ##__VA_ARGS__);      \
35                         _fix = true;                                    \
36                         break;                                          \
37                 case FSCK_ERR_NO:                                       \
38                         bch_err(c, msg, ##__VA_ARGS__);                 \
39                         _fix = false;                                   \
40                         break;                                          \
41                 }                                                       \
42         } else if (_can_ignore) {                                       \
43                 bch_err(c, msg, ##__VA_ARGS__);                         \
44         }                                                               \
45                                                                         \
46         if (_can_fix && !_can_ignore && fsck_err_opt == FSCK_ERR_NO)    \
47                 _fix = true;                                            \
48                                                                         \
49         if (!_fix && !_can_ignore) {                                    \
50                 printf("Fatal filesystem inconsistency, halting\n");    \
51                 ret = BCH_FSCK_ERRORS_NOT_FIXED;                        \
52                 goto fsck_err;                                          \
53         }                                                               \
54                                                                         \
55         _fix;                                                           \
56 })
57
58 //#include "acl.c"
59 #include "alloc.c"
60 #include "bkey.c"
61 #include "bkey_methods.c"
62 #include "bset.c"
63 #include "btree_cache.c"
64 #include "btree_gc.c"
65 #include "btree_io.c"
66 #include "btree_iter.c"
67 #include "btree_update.c"
68 #include "buckets.c"
69 //#include "chardev.c"
70 #include "checksum.c"
71 #include "clock.c"
72 #include "compress.c"
73 #include "debug.c"
74 #include "dirent.c"
75 #include "error.c"
76 #include "extents.c"
77 //#include "fs.c"
78 #include "fs-gc.c"
79 //#include "fs-io.c"
80 #include "inode.c"
81 #include "io.c"
82 #include "journal.c"
83 #include "keylist.c"
84 #include "migrate.c"
85 #include "move.c"
86 #include "movinggc.c"
87 #include "opts.c"
88 #include "siphash.c"
89 #include "six.c"
90 #include "super.c"
91 #include "super-io.c"
92 //#include "sysfs.c"
93 #include "tier.c"
94 #include "trace.c"
95 #include "util.c"
96 #include "xattr.c"
97
98 #define SHIM_KTYPE(type)                                                \
99 struct kobj_type type ## _ktype = { .release = type ## _release, }
100
101 static void bch2_fs_internal_release(struct kobject *k) {}
102
103 static void bch2_fs_opts_dir_release(struct kobject *k) {}
104
105 static void bch2_fs_time_stats_release(struct kobject *k) {}
106
107 SHIM_KTYPE(bch2_dev);
108 SHIM_KTYPE(bch2_fs);
109 SHIM_KTYPE(bch2_fs_internal);
110 SHIM_KTYPE(bch2_fs_time_stats);
111 SHIM_KTYPE(bch2_fs_opts_dir);