Skip to contentSkip to conversation

ieee1275/ofdisk: vscsi lun handling on lun len

PATCH Superseded Mukesh Kumar Chaurasiya 2 participants 2 messages Nov 8, 2023 – Nov 9, 2023

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ieee1275/ofdisk: vscsi lun handling on lun len

The returned data for "vscsi-report-luns" is actually an array ofdisk buffer-addr and buffer-len pairs. The expression "(args.table + 4 + 8 * i)" is incorrect, in addition to being confusing. In addition, the list of luns is not NULL-terminated, as implemented by the "while (*ptr)":
since the first reported LUN is likely to be "0" this loop ends up processing no LUNs at all in most cases. The list of LUNs is terminated according to length, not by a value.

---
 grub-core/disk/ieee1275/ofdisk.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
grub-core/disk/ieee1275/ofdisk.c +8 -3
index c58a1fce8..eca447dc0 100644
@@ -225,8 +225,12 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
 	grub_ieee1275_cell_t table;
       }
       args;
+      struct lun_len {
+	grub_uint64_t *buf_adr;
+	grub_uint64_t buf_len;
+      } *tbl;
       char *buf, *bufptr;
-      unsigned i;
+      unsigned i, j;
 
       if (grub_ieee1275_open (alias->path, &ihandle))
 	return;
@@ -251,12 +255,13 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
 	return;
       bufptr = grub_stpcpy (buf, alias->path);
 
+      tbl = (struct lun_len *)args.table;
       for (i = 0; i < args.nentries; i++)
 	{
 	  grub_uint64_t *ptr;
 
-	  ptr = *(grub_uint64_t **) (args.table + 4 + 8 * i);
-	  while (*ptr)
+	  ptr = (grub_uint64_t *)(grub_addr_t)tbl[i].buf_adr;
+	  for (j = 0; j < tbl[i].buf_len; j++)
 	    {
 	      grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr++);
 	      dev_iterate_real (buf, buf);
Signature · 7 lines
2.41.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#1 lore raw
Quoted 3 lines · Mukesh Kumar Chaurasiya

The returned data for "vscsi-report-luns" is actually an array ofdisk buffer-addr and buffer-len pairs. The expression "(args.table + 4 + 8 * i)" is incorrect, in addition to being confusing. In addition, the list of

These sentences do not parse well due to at least "addition" repetition. Please fix this.

Quoted 4 lines

luns is not NULL-terminated, as implemented by the "while (*ptr)":
since the first reported LUN is likely to be "0" this loop ends up processing no LUNs at all in most cases. The list of LUNs is terminated according to length, not by a value.

In general this commit message does not parse well mostly due to listing mistakes in row followed by explanation how (all of) them are fixed. Please think how to improve that.

Additionally, current commit message suggest (a bit) that this patch should be split into two. This does not seem true but it is disturbing. Again, it has to be fixed.

Quoted 10 lines
---
 grub-core/disk/ieee1275/ofdisk.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
grub-core/disk/ieee1275/ofdisk.c +0 -0
index c58a1fce8..eca447dc0 100644

grub-core/disk/ieee1275/ofdisk.c dev_iterate (const struct grub_ieee1275_devalias *alias) · line 228

Quoted 4 lines
grub-core/disk/ieee1275/ofdisk.c +1 -0
@@ -225,8 +225,12 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
 	grub_ieee1275_cell_t table;
       }
       args;
+      struct lun_len {

s/lun_len/lun_buf/?

grub-core/disk/ieee1275/ofdisk.c dev_iterate (const struct grub_ieee1275_devalias *alias) · line 229

Quoted 1 line
grub-core/disk/ieee1275/ofdisk.c +1 -0
+	grub_uint64_t *buf_adr;

s/buf_adr/buf_addr/

grub-core/disk/ieee1275/ofdisk.c dev_iterate (const struct grub_ieee1275_devalias *alias) · line 233

Quoted 5 lines
grub-core/disk/ieee1275/ofdisk.c +3 -1
+	grub_uint64_t buf_len;
+      } *tbl;
       char *buf, *bufptr;
-      unsigned i;
+      unsigned i, j;

s/unsigned/unsigned int/

grub-core/disk/ieee1275/ofdisk.c dev_iterate (const struct grub_ieee1275_devalias *alias) · line 258

Quoted 7 lines
grub-core/disk/ieee1275/ofdisk.c +1 -0
       if (grub_ieee1275_open (alias->path, &ihandle))
 	return;
@@ -251,12 +255,13 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
 	return;
       bufptr = grub_stpcpy (buf, alias->path);
 
+      tbl = (struct lun_len *)args.table;

Please add space before args.table.

grub-core/disk/ieee1275/ofdisk.c dev_iterate (const struct grub_ieee1275_devalias *alias) · line 263

Quoted 7 lines
grub-core/disk/ieee1275/ofdisk.c +1 -2
       for (i = 0; i < args.nentries; i++)
 	{
 	  grub_uint64_t *ptr;
 
-	  ptr = *(grub_uint64_t **) (args.table + 4 + 8 * i);
-	  while (*ptr)
+	  ptr = (grub_uint64_t *)(grub_addr_t)tbl[i].buf_adr;

Please add space before tbl[i].buf_adr.

grub-core/disk/ieee1275/ofdisk.c dev_iterate (const struct grub_ieee1275_devalias *alias) · line 267

Quoted 4 lines
grub-core/disk/ieee1275/ofdisk.c +1 -0
+	  for (j = 0; j < tbl[i].buf_len; j++)
 	    {
 	      grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr++);
 	      dev_iterate_real (buf, buf);

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel