Skip to contentSkip to conversation

iscsi_ibft: Use a field width for target lun sysfs entry

PATCH New Ross Lagerwall 1 participant 1 message Jun 27, 2019 iSCSI boot firmware table (iBFT) driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iscsi_ibft: Use a field width for target lun sysfs entry

The target lun sysfs entry contains the contents of an 8 byte LUN id formatted as hex. Because a field width is not specified for each byte, the resulting string is variable length and impossible for userspace to unambiguously parse. Fix this by using a field width of 2 for each byte so that the string can be parsed correctly.

---
 drivers/firmware/iscsi_ibft.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/iscsi_ibft.c +1 -1
index ab3aa3983833..5900edcb6334 100644
@@ -371,7 +371,7 @@ static ssize_t ibft_attr_show_target(void *data, int type, char *buf)
 		break;
 	case ISCSI_BOOT_TGT_LUN:
 		for (i = 0; i < 8; i++)
-			str += sprintf(str, "%x", (u8)tgt->lun[i]);
+			str += sprintf(str, "%02x", (u8)tgt->lun[i]);
 		str += sprintf(str, "\n");
 		break;
 	case ISCSI_BOOT_TGT_NIC_ASSOC:
Signature · 1 line
2.17.2