uint8_t system, sysbus, acpi_id;
uint16_t pnp_id;
int ndbus, region, btt_region_id, btt_id, rc, pos;
+ char *namespace = NULL;
debug(DEBUG, "entry");
* but the UUID we really do need to have.
*/
rc = read_sysfs_file(&filebuf,
- "class/block/%s/device/uuid", dev->disk_name);
+ "class/block/%s/device/namespace", dev->disk_name);
if ((rc < 0 && errno == ENOENT) || filebuf == NULL)
return -1;
- rc = efi_str_to_guid((char *)filebuf, &dev->nvdimm_label);
+ rc = sscanf((char *)filebuf, "%ms[^\n]\n", &namespace);
+ if (rc != 1 || namespace == NULL)
+ return -1;
+
+ filebuf = NULL;
+ debug(DEBUG, "nvdimm namespace is \"%s\"", namespace);
+ rc = read_sysfs_file(&filebuf, "bus/nd/devices/%s/uuid", namespace);
+ free(namespace);
+ if (rc < 0 || filebuf == NULL)
+ return -1;
+
+ rc = efi_str_to_guid((char *)filebuf,
+ &dev->nvdimm_info.namespace_label);
+ if (rc < 0)
+ return -1;
+
+ filebuf = NULL;
+ rc = read_sysfs_file(&filebuf, "class/block/%s/device/uuid",
+ dev->disk_name);
+ if (rc < 0 || filebuf == NULL)
+ return -1;
+
+ rc = efi_str_to_guid((char *)filebuf,
+ &dev->nvdimm_info.nvdimm_label);
if (rc < 0)
return -1;
- /* UUIDs are stored opposite Endian from GUIDs, so our normal GUID
- * parser is giving us the wrong thing; swizzle those bytes around.
+ /*
+ * Right now it's not clear what encoding NVDIMM($uuid) gets in the
+ * binary format, so this will be in the mixed endian format EFI GUIDs
+ * are in (33221100-1100-1100-0011-223344556677) unless you set this
+ * variable.
*/
- swizzle_guid_to_uuid(&dev->nvdimm_label);
+ if (getenv("LIBEFIBOOT_SWIZZLE_PMEM_UUID") != NULL) {
+ swizzle_guid_to_uuid(&dev->nvdimm_info.namespace_label);
+ swizzle_guid_to_uuid(&dev->nvdimm_info.nvdimm_label);
+ }
dev->interface_type = nd_pmem;
dp_create_pmem(struct device *dev,
uint8_t *buf, ssize_t size, ssize_t off)
{
- ssize_t sz;
+ ssize_t sz, sz1;
debug(DEBUG, "entry");
sz = efidp_make_nvdimm(buf + off, size ? size - off : 0,
- &dev->nvdimm_label);
-
- return sz;
+ &dev->nvdimm_info.namespace_label);
+ if (sz < 0)
+ return sz;
+ off += sz;
+ sz1 = efidp_make_nvdimm(buf + off, size ? size - off : 0,
+ &dev->nvdimm_info.nvdimm_label);
+ if (sz1 < 0)
+ return sz1;
+
+ return sz + sz1;
}
enum interface_type pmem_iftypes[] = { nd_pmem, unknown };