summaryrefslogtreecommitdiff
path: root/btrfsctl.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-08-07 16:15:59 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-08-07 16:15:59 -0400
commit0528b69c1507dbbde9038e7705fc15cc06e9f33b (patch)
tree370c0d5490d4b17aa603c907bf8575af0976c185 /btrfsctl.c
parent330f6227aa409f720157fcef35bc8642190a2fb1 (diff)
add defrag ioctl
Diffstat (limited to 'btrfsctl.c')
-rw-r--r--btrfsctl.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/btrfsctl.c b/btrfsctl.c
index ae2f27b3..4dfc42bd 100644
--- a/btrfsctl.c
+++ b/btrfsctl.c
@@ -77,6 +77,12 @@ int main(int ac, char **av)
exit(1);
}
command = BTRFS_IOC_SNAP_CREATE;
+ } else if (strcmp(av[i], "-d") == 0) {
+ if (i >= ac - 1) {
+ fprintf(stderr, "-d requires an arg");
+ print_usage();
+ }
+ command = BTRFS_IOC_DEFRAG;
}
}
if (command == 0) {
@@ -102,7 +108,10 @@ int main(int ac, char **av)
perror("open");
exit(1);
}
- strcpy(args.name, name);
+ if (name)
+ strcpy(args.name, name);
+ else
+ args.name[0] = '\0';
ret = ioctl(fd, command, &args);
printf("ioctl returns %d\n", ret);
return 0;