Skip to content

Commit

Permalink
always iterate over the returned values from blkid
Browse files Browse the repository at this point in the history
this fixes trying to mount a multi device btrfs root as its subvol UUID.
  • Loading branch information
falconindy committed May 12, 2011
1 parent 79f099b commit 91f7aa0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions init.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ static void start_rescue_shell(void) { /* {{{ */

static char *probe_fstype(const char *devname) { /* {{{ */
int ret;
char *fstype;
char *fstype = NULL;
blkid_probe pr;

pr = blkid_new_probe_from_filename(devname);
Expand All @@ -389,8 +389,17 @@ static char *probe_fstype(const char *devname) { /* {{{ */
return NULL;
} else {
const char *name, *data;
blkid_probe_get_value(pr, 0, &name, &data, NULL);
fstype = strdup(data);
int i, nvals = blkid_probe_numof_values(pr);

/* btrfs (maybe others) returns more than just its fstype here so we're
* forced to iterate over the data to find the one true 'TYPE' */
for (i = 0; i < nvals; i++) {
blkid_probe_get_value(pr, i, &name, &data, NULL);
if (strcmp(name, "TYPE") == 0) {
fstype = strdup(data);
break;
}
}
}

blkid_free_probe(pr);
Expand Down

0 comments on commit 91f7aa0

Please sign in to comment.