summaryrefslogtreecommitdiff
path: root/btrfs.c
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2013-02-12 21:24:50 +0200
committerDavid Sterba <dsterba@suse.cz>2013-02-12 22:55:28 +0100
commitd5d2046ae3b216af22a8a37c940f2412ba519b6e (patch)
treeff5f4fba089308f7dcbc9539997784a17ebf23a7 /btrfs.c
parent2f4e4e448fb34773728c0e2ef93be8d456a039cb (diff)
Btrfs-progs: add btrfsck name detection to btrfs
This patch adds a busybox-style name detection for the name "btrfsck" to btrfs utility. The idea is to maintain backwards compatibility by linking btrfsck to btrfs and have btrfs invoke the check sub-command when called through the btrfsck link. This has been suggested on the mailing list and approved by Dave and Chris. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'btrfs.c')
-rw-r--r--btrfs.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/btrfs.c b/btrfs.c
index 062bc515..a7dc50d8 100644
--- a/btrfs.c
+++ b/btrfs.c
@@ -262,16 +262,26 @@ const struct cmd_group btrfs_cmd_group = {
int main(int argc, char **argv)
{
const struct cmd_struct *cmd;
+ const char *bname;
- argc--;
- argv++;
- handle_options(&argc, &argv);
- if (argc > 0) {
- if (!prefixcmp(argv[0], "--"))
- argv[0] += 2;
+ if ((bname = strrchr(argv[0], '/')) != NULL)
+ bname++;
+ else
+ bname = argv[0];
+
+ if (!strcmp(bname, "btrfsck")) {
+ argv[0] = "check";
} else {
- usage_command_group(&btrfs_cmd_group, 0, 0);
- exit(1);
+ argc--;
+ argv++;
+ handle_options(&argc, &argv);
+ if (argc > 0) {
+ if (!prefixcmp(argv[0], "--"))
+ argv[0] += 2;
+ } else {
+ usage_command_group(&btrfs_cmd_group, 0, 0);
+ exit(1);
+ }
}
cmd = parse_command_token(argv[0], &btrfs_cmd_group);