]> git.sesse.net Git - bcachefs-tools-debian/blob - bcache-run.c
Rework option handling
[bcachefs-tools-debian] / bcache-run.c
1
2 #include <errno.h>
3 #include <stdbool.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7
8 #include <fcntl.h>
9 #include <sys/ioctl.h>
10 #include <unistd.h>
11
12 #include <nih/option.h>
13
14 #include <uuid/uuid.h>
15
16 #include "bcache.h"
17
18 int cmd_run(int argc, char *argv[])
19 {
20         NihOption opts[] = {
21                 NIH_OPTION_LAST
22         };
23         bch_nih_init(argc, argv, opts);
24
25         return 0;
26 }
27
28 int cmd_stop(int argc, char *argv[])
29 {
30         NihOption opts[] = {
31                 NIH_OPTION_LAST
32         };
33         char **args = bch_nih_init(argc, argv, opts);
34
35         if (nr_args(args) != 1)
36                 die("Please supply a filesystem");
37
38         struct bcache_handle fs = bcache_fs_open(args[0]);
39
40         if (ioctl(fs.fd, BCH_IOCTL_STOP))
41                 die("BCH_IOCTL_STOP error: %s", strerror(errno));
42
43         return 0;
44 }