diff options
author | Sage Weil <sage@newdream.net> | 2012-02-10 14:03:44 -0800 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2012-02-10 14:39:12 -0800 |
commit | 3c5dcf8958b2510479a3697fb43b064829f01406 (patch) | |
tree | a95b3b715eb5acb0004a6fcf70c3b866abc75a58 /qa | |
parent | e369ec158962f16660102c95b3e486a5415f4aff (diff) | |
download | ceph-3c5dcf8958b2510479a3697fb43b064829f01406.tar.gz |
qa/btrfs/create_async_snap
Stupid tool to call the async snap ioctl. Until the btrfs tool does it.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'qa')
-rw-r--r-- | qa/btrfs/Makefile | 2 | ||||
-rw-r--r-- | qa/btrfs/create_async_snap.c | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/qa/btrfs/Makefile b/qa/btrfs/Makefile index 354948c16bc..be95ecfd3cd 100644 --- a/qa/btrfs/Makefile +++ b/qa/btrfs/Makefile @@ -1,6 +1,6 @@ CFLAGS = -Wall -Wextra -D_GNU_SOURCE -TARGETS = clone_range test_async_snap +TARGETS = clone_range test_async_snap create_async_snap .c: $(CC) $(CFLAGS) $@.c -o $@ diff --git a/qa/btrfs/create_async_snap.c b/qa/btrfs/create_async_snap.c new file mode 100644 index 00000000000..2ef22af7b45 --- /dev/null +++ b/qa/btrfs/create_async_snap.c @@ -0,0 +1,34 @@ +#include <stdlib.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> +#include <stdio.h> +#include <sys/ioctl.h> +#include <string.h> + +#include <linux/ioctl.h> +#include <linux/types.h> +#include "../../src/os/btrfs_ioctl.h" + +struct btrfs_ioctl_vol_args_v2 va; + +int main(int argc, char **argv) +{ + int fd; + int r; + + if (argc != 3) { + printf("usage: %s <source subvol> <name>\n", argv[0]); + return 1; + } + printf("creating snap ./%s from %s\n", argv[2], argv[1]); + fd = open(".", O_RDONLY); + va.fd = open(argv[1], O_RDONLY); + va.flags = BTRFS_SUBVOL_CREATE_ASYNC; + strcpy(va.name, argv[2]); + r = ioctl(fd, BTRFS_IOC_SNAP_CREATE_V2, (unsigned long long)&va); + printf("result %d\n", r ? -errno:0); + return r; +} |