|
@@ -167,6 +167,24 @@ done:
|
|
}
|
|
}
|
|
return res;
|
|
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 the label to match
|
|
|
|
+ *
|
|
|
|
+ * Returns 1 if the device matches, and 0 otherwise.
|
|
|
|
+ */
|
|
|
|
+static int match_dev_by_label(struct device *dev, const void *data)
|
|
|
|
+{
|
|
|
|
+ const char *label = data;
|
|
|
|
+ struct hd_struct *part = dev_to_part(dev);
|
|
|
|
+
|
|
|
|
+ if (part->info && !strcmp(label, part->info->volname))
|
|
|
|
+ return 1;
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -190,6 +208,8 @@ done:
|
|
* a partition with a known unique id.
|
|
* a partition with a known unique id.
|
|
* 8) <major>:<minor> major and minor number of the device separated by
|
|
* 8) <major>:<minor> major and minor number of the device separated by
|
|
* a colon.
|
|
* 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).
|
|
* 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
|
|
* block_class is used to check if something is a disk name. If the disk
|
|
@@ -211,6 +231,17 @@ dev_t name_to_dev_t(const char *name)
|
|
if (!res)
|
|
if (!res)
|
|
goto fail;
|
|
goto fail;
|
|
goto done;
|
|
goto done;
|
|
|
|
+ } else if (strncmp(name, "PARTLABEL=", 10) == 0) {
|
|
|
|
+ struct device *dev;
|
|
|
|
+
|
|
|
|
+ dev = class_find_device(&block_class, NULL, name + 10,
|
|
|
|
+ &match_dev_by_label);
|
|
|
|
+ if (!dev)
|
|
|
|
+ goto fail;
|
|
|
|
+
|
|
|
|
+ res = dev->devt;
|
|
|
|
+ put_device(dev);
|
|
|
|
+ goto done;
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|