]> git.sesse.net Git - bcachefs-tools-debian/blob - bcache-userspace-shim.c
8634d8f730954e6b399c2ea557bbe8c716fea181
[bcachefs-tools-debian] / bcache-userspace-shim.c
1
2 #include <errno.h>
3 #include <linux/types.h>
4
5 #include "libbcache.h"
6 #include "tools-util.h"
7
8 /* stub out the bcache code we aren't building: */
9
10 struct block_device;
11 struct bcache_superblock;
12 struct cache;
13 struct cache_accounting;
14 struct cache_set;
15 struct closure;
16 struct file;
17 struct kobject;
18
19 struct kmem_cache *bch_search_cache;
20
21 const char *bch_backing_dev_register(struct bcache_superblock *sb)
22 {
23         return "not implemented";
24 }
25 void bch_blockdevs_stop(struct cache_set *c) {}
26 int bch_blockdev_volumes_start(struct cache_set *c) { return 0; }
27 void bch_attach_backing_devs(struct cache_set *c) {}
28 bool bch_is_open_backing_dev(struct block_device *bdev) { return false; }
29 void bch_blockdev_exit(void) {}
30 int bch_blockdev_init(void) { return 0; }
31
32 void bch_fs_exit(void) {}
33 int bch_fs_init(void) { return 0; }
34
35 const struct file_operations bch_chardev_fops;
36
37 void bcache_dev_sectors_dirty_add(struct cache_set *c, unsigned inode,
38                                   u64 offset, int nr_sectors) {}
39 void bch_writeback_recalc_oldest_gens(struct cache_set *c) {}
40
41 void bch_notify_cache_set_read_write(struct cache_set *c) {}
42 void bch_notify_cache_set_read_only(struct cache_set *c) {}
43 void bch_notify_cache_set_stopped(struct cache_set *c) {}
44 void bch_notify_cache_read_write(struct cache *c) {}
45 void bch_notify_cache_read_only(struct cache *c) {}
46 void bch_notify_cache_added(struct cache *c) {}
47 void bch_notify_cache_removing(struct cache *c) {}
48 void bch_notify_cache_removed(struct cache *c) {}
49 void bch_notify_cache_remove_failed(struct cache *c) {}
50 void bch_notify_cache_error(struct cache *c, bool b) {}
51
52 int bch_cache_accounting_add_kobjs(struct cache_accounting *acc,
53                                    struct kobject *parent) { return 0; }
54 void bch_cache_accounting_destroy(struct cache_accounting *acc) {}
55 void bch_cache_accounting_init(struct cache_accounting *acc,
56                                struct closure *parent) {}
57
58 #define bch_fmt(_c, fmt)        fmt "\n"
59
60 enum fsck_err_opts fsck_err_opt;
61
62 /* Returns true if error should be fixed: */
63
64 /* XXX: flag if we ignore errors */
65
66 /*
67  * If it's an error that we can't ignore, and we're running non
68  * interactively - return true and have the error fixed so that we don't have to
69  * bail out and stop the fsck early, so that the user can see all the errors
70  * present:
71  */
72 #define __fsck_err(c, _can_fix, _can_ignore, _nofix_msg, msg, ...)      \
73 ({                                                                      \
74         bool _fix = false;                                              \
75                                                                         \
76         if (_can_fix) {                                                 \
77                 switch (fsck_err_opt) {                                 \
78                 case FSCK_ERR_ASK:                                      \
79                         printf(msg ": fix?", ##__VA_ARGS__);            \
80                         _fix = ask_yn();                                \
81                                                                         \
82                         break;                                          \
83                 case FSCK_ERR_YES:                                      \
84                         bch_err(c, msg ", fixing", ##__VA_ARGS__);      \
85                         _fix = true;                                    \
86                         break;                                          \
87                 case FSCK_ERR_NO:                                       \
88                         bch_err(c, msg, ##__VA_ARGS__);                 \
89                         _fix = false;                                   \
90                         break;                                          \
91                 }                                                       \
92         } else if (_can_ignore) {                                       \
93                 bch_err(c, msg, ##__VA_ARGS__);                         \
94         }                                                               \
95                                                                         \
96         if (_can_fix && !_can_ignore && fsck_err_opt == FSCK_ERR_NO)    \
97                 _fix = true;                                            \
98                                                                         \
99         if (!_fix && !_can_ignore) {                                    \
100                 printf("Fatal filesystem inconsistency, halting\n");    \
101                 ret = BCH_FSCK_ERRORS_NOT_FIXED;                        \
102                 goto fsck_err;                                          \
103         }                                                               \
104                                                                         \
105         _fix;                                                           \
106 })
107
108 //#include "acl.c"
109 #include "alloc.c"
110 #include "bkey.c"
111 #include "bkey_methods.c"
112 //#include "blockdev.c"
113 #include "bset.c"
114 #include "btree_cache.c"
115 #include "btree_gc.c"
116 #include "btree_io.c"
117 #include "btree_iter.c"
118 #include "btree_update.c"
119 #include "buckets.c"
120 //#include "chardev.c"
121 #include "checksum.c"
122 #include "clock.c"
123 #include "closure.c"
124 #include "compress.c"
125 #include "debug.c"
126 #include "dirent.c"
127 #include "error.c"
128 #include "extents.c"
129 //#include "fs.c"
130 #include "fs-gc.c"
131 //#include "fs-io.c"
132 #include "inode.c"
133 #include "io.c"
134 #include "journal.c"
135 #include "keybuf.c"
136 #include "keylist.c"
137 #include "migrate.c"
138 #include "move.c"
139 #include "movinggc.c"
140 //#include "notify.c"
141 #include "opts.c"
142 //#include "request.c"
143 #include "siphash.c"
144 #include "six.c"
145 //#include "stats.c"
146 #include "super.c"
147 #include "super-io.c"
148 //#include "sysfs.c"
149 #include "tier.c"
150 #include "trace.c"
151 #include "util.c"
152 //#include "writeback.c"
153 #include "xattr.c"
154
155 #define SHIM_KTYPE(type)                                                \
156 struct kobj_type type ## _ktype = { .release = type ## _release, }
157
158 static void bch_cache_set_internal_release(struct kobject *k) {}
159
160 static void bch_cache_set_opts_dir_release(struct kobject *k) {}
161
162 static void bch_cache_set_time_stats_release(struct kobject *k) {}
163
164 SHIM_KTYPE(bch_cache);
165 SHIM_KTYPE(bch_cache_set);
166 SHIM_KTYPE(bch_cache_set_internal);
167 SHIM_KTYPE(bch_cache_set_time_stats);
168 SHIM_KTYPE(bch_cache_set_opts_dir);