Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / qa / btrfs / create_async_snap.c
1 #include <stdlib.h>
2 #include <unistd.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <errno.h>
7 #include <stdio.h>
8 #include <sys/ioctl.h>
9 #include <string.h>
10
11 #include <linux/ioctl.h>
12 #include <linux/types.h>
13 #include "../../src/os/btrfs_ioctl.h"
14
15 struct btrfs_ioctl_vol_args_v2 va;
16
17 int main(int argc, char **argv)
18 {
19         int fd;
20         int r;
21
22         if (argc != 3) {
23                 printf("usage: %s <source subvol> <name>\n", argv[0]);
24                 return 1;
25         }
26         printf("creating snap ./%s from %s\n", argv[2], argv[1]);
27         fd = open(".", O_RDONLY);
28         va.fd = open(argv[1], O_RDONLY);
29         va.flags = BTRFS_SUBVOL_CREATE_ASYNC;
30         strcpy(va.name, argv[2]);
31         r = ioctl(fd, BTRFS_IOC_SNAP_CREATE_V2, (unsigned long long)&va);
32         printf("result %d\n", r ? -errno:0);
33         return r;
34 }