Skip to content

Commit f1894dc

Browse files
committed
btrfs-progs: mkfs: print label of existing filesystem
For better identification also print the label (if set) found on the image when -f is not used: $ mkfs.btrfs --label=TEST img $ mkfs.btrfs img ERROR: img appears to contain an existing filesystem (type=btrfs, label=TEST) ERROR: use the -f option to force overwrite of img Signed-off-by: David Sterba <[email protected]>
1 parent 7e2ce5a commit f1894dc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mkfs/common.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,12 @@ static int check_overwrite(const char *device)
10491049
}
10501050

10511051
if (!blkid_probe_lookup_value(pr, "TYPE", &type, NULL)) {
1052-
error("%s appears to contain an existing filesystem (%s)", device, type);
1052+
const char *label = NULL;
1053+
1054+
blkid_probe_lookup_value(pr, "LABEL", &label, NULL);
1055+
1056+
error("%s appears to contain an existing filesystem (type=%s%s%s)",
1057+
device, type, (label ? ", label=" : ""), (label ? label : ""));
10531058
} else if (!blkid_probe_lookup_value(pr, "PTTYPE", &type, NULL)) {
10541059
error("%s appears to contain a partition table (%s)", device, type);
10551060
} else {

0 commit comments

Comments
 (0)