]> git.sesse.net Git - bcachefs-tools-debian/blob - bcacheadm-assemble.c
Don't install udev hook - it's confusing with bcachefs
[bcachefs-tools-debian] / bcacheadm-assemble.c
1
2 #include <alloca.h>
3 #include <errno.h>
4 #include <stdbool.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8
9 #include <sys/ioctl.h>
10
11 #include <nih/command.h>
12 #include <nih/option.h>
13
14 #include "bcache.h"
15 #include "bcacheadm-assemble.h"
16
17 NihOption opts_assemble[] = {
18         NIH_OPTION_LAST
19 };
20
21 int cmd_assemble(NihCommand *command, char *const *args)
22 {
23         unsigned nr_devs = nr_args(args);
24
25         struct bch_ioctl_assemble *assemble =
26                 alloca(sizeof(*assemble) + sizeof(__u64) * nr_devs);
27
28         memset(assemble, 0, sizeof(*assemble));
29         assemble->nr_devs = nr_devs;
30
31         for (unsigned i = 0; i < nr_devs; i++)
32              assemble->devs[i] = (__u64) args[i];
33
34         int ret = ioctl(bcachectl_open(), BCH_IOCTL_ASSEMBLE, assemble);
35         if (ret < 0)
36                 die("BCH_IOCTL_ASSEMBLE error: %s", strerror(errno));
37
38         return 0;
39 }
40
41 NihOption opts_incremental[] = {
42         NIH_OPTION_LAST
43 };
44
45 int cmd_incremental(NihCommand *command, char *const *args)
46 {
47         if (nr_args(args) != 1)
48                 die("Please supply exactly one device");
49
50         struct bch_ioctl_incremental incremental = {
51                 .dev = (__u64) args[0],
52         };
53
54         int ret = ioctl(bcachectl_open(), BCH_IOCTL_INCREMENTAL, &incremental);
55         if (ret < 0)
56                 die("BCH_IOCTL_INCREMENTAL error: %s", strerror(errno));
57
58         return 0;
59 }