Lines Matching +full:uuid +full:- +full:dev

1 // SPDX-License-Identifier: GPL-2.0-only
10 const char *uuid; member
15 * match_dev_by_uuid - callback for finding a partition using its uuid
16 * @dev: device passed in by the caller
21 static int __init match_dev_by_uuid(struct device *dev, const void *data) in match_dev_by_uuid() argument
23 struct block_device *bdev = dev_to_bdev(dev); in match_dev_by_uuid()
26 if (!bdev->bd_meta_info || in match_dev_by_uuid()
27 strncasecmp(cmp->uuid, bdev->bd_meta_info->uuid, cmp->len)) in match_dev_by_uuid()
33 * devt_from_partuuid - looks up the dev_t of a partition by its UUID
34 * @uuid_str: char array containing ascii UUID
38 * UUID value in its partition_meta_info struct. This does not search
42 * extracted and used as an offset from the partition identified by the UUID.
49 struct device *dev = NULL; in devt_from_partuuid() local
53 cmp.uuid = uuid_str; in devt_from_partuuid()
63 cmp.len = slash - uuid_str; in devt_from_partuuid()
71 dev = class_find_device(&block_class, NULL, &cmp, &match_dev_by_uuid); in devt_from_partuuid()
72 if (!dev) in devt_from_partuuid()
73 return -ENODEV; in devt_from_partuuid()
78 * to the partition number found by UUID. in devt_from_partuuid()
80 *devt = part_devt(dev_to_disk(dev), in devt_from_partuuid()
81 dev_to_bdev(dev)->bd_partno + offset); in devt_from_partuuid()
83 *devt = dev->devt; in devt_from_partuuid()
86 put_device(dev); in devt_from_partuuid()
91 "Expected PARTUUID=<valid-uuid-id>[/PARTNROFF=%%d]\n"); in devt_from_partuuid()
92 return -EINVAL; in devt_from_partuuid()
96 * match_dev_by_label - callback for finding a partition using its label
97 * @dev: device passed in by the caller
102 static int __init match_dev_by_label(struct device *dev, const void *data) in match_dev_by_label() argument
104 struct block_device *bdev = dev_to_bdev(dev); in match_dev_by_label()
107 if (!bdev->bd_meta_info || strcmp(label, bdev->bd_meta_info->volname)) in match_dev_by_label()
114 struct device *dev; in devt_from_partlabel() local
116 dev = class_find_device(&block_class, NULL, label, &match_dev_by_label); in devt_from_partlabel()
117 if (!dev) in devt_from_partlabel()
118 return -ENODEV; in devt_from_partlabel()
119 *devt = dev->devt; in devt_from_partlabel()
120 put_device(dev); in devt_from_partlabel()
128 struct device *dev; in blk_lookup_devt() local
131 while ((dev = class_dev_iter_next(&iter))) { in blk_lookup_devt()
132 struct gendisk *disk = dev_to_disk(dev); in blk_lookup_devt()
134 if (strcmp(dev_name(dev), name)) in blk_lookup_devt()
137 if (partno < disk->minors) { in blk_lookup_devt()
141 devt = MKDEV(MAJOR(dev->devt), in blk_lookup_devt()
142 MINOR(dev->devt) + partno); in blk_lookup_devt()
160 return -EINVAL; in devt_from_devname()
172 * Try non-existent, but valid partition, which may only exist after in devt_from_devname()
175 while (p > s && isdigit(p[-1])) in devt_from_devname()
176 p--; in devt_from_devname()
178 return -ENODEV; in devt_from_devname()
188 if (p < s + 2 || !isdigit(p[-2]) || p[-1] != 'p') in devt_from_devname()
189 return -ENODEV; in devt_from_devname()
190 p[-1] = '\0'; in devt_from_devname()
194 return -ENODEV; in devt_from_devname()
206 return -EINVAL; in devt_from_devnum()
210 return -EINVAL; in devt_from_devnum()
221 * 3) /dev/<disk_name> represents the device number of disk
222 * 4) /dev/<disk_name><decimal> represents the device number
223 * of partition - device number of disk plus the partition number
224 * 5) /dev/<disk_name>p<decimal> - same as the above, that form is
226 * 6) PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF representing the
228 * The UUID may be either an EFI/GPT UUID, or refer to an MSDOS
229 * partition using the format SSSSSSSS-PP, where SSSSSSSS is a zero-
230 * filled hex representation of the 32-bit "NT disk signature", and PP
231 * is a zero-filled hex representation of the 1-based partition number.
232 * 7) PARTUUID=<UUID>/PARTNROFF=<int> to select a partition in relation to
250 if (strncmp(name, "/dev/", 5) == 0) in early_lookup_bdev()
260 snprintf(buf, BDEVT_SIZE, "%-9s", tbuf); in bdevt_str()
268 * print a full list of all partitions - intended for places where the root
275 struct device *dev; in printk_all_partitions() local
278 while ((dev = class_dev_iter_next(&iter))) { in printk_all_partitions()
279 struct gendisk *disk = dev_to_disk(dev); in printk_all_partitions()
288 if (get_capacity(disk) == 0 || (disk->flags & GENHD_FL_HIDDEN)) in printk_all_partitions()
293 * hex - the same format as the root= option takes. in printk_all_partitions()
296 xa_for_each(&disk->part_tbl, idx, part) { in printk_all_partitions()
301 bdevt_str(part->bd_dev, devt_buf), in printk_all_partitions()
303 part->bd_meta_info ? in printk_all_partitions()
304 part->bd_meta_info->uuid : ""); in printk_all_partitions()
307 else if (dev->parent && dev->parent->driver) in printk_all_partitions()
309 dev->parent->driver->name); in printk_all_partitions()