vfs: room for 32 disks and partitions, 32 mounts, 16 SchFS volumes

NBLKDEV was 16 for every disk and partition together, which a laptop's
NVMe drive with its eight partitions and a USB stick come close to. The
mount table held 8, SchFS 4 volumes and 4 snapshots, FAT 4 volumes.
Now 32, 32, 16, 8 and 8; the device numbers still fit between the ones
already fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
This commit is contained in:
Nexoniarz 2026-10-23 12:19:50 +02:00
commit b336e4a566
5 changed files with 12 additions and 9 deletions

View file

@ -15,7 +15,9 @@
// a Linux driver for SchFS will see when it is handed /dev/sda2. // a Linux driver for SchFS will see when it is handed /dev/sda2.
#define BLKDEV_FIRST 4 #define BLKDEV_FIRST 4
#define NBLKDEV 16 // so device numbers stay below SCHFS_DEV (64) // Disks and partitions together. A laptop's NVMe drive alone often carries
// eight partitions, and a stick or an SD card more, so 16 ran out.
#define NBLKDEV 32 // device numbers 4..35, below SCHFS_DEV (64)
// The GPT partition type of a SchFS volume, as it is written and printed: // The GPT partition type of a SchFS volume, as it is written and printed:
// 47138FA9-B79C-47A6-9F7D-AC1F7F572D5E. sgdisk and fdisk accept it as is. // 47138FA9-B79C-47A6-9F7D-AC1F7F572D5E. sgdisk and fdisk accept it as is.

View file

@ -9,7 +9,7 @@
// Filesystem device numbers for mounted FAT volumes. Like SCHFS_DEV, runtime // Filesystem device numbers for mounted FAT volumes. Like SCHFS_DEV, runtime
// identities for the inode cache that nothing on disk records. // identities for the inode cache that nothing on disk records.
#define FAT_VOL_SLOTS 4 #define FAT_VOL_SLOTS 8 // 104..111
#define FAT_DEV 104 #define FAT_DEV 104
#define FAT_IS_DEV(d) ((d) >= FAT_DEV && (d) < FAT_DEV + FAT_VOL_SLOTS) #define FAT_IS_DEV(d) ((d) >= FAT_DEV && (d) < FAT_DEV + FAT_VOL_SLOTS)

View file

@ -139,7 +139,8 @@ struct inode {
// /dev/hdb /mnt` ignored its source argument entirely and handed back whichever // /dev/hdb /mnt` ignored its source argument entirely and handed back whichever
// disk the kernel had found at boot. Slot 0 is that boot volume, which is why // disk the kernel had found at boot. Slot 0 is that boot volume, which is why
// SCHFS_DEV alone still means "the root" everywhere that only ever wanted it. // SCHFS_DEV alone still means "the root" everywhere that only ever wanted it.
#define SCHFS_VOL_SLOTS 4 // Sixteen, which fills 64..79 up to PROCFS_DEV.
#define SCHFS_VOL_SLOTS 16
#define SCHFS_DEV 64 #define SCHFS_DEV 64
#define SCHFS_IS_VOL_DEV(d) \ #define SCHFS_IS_VOL_DEV(d) \
((d) >= SCHFS_DEV && (d) < SCHFS_DEV + SCHFS_VOL_SLOTS) ((d) >= SCHFS_DEV && (d) < SCHFS_DEV + SCHFS_VOL_SLOTS)
@ -152,10 +153,10 @@ struct inode {
// a reader whichever was cached first. So a slot is a device: SCHFS_SNAP_DEV // a reader whichever was cached first. So a slot is a device: SCHFS_SNAP_DEV
// through SCHFS_SNAP_DEV + SCHFS_SNAP_SLOTS - 1. // through SCHFS_SNAP_DEV + SCHFS_SNAP_SLOTS - 1.
// //
// Four rather than one because "one at a time" is an odd thing to explain and // More than one because "one at a time" is an odd thing to explain and
// the cost is two scratch pages per slot, allocated on first use. Four rather // the cost is two scratch pages per slot, allocated on first use. Not many
// than many because each is a device number and they are a fixed, small space. // because each is a device number and they are a fixed, small space.
#define SCHFS_SNAP_SLOTS 4 #define SCHFS_SNAP_SLOTS 8 // 96..103, up to FAT_DEV
#define SCHFS_SNAP_DEV 96 #define SCHFS_SNAP_DEV 96
#define SCHFS_IS_SNAP_DEV(d) \ #define SCHFS_IS_SNAP_DEV(d) \
((d) >= SCHFS_SNAP_DEV && (d) < SCHFS_SNAP_DEV + SCHFS_SNAP_SLOTS) ((d) >= SCHFS_SNAP_DEV && (d) < SCHFS_SNAP_DEV + SCHFS_SNAP_SLOTS)

View file

@ -245,7 +245,7 @@ gen_mounts(struct sbuf *sb)
// Every mount is in the table, /dev included. A fixed devtmpfs line here // Every mount is in the table, /dev included. A fixed devtmpfs line here
// listed it twice once init mounted it the ordinary way. // listed it twice once init mounted it the ordinary way.
for (int i = 0; i < 16; i++) { for (int i = 0; i < 32; i++) {
if (mount_get(i, path, source, type, &fsdev) != 0) if (mount_get(i, path, source, type, &fsdev) != 0)
continue; continue;
// "/" is emitted last, below, so skip it if it somehow appears here. // "/" is emitted last, below, so skip it if it somehow appears here.

View file

@ -1584,7 +1584,7 @@ skipelem(char *path, char *name, int *toolong)
// a subtree becomes a place you can walk into and never out of. // a subtree becomes a place you can walk into and never out of.
// =========================================================================== // ===========================================================================
#define NMOUNT 8 #define NMOUNT 32
static struct { static struct {
struct spinlock lock; struct spinlock lock;