]> git.sesse.net Git - bcachefs-tools-debian/blob - bcache-userspace-shim.c
bcache in userspace; userspace fsck
[bcachefs-tools-debian] / bcache-userspace-shim.c
1
2 #include <errno.h>
3 #include <linux/byteorder.h>
4 #include <linux/types.h>
5
6 /* stub out the bcache code we aren't building: */
7
8 struct block_device;
9 struct bcache_superblock;
10 struct cache;
11 struct cache_accounting;
12 struct cache_set;
13 struct closure;
14 struct file;
15 struct kobject;
16
17 struct kmem_cache *bch_search_cache;
18
19 const char *bch_backing_dev_register(struct bcache_superblock *sb)
20 {
21         return "not implemented";
22 }
23 void bch_blockdevs_stop(struct cache_set *c) {}
24 int bch_blockdev_volumes_start(struct cache_set *c) { return 0; }
25 void bch_attach_backing_devs(struct cache_set *c) {}
26 bool bch_is_open_backing_dev(struct block_device *bdev) { return false; }
27 void bch_blockdev_exit(void) {}
28 int bch_blockdev_init(void) { return 0; }
29
30 void bch_fs_exit(void) {}
31 int bch_fs_init(void) { return 0; }
32
33 const struct file_operations bch_chardev_fops;
34
35 void bcache_dev_sectors_dirty_add(struct cache_set *c, unsigned inode,
36                                   u64 offset, int nr_sectors) {}
37 void bch_writeback_recalc_oldest_gens(struct cache_set *c) {}
38
39 void bch_notify_cache_set_read_write(struct cache_set *c) {}
40 void bch_notify_cache_set_read_only(struct cache_set *c) {}
41 void bch_notify_cache_set_stopped(struct cache_set *c) {}
42 void bch_notify_cache_read_write(struct cache *c) {}
43 void bch_notify_cache_read_only(struct cache *c) {}
44 void bch_notify_cache_added(struct cache *c) {}
45 void bch_notify_cache_removing(struct cache *c) {}
46 void bch_notify_cache_removed(struct cache *c) {}
47 void bch_notify_cache_remove_failed(struct cache *c) {}
48 void bch_notify_cache_error(struct cache *c, bool b) {}
49
50 int bch_cache_accounting_add_kobjs(struct cache_accounting *acc,
51                                    struct kobject *parent) { return 0; }
52 void bch_cache_accounting_destroy(struct cache_accounting *acc) {}
53 void bch_cache_accounting_init(struct cache_accounting *acc,
54                                struct closure *parent) {}
55
56 //#include "acl.c"
57 #include "alloc.c"
58 #include "bkey.c"
59 #include "bkey_methods.c"
60 //#include "blockdev.c"
61 #include "bset.c"
62 #include "btree_cache.c"
63 #include "btree_gc.c"
64 #include "btree_io.c"
65 #include "btree_iter.c"
66 #include "btree_update.c"
67 #include "buckets.c"
68 //#include "chardev.c"
69 #include "checksum.c"
70 #include "clock.c"
71 #include "closure.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 "keybuf.c"
84 #include "keylist.c"
85 #include "migrate.c"
86 #include "move.c"
87 #include "movinggc.c"
88 //#include "notify.c"
89 #include "opts.c"
90 //#include "request.c"
91 #include "siphash.c"
92 #include "six.c"
93 //#include "stats.c"
94 #include "super.c"
95 //#include "sysfs.c"
96 #include "tier.c"
97 #include "trace.c"
98 #include "util.c"
99 //#include "writeback.c"
100 #include "xattr.c"
101
102 #define SHIM_KTYPE(type)                                                \
103 struct kobj_type type ## _ktype = { .release = type ## _release, }
104
105 static void bch_cache_set_internal_release(struct kobject *k) {}
106
107 static void bch_cache_set_opts_dir_release(struct kobject *k) {}
108
109 static void bch_cache_set_time_stats_release(struct kobject *k) {}
110
111 SHIM_KTYPE(bch_cache);
112 SHIM_KTYPE(bch_cache_set);
113 SHIM_KTYPE(bch_cache_set_internal);
114 SHIM_KTYPE(bch_cache_set_time_stats);
115 SHIM_KTYPE(bch_cache_set_opts_dir);
116
117 //#include "tools-util.h"
118
119 int cmd_fsck(int argc, char *argv[])
120 {
121         DECLARE_COMPLETION_ONSTACK(shutdown);
122         struct cache_set_opts opts = cache_set_opts_empty();
123         struct cache_set *c = NULL;
124         const char *err;
125
126         printf("registering %s...\n", argv[1]);
127
128         err = bch_register_cache_set(argv + 1, argc - 1, opts, &c);
129         if (err) {
130                 BUG_ON(c);
131                 fprintf(stderr, "error opening %s: %s\n", argv[1], err);
132                 exit(EXIT_FAILURE);
133         }
134
135         c->stop_completion = &shutdown;
136         bch_cache_set_stop(c);
137         closure_put(&c->cl);
138
139         /* Killable? */
140         wait_for_completion(&shutdown);
141
142         return 0;
143 }