forked from Mirrors/btrfs-progs
btrfsctl: add snapshot/subvolume destroy ioctl
resend Aaron Straus's patch Signed-off-by: Yan Zheng <zheng.yan@oracle.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>master
parent
4f89b6eb07
commit
45195b216d
15
btrfsctl.c
15
btrfsctl.c
|
@ -46,7 +46,7 @@ static inline int ioctl(int fd, int define, void *arg) { return 0; }
|
||||||
static void print_usage(void)
|
static void print_usage(void)
|
||||||
{
|
{
|
||||||
printf("usage: btrfsctl [ -d file|dir] [ -s snap_name subvol|tree ]\n");
|
printf("usage: btrfsctl [ -d file|dir] [ -s snap_name subvol|tree ]\n");
|
||||||
printf(" [-r size] [-A device] [-a] [-c]\n");
|
printf(" [-r size] [-A device] [-a] [-c] [-D dir .]\n");
|
||||||
printf("\t-d filename: defragments one file\n");
|
printf("\t-d filename: defragments one file\n");
|
||||||
printf("\t-d directory: defragments the entire Btree\n");
|
printf("\t-d directory: defragments the entire Btree\n");
|
||||||
printf("\t-s snap_name dir: creates a new snapshot of dir\n");
|
printf("\t-s snap_name dir: creates a new snapshot of dir\n");
|
||||||
|
@ -55,6 +55,7 @@ static void print_usage(void)
|
||||||
printf("\t-A device: scans the device file for a Btrfs filesystem\n");
|
printf("\t-A device: scans the device file for a Btrfs filesystem\n");
|
||||||
printf("\t-a: scans all devices for Btrfs filesystems\n");
|
printf("\t-a: scans all devices for Btrfs filesystems\n");
|
||||||
printf("\t-c: forces a single FS sync\n");
|
printf("\t-c: forces a single FS sync\n");
|
||||||
|
printf("\t-D: delete snapshot\n");
|
||||||
printf("%s\n", BTRFS_BUILD_VERSION);
|
printf("%s\n", BTRFS_BUILD_VERSION);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -158,6 +159,18 @@ int main(int ac, char **av)
|
||||||
print_usage();
|
print_usage();
|
||||||
}
|
}
|
||||||
command = BTRFS_IOC_DEFRAG;
|
command = BTRFS_IOC_DEFRAG;
|
||||||
|
} else if (strcmp(av[i], "-D") == 0) {
|
||||||
|
if (i >= ac - 1) {
|
||||||
|
fprintf(stderr, "-D requires an arg\n");
|
||||||
|
print_usage();
|
||||||
|
}
|
||||||
|
command = BTRFS_IOC_SNAP_DESTROY;
|
||||||
|
name = av[i + 1];
|
||||||
|
len = strlen(name);
|
||||||
|
if (len == 0 || len >= BTRFS_VOL_NAME_MAX) {
|
||||||
|
fprintf(stderr, "-D size too long\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
} else if (strcmp(av[i], "-A") == 0) {
|
} else if (strcmp(av[i], "-A") == 0) {
|
||||||
if (i >= ac - 1) {
|
if (i >= ac - 1) {
|
||||||
fprintf(stderr, "-A requires an arg\n");
|
fprintf(stderr, "-A requires an arg\n");
|
||||||
|
|
3
ioctl.h
3
ioctl.h
|
@ -56,4 +56,7 @@ struct btrfs_ioctl_vol_args {
|
||||||
/* 13 is for CLONE_RANGE */
|
/* 13 is for CLONE_RANGE */
|
||||||
#define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
|
#define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
|
||||||
struct btrfs_ioctl_vol_args)
|
struct btrfs_ioctl_vol_args)
|
||||||
|
|
||||||
|
#define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
|
||||||
|
struct btrfs_ioctl_vol_args)
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue