#include "xalloc.h"
#include "mangle.h"
#include "path.h"
+#include "nls.h"
#include "lsblk.h"
return;
free(p->fstype);
+ free(p->fsversion);
free(p->uuid);
free(p->ptuuid);
free(p->pttype);
}
if ((data = udev_device_get_property_value(dev, "ID_FS_TYPE")))
prop->fstype = xstrdup(data);
+ if ((data = udev_device_get_property_value(dev, "ID_FS_VERSION")))
+ prop->fsversion = xstrdup(data);
if ((data = udev_device_get_property_value(dev, "ID_PART_ENTRY_TYPE")))
prop->parttype = xstrdup(data);
if ((data = udev_device_get_property_value(dev, "ID_PART_ENTRY_UUID")))
else if (lookup(buf, "ID_PART_TABLE_UUID", &prop->ptuuid)) ;
else if (lookup(buf, "ID_PART_TABLE_TYPE", &prop->pttype)) ;
else if (lookup(buf, "ID_FS_TYPE", &prop->fstype)) ;
+ else if (lookup(buf, "ID_FS_VERSION", &prop->fsversion)) ;
else if (lookup(buf, "ID_PART_ENTRY_TYPE", &prop->parttype)) ;
else if (lookup(buf, "ID_PART_ENTRY_UUID", &prop->partuuid)) ;
else if (lookup(buf, "ID_PART_ENTRY_FLAGS", &prop->partflags)) ;
prop->pttype = xstrdup(data);
if (!blkid_probe_lookup_value(pr, "LABEL", &data, NULL))
prop->label = xstrdup(data);
+ if (!blkid_probe_lookup_value(pr, "VERSION", &data, NULL))
+ prop->fsversion = xstrdup(data);
if (!blkid_probe_lookup_value(pr, "PART_ENTRY_TYPE", &data, NULL))
prop->parttype = xstrdup(data);
if (!blkid_probe_lookup_value(pr, "PART_ENTRY_UUID", &data, NULL))
udev_unref(udev);
#endif
}
+
+
+
+/*
+ * Partition types
+ */
+struct lsblk_parttype {
+ unsigned int code; /* type as number or zero */
+ char *name; /* description */
+ char *typestr; /* type as string or NULL */
+};
+
+static const struct lsblk_parttype mbr_types[] =
+{
+ #include "pt-mbr-partnames.h"
+};
+
+#define DEF_GUID(_u, _n) \
+ { \
+ .typestr = (_u), \
+ .name = (_n), \
+ }
+static const struct lsblk_parttype gpt_types[] =
+{
+ #include "pt-gpt-partnames.h"
+};
+
+const char *lsblk_parttype_code_to_string(const char *code, const char *pttype)
+{
+ size_t i;
+
+ if (!code || !pttype)
+ return NULL;
+
+ if (strcmp(pttype, "dos") == 0 || strcmp(pttype, "mbr") == 0) {
+ char *end = NULL;
+ unsigned int xcode;
+
+ errno = 0;
+ xcode = strtol(code, &end, 16);
+
+ if (errno || *end != '\0')
+ return NULL;
+
+ for (i = 0; i < ARRAY_SIZE(mbr_types); i++) {
+ const struct lsblk_parttype *t = &mbr_types[i];
+
+ if (t->name && t->code == xcode)
+ return t->name;
+ }
+
+ } else if (strcmp(pttype, "gpt") == 0) {
+ for (i = 0; i < ARRAY_SIZE(gpt_types); i++) {
+ const struct lsblk_parttype *t = &gpt_types[i];
+
+ if (t->name && t->typestr &&
+ strcasecmp(code, t->typestr) == 0)
+ return t->name;
+ }
+ }
+
+ return NULL;
+}