summaryrefslogtreecommitdiffstats
path: root/qa/btrfs/create_async_snap.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /qa/btrfs/create_async_snap.c
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'qa/btrfs/create_async_snap.c')
-rw-r--r--qa/btrfs/create_async_snap.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/qa/btrfs/create_async_snap.c b/qa/btrfs/create_async_snap.c
new file mode 100644
index 000000000..2ef22af7b
--- /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;
+}