int fd = -1;
int saved_errno;
- debug(DEBUG, "partition:%d", partition);
+ debug("partition:%d", partition);
if (buf && size)
memset(buf, '\0', size);
if (partition < 0) {
int disk_fd;
- debug(DEBUG, "partition: %d", partition);
+ debug("partition: %d", partition);
disk_fd = open_disk(dev,
(options & EFIBOOT_OPTIONS_WRITE_SIGNATURE)
? O_RDWR : O_RDONLY);
partition = 1;
else
partition = 0;
- debug(DEBUG, "is_partitioned(): partition -> %d", partition);
+ debug("is_partitioned(): partition -> %d", partition);
close(disk_fd);
}
}
if (options & EFIBOOT_ABBREV_NONE)
- debug(DEBUG, "EFIBOOT_ABBREV_NONE");
+ debug("EFIBOOT_ABBREV_NONE");
if (options & EFIBOOT_ABBREV_HD)
- debug(DEBUG, "EFIBOOT_ABBREV_HD");
+ debug("EFIBOOT_ABBREV_HD");
if (options & EFIBOOT_ABBREV_FILE)
- debug(DEBUG, "EFIBOOT_ABBREV_FILE");
+ debug("EFIBOOT_ABBREV_FILE");
if (options & EFIBOOT_ABBREV_EDD10)
- debug(DEBUG, "EFIBOOT_ABBREV_EDD10");
+ debug("EFIBOOT_ABBREV_EDD10");
if (options & EFIBOOT_ABBREV_EDD10) {
va_list aq;
if (!(options & (EFIBOOT_ABBREV_FILE|EFIBOOT_ABBREV_HD)) &&
(dev->flags & DEV_ABBREV_ONLY)) {
+ efi_error_clear();
errno = EINVAL;
efi_error("Device must use File() or HD() device path");
goto err;
if (fd >= 0)
close(fd);
errno = saved_errno;
- debug(DEBUG, "= %zd", ret);
+ debug("= %zd", ret);
return ret;
}
{
ssize_t off = 0;
- debug(DEBUG, "hid:0x%08x hidstr:\"%s\"", dp->acpi_hid_ex.hid, hidstr);
- debug(DEBUG, "cid:0x%08x cidstr:\"%s\"", dp->acpi_hid_ex.cid, cidstr);
- debug(DEBUG, "uid:0x%08x uidstr:\"%s\"", dp->acpi_hid_ex.uid, uidstr);
+ debug("hid:0x%08x hidstr:\"%s\"", dp->acpi_hid_ex.hid, hidstr);
+ debug("cid:0x%08x cidstr:\"%s\"", dp->acpi_hid_ex.cid, cidstr);
+ debug("uid:0x%08x uidstr:\"%s\"", dp->acpi_hid_ex.uid, uidstr);
if (!hidstr && !cidstr && (uidstr || dp->acpi_hid_ex.uid)) {
format(buf, size, off, "AcpiExp",
// size_t cidlen = 0;
if (dp->subtype == EFIDP_ACPI_ADR) {
- debug(DEBUG, "formatting ACPI _ADR");
+ debug("formatting ACPI _ADR");
format_acpi_adr(buf, size, off, dp);
return off;
} else if (dp->subtype != EFIDP_ACPI_HID_EX &&
dp->subtype != EFIDP_ACPI_HID) {
- debug(DEBUG, "DP subtype %d, formatting as ACPI Path", dp->subtype);
+ debug("DP subtype %d, formatting as ACPI Path", dp->subtype);
format(buf, size, off, "AcpiPath", "AcpiPath(%d,", dp->subtype);
format_hex(buf, size, off, "AcpiPath", (uint8_t *)dp+4,
(efidp_node_size(dp)-4) / 2);
ssize_t limit = efidp_node_size(dp)
- offsetof(efidp_acpi_hid_ex, hidstr);
- debug(DEBUG, "formatting ACPI HID EX");
+ debug("formatting ACPI HID EX");
hidstr = dp->acpi_hid_ex.hidstr;
hidlen = strnlen(hidstr, limit);
limit -= hidlen + 1;
break;
}
default:
- debug(DEBUG, "Decoding non-well-known HID");
+ debug("Decoding non-well-known HID");
switch (dp->subtype) {
case EFIDP_ACPI_HID_EX:
format_acpi_hid_ex(buf, size, off, dp,
hidstr, cidstr, uidstr);
break;
case EFIDP_ACPI_HID:
- debug(DEBUG, "Decoding ACPI HID");
+ debug("Decoding ACPI HID");
format(buf, size, off, "Acpi",
"Acpi(0x%08x,0x%"PRIx32")",
dp->acpi_hid.hid, dp->acpi_hid.uid);
break;
default:
- debug(DEBUG, "ACPI subtype %d???",
+ debug("ACPI subtype %d???",
dp->subtype);
errno = EINVAL;
return -1;
spaces[pos] = '\0';
pos = 0;
- debug(DEBUG, "entry");
+ debug("entry");
/*
* find the ACPI root dunno0 and dunno1; they basically look like:
* side in sscanf.
*/
rc = sscanf(devpart, "../../devices/platform/%n", &pos);
- debug(DEBUG, "devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos);
+ debug("devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos);
if (rc != 0 || pos < 1)
return 0;
devpart += pos;
return -1;
}
dev->acpi_root.acpi_hid_str[pos] = 0;
- debug(DEBUG, "acpi_hid_str:\"%s\"", dev->acpi_root.acpi_hid_str);
+ debug("acpi_hid_str:\"%s\"", dev->acpi_root.acpi_hid_str);
pos -= 4;
- debug(DEBUG, "devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos);
+ debug("devpart:\"%s\" rc:%d pos:%d", devpart, rc, pos);
acpi_header = strndupa(devpart, pos);
if (!acpi_header)
return 0;
acpi_header[pos] = 0;
- debug(DEBUG, "devpart:\"%s\" acpi_header:\"%s\"", devpart, acpi_header);
+ debug("devpart:\"%s\" acpi_header:\"%s\"", devpart, acpi_header);
devpart += pos;
/*
efi_error("Could not parse ACPI path \"%s\"", devpart);
return 0;
}
- debug(DEBUG, "devpart:\"%s\" parsed:%04hx:%02hhx pos:%d rc:%d",
+ debug("devpart:\"%s\" parsed:%04hx:%02hhx pos:%d rc:%d",
devpart, pad0, pad1, pos, rc);
devpart += pos;
rc = parse_acpi_hid_uid(dev, "devices/platform/%s%04hX:%02hhX",
acpi_header, pad0, pad1);
- debug(DEBUG, "rc:%d acpi_header:%s pad0:%04hX pad1:%02hhX",
+ debug("rc:%d acpi_header:%s pad0:%04hX pad1:%02hhX",
rc, acpi_header, pad0, pad1);
if (rc < 0 && errno == ENOENT) {
rc = parse_acpi_hid_uid(dev, "devices/platform/%s%04hx:%02hhx",
acpi_header, pad0, pad1);
- debug(DEBUG, "rc:%d acpi_header:%s pad0:%04hx pad1:%02hhx",
+ debug("rc:%d acpi_header:%s pad0:%04hx pad1:%02hhx",
rc, acpi_header, pad0, pad1);
}
if (rc < 0) {
efi_error("Could not parse hid/uid");
return rc;
}
- debug(DEBUG, "Parsed HID:0x%08x UID:0x%"PRIx64" uidstr:\"%s\" path:\"%s\"",
+ debug("Parsed HID:0x%08x UID:0x%"PRIx64" uidstr:\"%s\" path:\"%s\"",
dev->acpi_root.acpi_hid, dev->acpi_root.acpi_uid,
dev->acpi_root.acpi_uid_str,
dev->acpi_root.acpi_cid_str);
{
ssize_t sz = 0, new = 0;
- debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off);
+ debug("entry buf:%p size:%zd off:%zd", buf, size, off);
if (dev->acpi_root.acpi_uid_str || dev->acpi_root.acpi_cid_str) {
- debug(DEBUG, "creating acpi_hid_ex dp hid:0x%08x uid:0x%"PRIx64" uidstr:\"%s\" cidstr:\"%s\"",
+ debug("creating acpi_hid_ex dp hid:0x%08x uid:0x%"PRIx64" uidstr:\"%s\" cidstr:\"%s\"",
dev->acpi_root.acpi_hid, dev->acpi_root.acpi_uid,
dev->acpi_root.acpi_uid_str, dev->acpi_root.acpi_cid_str);
new = efidp_make_acpi_hid_ex(buf + off, size ? size - off : 0,
return new;
}
} else {
- debug(DEBUG, "creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64,
+ debug("creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64,
dev->acpi_root.acpi_hid,
dev->acpi_root.acpi_uid);
new = efidp_make_acpi_hid(buf + off, size ? size - off : 0,
}
sz += new;
- debug(DEBUG, "returning %zd", sz);
+ debug("returning %zd", sz);
return sz;
}
uint32_t acpi_hid = 0;
uint64_t acpi_uid_int = 0;
- debug(DEBUG, "entry");
+ debug("entry");
va_start(ap, fmt);
rc = vasprintfa(&path, fmt, ap);
va_end(ap);
- debug(DEBUG, "path:%s rc:%d", path, rc);
+ debug("path:%s rc:%d", path, rc);
if (rc < 0 || path == NULL)
return -1;
if (l > 1) {
fbuf[l-1] = 0;
dev->acpi_root.acpi_cid_str = strdup(fbuf);
- debug(DEBUG, "Setting ACPI root path to \"%s\"", fbuf);
+ debug("Setting ACPI root path to \"%s\"", fbuf);
}
}
rc -= 4;
rc = sscanf((char *)fbuf + rc, "%04hx", &tmp16);
- debug(DEBUG, "rc:%d hid:0x%08x\n", rc, tmp16);
+ debug("rc:%d hid:0x%08x\n", rc, tmp16);
if (rc != 1)
goto hid_err;
if (acpi_hid == EFIDP_ACPI_PCIE_ROOT_HID)
acpi_hid = EFIDP_ACPI_PCI_ROOT_HID;
dev->acpi_root.acpi_hid = acpi_hid;
- debug(DEBUG, "acpi root HID:0x%08x", acpi_hid);
+ debug("acpi root HID:0x%08x", acpi_hid);
errno = 0;
fbuf = NULL;
}
}
}
- debug(DEBUG, "acpi root UID:0x%"PRIx64" uidstr:\"%s\"",
+ debug("acpi root UID:0x%"PRIx64" uidstr:\"%s\"",
dev->acpi_root.acpi_uid, dev->acpi_root.acpi_uid_str);
errno = 0;
uint64_t scsi_lun;
int pos;
- debug(DEBUG, "entry");
+ debug("entry");
/* IDE disks can have up to 64 partitions, or 6 bits worth,
* and have one bit for the disk number.
* This leaves an extra bit at the top.
dev->interface_type = ata;
set_part(dev, dev->minor & 0x3F);
} else {
- debug(DEBUG, "If this is ATA, it isn't using a traditional IDE inode.");
+ debug("If this is ATA, it isn't using a traditional IDE inode.");
}
if (is_pata(dev)) {
{
ssize_t sz;
- debug(DEBUG, "entry");
+ debug("entry");
sz = efidp_make_atapi(buf + off, size ? size - off : 0,
dev->ata_info.scsi_device,
static ssize_t
parse_i2o(struct device *dev, const char *current UNUSED, const char *root UNUSED)
{
- debug(DEBUG, "entry");
+ debug("entry");
/* I2O disks can have up to 16 partitions, or 4 bits worth. */
if (dev->major >= 80 && dev->major <= 87) {
dev->interface_type = i2o;
spaces[pos0] = '\0';
pos0 = 0;
- debug(DEBUG, "entry");
+ debug("entry");
- debug(DEBUG, "searching for nvme/nvme0/nvme0n1 or nvme/nvme0/nvme0n1/nvme0n1p1");
+ debug("searching for nvme/nvme0/nvme0n1 or nvme/nvme0/nvme0n1/nvme0n1p1");
rc = sscanf(current, "nvme/nvme%d/nvme%dn%d%n/nvme%dn%dp%d%n",
&tosser0, &ctrl_id, &ns_id, &pos0,
&tosser1, &tosser2, &partition, &pos1);
- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
- arrow(DEBUG, spaces, 9, pos0, rc, 3);
- arrow(DEBUG, spaces, 9, pos1, rc, 6);
+ debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current, rc, pos0, pos1);
+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
+ arrow(LOG_DEBUG, spaces, 9, pos1, rc, 6);
/*
* If it isn't of that form, it's not one of our nvme devices.
*/
{
ssize_t sz;
- debug(DEBUG, "entry");
+ debug("entry");
sz = efidp_make_nvme(buf + off, size ? size - off : 0,
dev->nvme_info.ns_id,
spaces[pos] = '\0';
pos = 0;
- debug(DEBUG, "entry");
+ debug("entry");
/*
* find the pci root domain and port; they basically look like:
dp_create_pci_root(struct device *dev UNUSED,
uint8_t *buf, ssize_t size, ssize_t off)
{
- debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off);
- debug(DEBUG, "returning 0");
+ debug("entry buf:%p size:%zd off:%zd", buf, size, off);
+ debug("returning 0");
#if 0
if (dev->acpi_root.acpi_uid_str) {
- debug(DEBUG, "creating acpi_hid_ex dp hid:0x%08x uid:\"%s\"",
+ debug("creating acpi_hid_ex dp hid:0x%08x uid:\"%s\"",
dev->acpi_root.acpi_hid,
dev->acpi_root.acpi_uid_str);
new = efidp_make_acpi_hid_ex(buf + off, size ? size - off : 0,
return new;
}
} else {
- debug(DEBUG, "creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64,
+ debug("creating acpi_hid dp hid:0x%08x uid:0x%0"PRIx64,
dev->acpi_root.acpi_hid,
dev->acpi_root.acpi_uid);
new = efidp_make_acpi_hid(buf + off, size ? size - off : 0,
off += new;
sz += new;
- debug(DEBUG, "returning %zd", sz);
+ debug("returning %zd", sz);
return sz;
#else
return 0;
spaces[pos] = '\0';
pos = 0;
- debug(DEBUG, "entry");
+ debug("entry");
/* find the pci domain/bus/device/function:
* 0000:00:01.0/0000:01:00.0/
unsigned int i = dev->n_pci_devs;
pos = 0;
- debug(DEBUG, "searching for 0000:00:00.0/");
+ debug("searching for 0000:00:00.0/");
rc = sscanf(devpart, "%hx:%hhx:%hhx.%hhx/%n",
&domain, &bus, &device, &function, &pos);
- debug(DEBUG, "current:\"%s\" rc:%d pos:%d", devpart, rc, pos);
- arrow(DEBUG, spaces, 9, pos, rc, 3);
+ debug("current:\"%s\" rc:%d pos:%d", devpart, rc, pos);
+ arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
if (rc != 4)
break;
devpart += pos;
- debug(DEBUG, "found pci domain %04hx:%02hhx:%02hhx.%02hhx",
+ debug("found pci domain %04hx:%02hhx:%02hhx.%02hhx",
domain, bus, device, function);
pci_dev = realloc(dev->pci_dev,
sizeof(*pci_dev) * (i + 1));
}
free(tmp);
dev->pci_dev[i].driverlink = strdup(linkbuf);
- debug(DEBUG, "driver:%s\n", linkbuf);
+ debug("driver:%s\n", linkbuf);
dev->n_pci_devs += 1;
}
- debug(DEBUG, "next:\"%s\"", devpart);
+ debug("next:\"%s\"", devpart);
return devpart - current;
}
{
ssize_t sz = 0, new = 0;
- debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off);
+ debug("entry buf:%p size:%zd off:%zd", buf, size, off);
- debug(DEBUG, "creating PCI device path nodes");
+ debug("creating PCI device path nodes");
for (unsigned int i = 0; i < dev->n_pci_devs; i++) {
- debug(DEBUG, "creating PCI device path node %u", i);
+ debug("creating PCI device path node %u", i);
new = efidp_make_pci(buf + off, size ? size - off : 0,
dev->pci_dev[i].pci_device,
dev->pci_dev[i].pci_function);
off += new;
}
- debug(DEBUG, "returning %zd", sz);
+ debug("returning %zd", sz);
return sz;
}
int ndbus, region, btt_region_id, btt_id, rc, pos;
char *namespace = NULL;
- debug(DEBUG, "entry");
+ debug("entry");
if (!strcmp(dev->driver, "nd_pmem")) {
;
return -1;
filebuf = NULL;
- debug(DEBUG, "nvdimm namespace is \"%s\"", namespace);
+ debug("nvdimm namespace is \"%s\"", namespace);
rc = read_sysfs_file(&filebuf, "bus/nd/devices/%s/uuid", namespace);
free(namespace);
if (rc < 0 || filebuf == NULL)
{
ssize_t sz, sz1;
- debug(DEBUG, "entry");
+ debug("entry");
sz = efidp_make_nvdimm(buf + off, size ? size - off : 0,
&dev->nvdimm_info.namespace_label);
uint8_t *filebuf = NULL;
uint64_t sas_address;
- debug(DEBUG, "entry");
+ debug("entry");
pos = parse_scsi_link(current, &scsi_host,
&scsi_bus, &scsi_device,
{
ssize_t sz;
- debug(DEBUG, "entry");
+ debug("entry");
sz = efidp_make_sas(buf + off, size ? size - off : 0,
dev->sas_info.sas_address);
spaces[pos] = '\0';
pos = 0;
- debug(DEBUG, "entry");
+ debug("entry");
if (is_pata(dev)) {
- debug(DEBUG, "This is a PATA device; skipping.");
+ debug("This is a PATA device; skipping.");
return 0;
}
* ata1/host0/target0:0:0/0:0:0:0
* ^dev ^host x y z
*/
- debug(DEBUG, "searching for ata1/");
+ debug("searching for ata1/");
rc = sscanf(current, "ata%"PRIu32"/%n", &print_id, &pos);
- debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
- arrow(DEBUG, spaces, 9, pos, rc, 1);
+ debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
+ arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
/*
* If we don't find this one, it isn't an ata device, so return 0 not
* error. Later errors mean it is an ata device, but we can't parse
current += pos;
pos = 0;
- debug(DEBUG, "searching for host0/");
+ debug("searching for host0/");
rc = sscanf(current, "host%"PRIu32"/%n", &scsi_bus, &pos);
- debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
- arrow(DEBUG, spaces, 9, pos, rc, 1);
+ debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
+ arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
if (rc != 1)
return -1;
current += pos;
pos = 0;
- debug(DEBUG, "searching for target0:0:0:0/");
+ debug("searching for target0:0:0:0/");
rc = sscanf(current, "target%"PRIu32":%"PRIu32":%"PRIu64"/%n",
&scsi_device, &scsi_target, &scsi_lun, &pos);
- debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
- arrow(DEBUG, spaces, 9, pos, rc, 3);
+ debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
+ arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
if (rc != 3)
return -1;
current += pos;
pos = 0;
- debug(DEBUG, "searching for 0:0:0:0/");
+ debug("searching for 0:0:0:0/");
rc = sscanf(current, "%"PRIu32":%"PRIu32":%"PRIu32":%"PRIu64"/%n",
&tosser0, &tosser1, &tosser2, &tosser3, &pos);
- debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
- arrow(DEBUG, spaces, 9, pos, rc, 4);
+ debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
+ arrow(LOG_DEBUG, spaces, 9, pos, rc, 4);
if (rc != 4)
return -1;
current += pos;
{
ssize_t sz = -1;
- debug(DEBUG, "entry buf:%p size:%zd off:%zd", buf, size, off);
+ debug("entry buf:%p size:%zd off:%zd", buf, size, off);
if (dev->interface_type == ata || dev->interface_type == atapi) {
sz = efidp_make_atapi(buf + off, size ? size - off : 0,
spaces[sz] = '\0';
sz = 0;
- debug(DEBUG, "entry");
+ debug("entry");
/*
* This structure is completely ridiculous.
*
* host4/port-4:0
* or host4/port-4:0:0
*/
- debug(DEBUG, "searching for host4/");
+ debug("searching for host4/");
rc = sscanf(current, "host%d/%n", scsi_host, &pos0);
- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
- arrow(DEBUG, spaces, 9, pos0, rc, 1);
+ debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 1);
if (rc != 1)
return -1;
sz += pos0;
pos0 = 0;
- debug(DEBUG, "searching for port-4:0 or port-4:0:0");
+ debug("searching for port-4:0 or port-4:0:0");
rc = sscanf(current, "port-%d:%d%n:%d%n", &tosser0,
&tosser1, &pos0, &tosser2, &pos1);
- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d pos1:%d\n", current+sz, rc, pos0, pos1);
- arrow(DEBUG, spaces, 9, pos0, rc, 2);
- arrow(DEBUG, spaces, 9, pos1, rc, 3);
+ debug("current:\"%s\" rc:%d pos0:%d pos1:%d\n", current+sz, rc, pos0, pos1);
+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2);
+ arrow(LOG_DEBUG, spaces, 9, pos1, rc, 3);
if (rc == 2 || rc == 3) {
sz += pos0;
pos0 = 0;
* awesomely these are the exact same fields that go into port-blah,
* but we don't care for now about any of them anyway.
*/
- debug(DEBUG, "searching for /end_device-4:0/ or /end_device-4:0:0/");
+ debug("searching for /end_device-4:0/ or /end_device-4:0:0/");
rc = sscanf(current + sz, "/end_device-%d:%d%n", &tosser0, &tosser1, &pos0);
- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
- arrow(DEBUG, spaces, 9, pos0, rc, 2);
+ debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2);
if (rc != 2)
return -1;
sz += pos0;
pos0 = 0;
rc = sscanf(current + sz, ":%d%n", &tosser0, &pos0);
- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
- arrow(DEBUG, spaces, 9, pos0, rc, 2);
+ debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 2);
if (rc != 0 && rc != 1)
return -1;
sz += pos0;
* /target4:0:0/
*/
uint64_t tosser3;
- debug(DEBUG, "searching for target4:0:0/");
+ debug("searching for target4:0:0/");
rc = sscanf(current + sz, "target%d:%d:%"PRIu64"/%n", &tosser0, &tosser1,
&tosser3, &pos0);
- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
- arrow(DEBUG, spaces, 9, pos0, rc, 3);
+ debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 3);
if (rc != 3)
return -1;
sz += pos0;
/* now:
* %d:%d:%d:%llu/
*/
- debug(DEBUG, "searching for 4:0:0:0/");
+ debug("searching for 4:0:0:0/");
rc = sscanf(current + sz, "%d:%d:%d:%"PRIu64"/%n",
scsi_bus, scsi_device, scsi_target, scsi_lun, &pos0);
- debug(DEBUG, "current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
- arrow(DEBUG, spaces, 9, pos0, rc, 4);
+ debug("current:\"%s\" rc:%d pos0:%d\n", current+sz, rc, pos0);
+ arrow(LOG_DEBUG, spaces, 9, pos0, rc, 4);
if (rc != 4)
return -1;
sz += pos0;
spaces[pos] = '\0';
pos = 0;
- debug(DEBUG, "entry");
+ debug("entry");
- debug(DEBUG, "searching for ../../../0:0:0:0");
+ debug("searching for ../../../0:0:0:0");
rc = sscanf(dev->device, "../../../%d:%d:%d:%"PRIu64"%n",
&dev->scsi_info.scsi_bus,
&dev->scsi_info.scsi_device,
&dev->scsi_info.scsi_target,
&dev->scsi_info.scsi_lun,
&pos);
- debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", dev->device, rc, pos);
- arrow(DEBUG, spaces, 9, pos, rc, 3);
+ debug("current:\"%s\" rc:%d pos:%d\n", dev->device, rc, pos);
+ arrow(LOG_DEBUG, spaces, 9, pos, rc, 3);
if (rc != 4)
return 0;
{
ssize_t sz = 0;
- debug(DEBUG, "entry");
+ debug("entry");
sz = efidp_make_scsi(buf + off, size ? size - off : 0,
dev->scsi_info.scsi_target,
spaces[pos] = '\0';
pos = 0;
- debug(DEBUG, "entry");
+ debug("entry");
rc = sscanf(devpart, "../../devices/platform/soc/%*[^/]/%n", &pos);
if (rc != 0)
return 0;
devpart += pos;
- debug(DEBUG, "new position is \"%s\"", devpart);
+ debug("new position is \"%s\"", devpart);
return devpart - current;
}
spaces[pos] = '\0';
pos = 0;
- debug(DEBUG, "entry");
+ debug("entry");
- debug(DEBUG, "searching for virtio0/");
+ debug("searching for virtio0/");
rc = sscanf(current, "virtio%x/%n", &tosser, &pos);
- debug(DEBUG, "current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
- arrow(DEBUG, spaces, 9, pos, rc, 1);
+ debug("current:\"%s\" rc:%d pos:%d\n", current, rc, pos);
+ arrow(LOG_DEBUG, spaces, 9, pos, rc, 1);
/*
* If we couldn't find virtioX/ then it isn't a virtio device.
*/
char *proximate = pathseg(dev->link, -4);
errno = 0;
- debug(DEBUG, "dev->disk_name:%p dev->part_name:%p", dev->disk_name, dev->part_name);
- debug(DEBUG, "dev->part:%d", dev->part);
- debug(DEBUG, "ultimate:\"%s\"", ultimate ? : "");
- debug(DEBUG, "penultimate:\"%s\"", penultimate ? : "");
- debug(DEBUG, "approximate:\"%s\"", approximate ? : "");
- debug(DEBUG, "proximate:\"%s\"", proximate ? : "");
+ debug("dev->disk_name:%p dev->part_name:%p", dev->disk_name, dev->part_name);
+ debug("dev->part:%d", dev->part);
+ debug("ultimate:\"%s\"", ultimate ? : "");
+ debug("penultimate:\"%s\"", penultimate ? : "");
+ debug("approximate:\"%s\"", approximate ? : "");
+ debug("proximate:\"%s\"", proximate ? : "");
if (ultimate && penultimate &&
((proximate && !strcmp(proximate, "nvme")) ||
*/
set_disk_name(dev, "%s", penultimate);
set_part_name(dev, "%s", ultimate);
- debug(DEBUG, "disk:%s part:%s", penultimate, ultimate);
+ debug("disk:%s part:%s", penultimate, ultimate);
} else if (ultimate && approximate && !strcmp(approximate, "nvme")) {
/*
* 259:0 -> ../../devices/pci0000:00/0000:00:1d.0/0000:05:00.0/nvme/nvme0/nvme0n1
*/
set_disk_name(dev, "%s", ultimate);
set_part_name(dev, "%sp%d", ultimate, dev->part);
- debug(DEBUG, "disk:%s part:%sp%d", ultimate, ultimate, dev->part);
+ debug("disk:%s part:%sp%d", ultimate, ultimate, dev->part);
} else if (ultimate && penultimate && !strcmp(penultimate, "block")) {
/*
* 253:0 -> ../../devices/virtual/block/dm-0 (... I guess)
*/
set_disk_name(dev, "%s", ultimate);
set_part_name(dev, "%s%d", ultimate, dev->part);
- debug(DEBUG, "disk:%s part:%s%d", ultimate, ultimate, dev->part);
+ debug("disk:%s part:%s%d", ultimate, ultimate, dev->part);
} else if (ultimate && approximate && !strcmp(approximate, "mtd")) {
/*
* 31:0 -> ../../devices/platform/1e000000.palmbus/1e000b00.spi/spi_master/spi32766/spi32766.0/mtd/mtd0/mtdblock0
*/
set_disk_name(dev, "%s", ultimate);
- debug(DEBUG, "disk:%s", ultimate);
+ debug("disk:%s", ultimate);
}
return 0;
}
dev->part = partition;
- debug(DEBUG, "partition:%d dev->part:%d", partition, dev->part);
+ debug("partition:%d dev->part:%d", partition, dev->part);
dev->probes = calloc(nmemb, sizeof(struct dev_probe *));
if (!dev->probes) {
efi_error("could not allocate %zd bytes",
efi_error("strdup(\"%s\") failed", linkbuf);
goto err;
}
- debug(DEBUG, "dev->link: %s", dev->link);
+ debug("dev->link: %s", dev->link);
if (dev->part == -1) {
rc = read_sysfs_file(&tmpbuf, "dev/block/%s/partition", dev->link);
efi_error("could not set disk and partition names");
goto err;
}
- debug(DEBUG, "dev->disk_name: %s", dev->disk_name);
- debug(DEBUG, "dev->part_name: %s", dev->part_name);
+ debug("dev->disk_name: %s", dev->disk_name);
+ debug("dev->part_name: %s", dev->part_name);
rc = sysfs_readlink(&tmpbuf, "block/%s/device", dev->disk_name);
if (rc < 0 || !tmpbuf) {
bool needs_root = true;
int last_successful_probe = -1;
- debug(DEBUG, "searching for device nodes in %s", dev->link);
+ debug("searching for device nodes in %s", dev->link);
for (i = 0; dev_probes[i] && dev_probes[i]->parse; i++) {
struct dev_probe *probe = dev_probes[i];
ssize_t pos;
if (!needs_root &&
(probe->flags & DEV_PROVIDES_ROOT)) {
- debug(DEBUG, "not testing %s because flags is 0x%x",
+ debug("not testing %s because flags is 0x%x",
probe->name, probe->flags);
continue;
}
- debug(DEBUG, "trying %s", probe->name);
+ debug("trying %s", probe->name);
pos = probe->parse(dev, current, dev->link);
if (pos < 0) {
efi_error("parsing %s failed", probe->name);
goto err;
} else if (pos > 0) {
- debug(DEBUG, "%s matched %s", probe->name, current);
+ debug("%s matched %s", probe->name, current);
dev->flags |= probe->flags;
if (probe->flags & DEV_PROVIDES_HD ||
dev->probes[n++] = dev_probes[i];
current += pos;
- debug(DEBUG, "current:%s", current);
+ debug("current:%s", current);
last_successful_probe = i;
if (!*current || !strncmp(current, "block/", 6))
continue;
}
- debug(DEBUG, "dev_probes[i+1]: %p dev->interface_type: %d\n",
+ debug("dev_probes[i+1]: %p dev->interface_type: %d\n",
dev_probes[i+1], dev->interface_type);
if (dev_probes[i+1] == NULL && dev->interface_type == unknown) {
int new_pos = 0;
current);
goto err;
}
- debug(DEBUG,
- "Cannot parse device link segment \"%s\"",
- current);
- debug(DEBUG, "Skipping to \"%s\"", current + new_pos);
- debug(DEBUG,
- "This means we can only write abbreviated paths");
+ debug("Cannot parse device link segment \"%s\"", current);
+ debug("Skipping to \"%s\"", current + pos);
+ debug("This means we can only create abbreviated paths");
if (rc < 0)
goto err;
if (new_pos == 0)
{
ssize_t off = 0;
- debug(DEBUG, "entry buf:%p size:%zd", buf, size);
+ debug("entry buf:%p size:%zd", buf, size);
for (unsigned int i = 0; dev->probes[i] &&
dev->probes[i]->parse; i++) {
off += sz;
}
- debug(DEBUG, "= %zd", off);
+ debug("= %zd", off);
return off;
}
+ sizeof (uint16_t) + desc_len
+ dp_size + optional_data_size;
- debug(DEBUG, "entry buf:%p size:%zd dp:%p dp_size:%zd",
+ debug("entry buf:%p size:%zd dp:%p dp_size:%zd",
buf, size, dp, dp_size);
if (size == 0)
return -1;
}
- debug(DEBUG, "testing buf");
+ debug("testing buf");
if (!buf) {
invalid:
errno = EINVAL;
return -1;
}
- debug(DEBUG, "testing optional data presence");
+ debug("testing optional data presence");
if (!optional_data && optional_data_size != 0)
goto invalid;
- debug(DEBUG, "testing dp presence");
+ debug("testing dp presence");
if ((!dp && dp_size == 0) || dp_size < 0)
goto invalid;
if (dp) {
- debug(DEBUG, "testing dp validity");
+ debug("testing dp validity");
if (!efidp_is_valid(dp, dp_size)) {
if (efi_get_verbose() >= 1)
hexdump((void *)dp, dp_size);
goto invalid;
}
- debug(DEBUG,
- "testing dp size: dp_size:%zd efidp_size(dp):%zd",
+ debug("testing dp size: dp_size:%zd efidp_size(dp):%zd",
dp_size, efidp_size(dp));
if (efidp_size(dp) != dp_size) {
if (efi_get_verbose() >= 1)
u16[1] = __builtin_bswap16(u16[1]);
}
-#define debug_(file, line, func, level, fmt, args...) \
+#define log_(file, line, func, level, fmt, args...) \
({ \
if (efi_get_verbose() >= level) { \
FILE *logfile_ = efi_get_logfile(); \
} \
})
-#define debug(level, fmt, args...) debug_(__FILE__, __LINE__, __func__, level, fmt, ## args)
-#define arrow(l,b,o,p,n,m) ({if(n==m){char c_=b[p+1]; b[o]='^'; b[p+o]='^';b[p+o+1]='\0';debug(l,"%s",b);b[o]=' ';b[p+o]=' ';b[p+o+1]=c_;}})
-
-#define DEBUG 1
+#define LOG_VERBOSE 0
+#define LOG_DEBUG 1
+#ifdef log
+#undef log
+#endif
+#define log(level, fmt, args...) log_(__FILE__, __LINE__, __func__, level, fmt, ## args)
+#define arrow(l,b,o,p,n,m) ({if(n==m){char c_=b[p+1]; b[o]='^'; b[p+o]='^';b[p+o+1]='\0';log(l,"%s",b);b[o]=' ';b[p+o]=' ';b[p+o+1]=c_;}})
+#define debug(fmt, args...) log(LOG_DEBUG, fmt, ## args)
#endif /* EFIVAR_UTIL_H */