drop the inode map tree
[btrfs-progs-unstable.git] / btrfsctl.c
blobcab846b05d448474cf04e4994765f306bcb05ba7
1 #ifndef __CHECKER__
2 #include <sys/ioctl.h>
3 #include <sys/mount.h>
4 #include "ioctl.h"
5 #endif
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <sys/types.h>
9 #include <sys/stat.h>
10 #include <fcntl.h>
11 #include <unistd.h>
12 #include "kerncompat.h"
14 #ifdef __CHECKER__
15 #define BLKGETSIZE64 0
16 #define BTRFS_IOC_SNAP_CREATE 0
17 #define BTRFS_VOL_NAME_MAX 255
18 struct btrfs_ioctl_vol_args { char name[BTRFS_VOL_NAME_MAX]; };
19 static inline int ioctl(int fd, int define, void *arg) { return 0; }
20 #endif
22 void print_usage(void)
24 printf("usage: btrfsctl [ -s snapshot_name ] dir\n");
25 exit(1);
28 int main(int ac, char **av)
30 char *fname;
31 int fd;
32 int ret;
33 struct btrfs_ioctl_vol_args args;
34 char *name;
35 int i;
37 for (i = 1; i < ac - 1; i++) {
38 if (strcmp(av[i], "-s") == 0) {
39 if (i + 1 >= ac - 1) {
40 fprintf(stderr, "-s requires an arg");
41 print_usage();
43 name = av[i + 1];
44 if (strlen(name) >= BTRFS_VOL_NAME_MAX) {
45 fprintf(stderr, "snapshot name is too long\n");
46 exit(1);
50 fname = av[ac - 1];
51 printf("fname is %s\n", fname);
52 fd = open(fname, O_RDWR);
53 if (fd < 0) {
54 perror("open");
55 exit(1);
57 strcpy(args.name, name);
58 ret = ioctl(fd, BTRFS_IOC_SNAP_CREATE, &args);
59 printf("ioctl returns %d\n", ret);
60 return 0;