Patch: Allow options to be passed to btrfsck
diff mbox

Message ID 201002111409.39348.sten.heinze@gmx.de
State New, archived
Headers show

Commit Message

Sten Heinze Feb. 11, 2010, 1:09 p.m. UTC
None

Patch
diff mbox

Index: btrfs-tools/btrfsck.c
===================================================================
--- btrfs-tools.orig/btrfsck.c	2010-02-08 05:44:01.037134357 +0100
+++ btrfs-tools/btrfsck.c	2010-02-11 05:02:15.469358404 +0100
@@ -2807,7 +2807,7 @@ 
 
 static void print_usage(void)
 {
-	fprintf(stderr, "usage: btrfsck dev\n");
+	fprintf(stderr, "usage: btrfsck [option] dev\n");
 	fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
 	exit(1);
 }
@@ -2821,9 +2821,24 @@ 
 	if (ac < 2)
 		print_usage();
 
+	char *file = av[ac - 1];
+	int pos;
+	for( pos = 1; pos < ac; ++pos)
+	{
+		/* ignore all options for now, stop at first device found */
+		if (av[pos][0] != '-')
+		{
+			file = av[pos];
+			break;
+		}
+	}
+
+	/* print device fsck'ed */
+	printf("%s: ", file);
+
 	radix_tree_init();
 	cache_tree_init(&root_cache);
-	root = open_ctree(av[1], 0, 0);
+	root = open_ctree(file, 0, 0);
 
 	if (root == NULL)
 		return 1;