// SPDX-License-Identifier: GPL-2.0-only /* * Code for looking up block devices in the early boot code before mounting the * root file system. */ #include <linux/blkdev.h> #include <linux/ctype.h> struct uuidcmp { … }; /** * match_dev_by_uuid - callback for finding a partition using its uuid * @dev: device passed in by the caller * @data: opaque pointer to the desired struct uuidcmp to match * * Returns 1 if the device matches, and 0 otherwise. */ static int __init match_dev_by_uuid(struct device *dev, const void *data) { … } /** * devt_from_partuuid - looks up the dev_t of a partition by its UUID * @uuid_str: char array containing ascii UUID * @devt: dev_t result * * The function will return the first partition which contains a matching * UUID value in its partition_meta_info struct. This does not search * by filesystem UUIDs. * * If @uuid_str is followed by a "/PARTNROFF=%d", then the number will be * extracted and used as an offset from the partition identified by the UUID. * * Returns 0 on success or a negative error code on failure. */ static int __init devt_from_partuuid(const char *uuid_str, dev_t *devt) { … } /** * match_dev_by_label - callback for finding a partition using its label * @dev: device passed in by the caller * @data: opaque pointer to the label to match * * Returns 1 if the device matches, and 0 otherwise. */ static int __init match_dev_by_label(struct device *dev, const void *data) { … } static int __init devt_from_partlabel(const char *label, dev_t *devt) { … } static dev_t __init blk_lookup_devt(const char *name, int partno) { … } static int __init devt_from_devname(const char *name, dev_t *devt) { … } static int __init devt_from_devnum(const char *name, dev_t *devt) { … } /* * Convert a name into device number. We accept the following variants: * * 1) <hex_major><hex_minor> device number in hexadecimal represents itself * no leading 0x, for example b302. * 3) /dev/<disk_name> represents the device number of disk * 4) /dev/<disk_name><decimal> represents the device number * of partition - device number of disk plus the partition number * 5) /dev/<disk_name>p<decimal> - same as the above, that form is * used when disk name of partitioned disk ends on a digit. * 6) PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF representing the * unique id of a partition if the partition table provides it. * The UUID may be either an EFI/GPT UUID, or refer to an MSDOS * partition using the format SSSSSSSS-PP, where SSSSSSSS is a zero- * filled hex representation of the 32-bit "NT disk signature", and PP * is a zero-filled hex representation of the 1-based partition number. * 7) PARTUUID=<UUID>/PARTNROFF=<int> to select a partition in relation to * a partition with a known unique id. * 8) <major>:<minor> major and minor number of the device separated by * a colon. * 9) PARTLABEL=<name> with name being the GPT partition label. * MSDOS partitions do not support labels! * * If name doesn't have fall into the categories above, we return (0,0). * block_class is used to check if something is a disk name. If the disk * name contains slashes, the device name has them replaced with * bangs. */ int __init early_lookup_bdev(const char *name, dev_t *devt) { … } static char __init *bdevt_str(dev_t devt, char *buf) { … } /* * print a full list of all partitions - intended for places where the root * filesystem can't be mounted and thus to give the victim some idea of what * went wrong */ void __init printk_all_partitions(void) { … }