Il giorno lun 26 ott 2026 alle ore 11:39 Samuel Thibault
<[email protected]> ha scritto:
> That is it, yes.
Ok, thanks, Samuel.
> Yes, but
>
> You just need 3.
Removed.
> Now in the USB case we will have a NULL entry, the for loop needs to be
> fixed otherwise it can crash.
>
> But I don't think we need MAX_DISK_DEV at all: you can just drop the
> size from the allowed_devs array so it's automatically computed, and
> make the for loop use sizeof(allowed_devs)/sizeof(allowed_devs[0]) to
> know how many elements there are in the array. That can be a preparatory
> patch that we can commit already.
>
> Samuel
Got it. The preparatory patch follows.
Gianluca
diff --git a/rumpdisk/block-rump.c b/rumpdisk/block-rump.c
index aa4a387f..5e380952 100644
--- a/rumpdisk/block-rump.c
+++ b/rumpdisk/block-rump.c
@@ -47,7 +47,6 @@
#define BLKRRPART 0x125F /* re-read partition table */
#define DISK_NAME_LEN 32
-#define MAX_DISK_DEV 2
#ifdef _RUMP_SATA
#define RUMP_TYPE_STRING "rump SATA/IDE"
@@ -122,7 +121,7 @@ static boolean_t
is_disk_device (const char *name)
{
const char *dev;
- const char *allowed_devs[MAX_DISK_DEV] = {
+ const char *allowed_devs[] = {
#ifdef _RUMP_SATA
"wd",
#else
@@ -132,7 +131,7 @@ is_disk_device (const char *name)
};
uint8_t i;
- for (i = 0; i < MAX_DISK_DEV; i++)
+ for (i = 0; i < sizeof (allowed_devs) / sizeof (allowed_devs[0]); i++)
{
dev = allowed_devs[i];
/* /dev/XXN but we only care about /dev/XX prefix */