--- linux-3.7.1/init/do_mounts.c +++ ../linux-3.7.1/init/do_mounts.c @@ -160,6 +160,63 @@ done: return res; } + +/** + * match_dev_by_label - callback for finding a partition using its label + * @dev: device passed in by the caller + * @data: opaque pointer to a char array with a label + * + * Returns 1 if the device matches, and 0 otherwise. + */ +#include +static int match_dev_by_label(struct device *dev, void *data) +{ + char* e4label; + struct buffer_head *bh; + struct hd_struct *part = dev_to_part(dev); + struct gendisk* disk = part_to_disk(part); + struct block_device* bdev = bdget_disk(disk, part->partno); + + if(part->nr_sects < 1000) + return 0; + + if(blkdev_get(bdev, FMODE_READ, NULL)) + return 0; + + if (!(bh = __bread(bdev, 0, 2048))) + return 0; + + e4label = ((char *) bh->b_data) + 0x478; + printk("match_dev_by_label %s : %s\n", data, e4label); + if (strncmp(e4label, data, strlen(data)) == 0) { + brelse(bh); + return 1; + } + + brelse(bh); + return 0; +} + + +/** + * devt_from_partlabel - looks up the dev_t of a partition by its label + * + * Returns the matching dev_t on success or 0 on failure. + */ +static dev_t devt_from_partlabel(char *label_str) +{ + dev_t res = 0; + struct device *dev = NULL; + + dev = class_find_device(&block_class, NULL, label_str, &match_dev_by_label); + if (!dev) + goto done; + + res = dev->devt; + put_device(dev); +done: + return res; +} #endif /* @@ -176,6 +233,8 @@ * unique id of a partition if the partition table provides it. * 7) PARTUUID=/PARTNROFF= to select a partition in relation to * a partition with a known unique id. + * 8) LABEL=