Hello,
I have tried to understand how to enable NVMe support in rumpdisk on
the Hurd and I have produced the following patch.
Any feedback is welcome.
Sincerely,
Gianluca
diff --git a/rumpdisk/Makefile b/rumpdisk/Makefile
index de33c65d..48e9a918 100644
--- a/rumpdisk/Makefile
+++ b/rumpdisk/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2019, 2023 Free Software Foundation, Inc.
+# Copyright (C) 2019, 2023, 2026 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
@@ -17,6 +17,7 @@
RUMPLIBS=rump rumpuser rumpdev rumpdev_disk rumpdev_pci rumpvfs
RUMPSATA=rumpdev_ahcisata rumpdev_piixide rumpdev_ata
+RUMPNVME=rumpdev_nvme rumpdev_ld
RUMPUSB=rumpdev_usb rumpdev_pci_usbhc rumpdev_umass rumpdev_scsipi
RUMPEXTRA=rumpdev_scsipi
@@ -51,6 +52,15 @@ rumpdisk.static-LDLIBS += $(HURDLIBS:%=-l%)
$(RUMPSTATIC) $(RUMPEXTRA:%=-l%_pic)
-Wl,--whole-archive $(RUMPSATA:%=-l%_pic)
$(RUMPLIBS:%=-l%_pic) -Wl,--no-whole-archive
rumpdisk rumpdisk.static: $(rumpdisk-OBJS)
+%.nvme.o: %.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -DRUMP_NVME -c $< -o $@
+rumpdisk-OBJS = $(SRCS:.c=.nvme.o)
+rumpdisk-LDLIBS += $(HURDLIBS:%=-l%) $(RUMPSTATIC) $(RUMPEXTRA:%=-l%) \
+ -Wl,--no-as-needed $(RUMPNVME:%=-l%) $(RUMPLIBS:%=-l%) -Wl,--as-needed
+rumpdisk.static-LDLIBS += $(HURDLIBS:%=-l%) $(RUMPSTATIC)
$(RUMPEXTRA:%=-l%_pic) \
+ -Wl,--whole-archive $(RUMPNVME:%=-l%_pic)
$(RUMPLIBS:%=-l%_pic) -Wl,--no-whole-archive
+rumpdisk rumpdisk.static: $(rumpdisk-OBJS)
+
%.usb.o: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
rumpusbdisk-OBJS = $(SRCS:.c=.usb.o)
diff --git a/rumpdisk/block-rump.c b/rumpdisk/block-rump.c
index aa4a387f..4512de22 100644
--- a/rumpdisk/block-rump.c
+++ b/rumpdisk/block-rump.c
@@ -1,7 +1,7 @@
/*
* Rump block driver support
*
- * Copyright (C) 2019 Free Software Foundation
+ * Copyright (C) 2019, 2026 Free Software Foundation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -47,10 +47,12 @@
#define BLKRRPART 0x125F /* re-read partition table */
#define DISK_NAME_LEN 32
-#define MAX_DISK_DEV 2
+#define MAX_DISK_DEV 3
#ifdef _RUMP_SATA
#define RUMP_TYPE_STRING "rump SATA/IDE"
+#elif defined(_RUMP_NVME)
+#define RUMP_TYPE_STRING "rump NVMe"
#else
#define RUMP_TYPE_STRING "rump USB"
#endif
@@ -125,6 +127,8 @@ is_disk_device (const char *name)
const char *allowed_devs[MAX_DISK_DEV] = {
#ifdef _RUMP_SATA
"wd",
+#elif _RUMP_NVME
+ "ld",
#else
"sd",
#endif
@@ -185,6 +189,21 @@ rumpdisk_device_init (void)
return;
}
#endif
+#ifdef _RUMP_NVME
+ if (! device_open (device_master, D_READ, "ld0", &device)
+ || ! device_open (device_master, D_READ, "ld1", &device)
+ || ! device_open (device_master, D_READ, "ld2", &device)
+ || ! device_open (device_master, D_READ, "ld3", &device))
+ {
+ device_close (device);
+ mach_port_deallocate (mach_task_self (), device);
+ mach_port_deallocate (mach_task_self (), device_master);
+ fprintf(stderr, "Kernel is already driving a Logic Disk device,
skipping probing " RUMP_TYPE_STRING " disks\n");
+ fflush(stderr);
+ disabled = 1;
+ return;
+ }
+#endif
if (! device_open (device_master, D_READ, "sd0", &device)
|| ! device_open (device_master, D_READ, "sd1", &device)