summaryrefslogtreecommitdiff
path: root/btrfsctl.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-03-24 15:04:49 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2008-03-24 15:04:49 -0400
commit26afd0f31d59853f51120622b0121cdfc72cd398 (patch)
tree7fb3b9c7039a676f5cd35b35b4ad6cebdaaec052 /btrfsctl.c
parent1f3ba6a3f9440a40108273dbbe4f37306be8d9ad (diff)
ioctls to scan for btrfs filesystems
Diffstat (limited to 'btrfsctl.c')
-rw-r--r--btrfsctl.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/btrfsctl.c b/btrfsctl.c
index 22f253a0..1518a13e 100644
--- a/btrfsctl.c
+++ b/btrfsctl.c
@@ -47,6 +47,7 @@ void print_usage(void)
printf("\t-s snap_name existing_subvol creates a new snapshot\n");
printf("\t-s snap_name tree_root creates a new subvolume\n");
printf("\t-r [+-]size[gkm] resize the FS\n");
+ printf("\t-a device scans the device for a Btrfs filesystem\n");
exit(1);
}
@@ -88,6 +89,12 @@ int main(int ac, char **av)
print_usage();
}
command = BTRFS_IOC_DEFRAG;
+ } else if (strcmp(av[i], "-a") == 0) {
+ if (i >= ac - 1) {
+ fprintf(stderr, "-a requires an arg\n");
+ print_usage();
+ }
+ command = BTRFS_IOC_SCAN_DEV;
} else if (strcmp(av[i], "-r") == 0) {
if (i >= ac - 1) {
fprintf(stderr, "-r requires an arg\n");
@@ -119,9 +126,14 @@ int main(int ac, char **av)
exit(1);
}
fd = dirfd(dirstream);
+ } else if (command == BTRFS_IOC_SCAN_DEV) {
+ fd = open("/dev/btrfs-control", O_RDWR);
+ printf("scanning %s command %lu\n", fname, BTRFS_IOC_SCAN_DEV);
+ name = fname;
} else {
fd = open(fname, O_RDWR);
- } if (fd < 0) {
+ }
+ if (fd < 0) {
perror("open");
exit(1);
}