فهرست منبع

Add vfs support but only vfat for now

Johannes Zellner 1 ماه پیش
والد
کامیت
629216ea97
18فایلهای تغییر یافته به همراه822 افزوده شده و 566 حذف شده
  1. 5 3
      AGENTS.md
  2. 14 11
      Makefile
  3. 9 3
      blkdev.c
  4. 10 11
      cat.c
  5. 16 1
      disk.c
  6. 7 0
      disk.h
  7. 382 403
      fat.c
  8. 51 41
      fat.h
  9. 1 1
      fatdetect.h
  10. 23 21
      ls.c
  11. 12 7
      mkdir.c
  12. 12 7
      rm.c
  13. 12 7
      rmdir.c
  14. 20 34
      run.c
  15. 14 8
      save.c
  16. 8 8
      terminal.c
  17. 194 0
      vfs.c
  18. 32 0
      vfs.h

+ 5 - 3
AGENTS.md

@@ -61,7 +61,9 @@ make clean
   8×8 font, rainbow separator, live datetime header, blinking cursor.
   8×8 font, rainbow separator, live datetime header, blinking cursor.
 - **Shell**: `terminal.c` — history, line editing, command dispatch (hand-rolled
 - **Shell**: `terminal.c` — history, line editing, command dispatch (hand-rolled
   `is_cmd_*` parsers).
   `is_cmd_*` parsers).
-- **Filesystem**: `fat.c` (FAT12 read/write + subdirectories), `disk.c` (FDC + ISA DMA ch2, retries).
+- **Filesystem**: `fat.c` (FAT12/16/32 read + FAT12/16 write, device-parameterized),
+  `vfs.c` (mounts every FAT device under `/`), `fatdetect.c`/`fatformat.c`,
+  `blkdev.c` (floppy + IDE registry), `ata.c` (ATA PIO), `disk.c` (FDC + ISA DMA ch2, retries).
 - **Serial**: `serial.c`, `serial_ring_buf.c/h`, `bin_recv.c/h`, `serial_recv.c`,
 - **Serial**: `serial.c`, `serial_ring_buf.c/h`, `bin_recv.c/h`, `serial_recv.c`,
   `serial_loop.c`, `send_serial.c` — 16550 UART, IRQ-driven ring buffer, XMODEM.
   `serial_loop.c`, `send_serial.c` — 16550 UART, IRQ-driven ring buffer, XMODEM.
 - **Hot-reload (kexec)**: `kexec.c/h`, `kexec_tramp.S`, `bootstrap.c`, and the
 - **Hot-reload (kexec)**: `kexec.c/h`, `kexec_tramp.S`, `bootstrap.c`, and the
@@ -77,8 +79,8 @@ make clean
 
 
 ## Shell commands
 ## Shell commands
 
 
-`hello`, `reboot`, `poweroff`, `ls [path]`, `cat <path>`, `save <path> <text>`, `rm <path>`,
-`mkdir <path>`, `rmdir <path>`, `run <file>`, `space`, `clock`,
+`hello`, `reboot`, `poweroff`, `ls [/dev[/dir]]`, `cat /dev/file`, `save /dev/file <text>`, `rm /dev/file`,
+`mkdir /dev/dir`, `rmdir /dev/dir`, `run /dev/file`, `space`, `clock`,
 `colors`, `display`, `cpuinfo`, `mouseinfo`, `lsusb`, `storage`, `format <device>`,
 `colors`, `display`, `cpuinfo`, `mouseinfo`, `lsusb`, `storage`, `format <device>`,
 `ps`, `kill <pid>`, `help`, `clear`, `serial test|recv`, `kexec`, `dbg`.
 `ps`, `kill <pid>`, `help`, `clear`, `serial test|recv`, `kexec`, `dbg`.
 
 

+ 14 - 11
Makefile

@@ -47,16 +47,16 @@ poweroff.o: poweroff.c
 disk.o: disk.c disk.h io.h timer.h
 disk.o: disk.c disk.h io.h timer.h
 	$(CC) $(CFLAGS) -o $@ $<
 	$(CC) $(CFLAGS) -o $@ $<
 
 
-fat.o: fat.c fat.h disk.h io.h
+fat.o: fat.c fat.h blkdev.h io.h
 	$(CC) $(CFLAGS) -o $@ $<
 	$(CC) $(CFLAGS) -o $@ $<
 
 
-ls.o: ls.c fat.h io.h
+ls.o: ls.c fat.h io.h vfs.h
 	$(CC) $(CFLAGS) -o $@ $<
 	$(CC) $(CFLAGS) -o $@ $<
 
 
-cat.o: cat.c fat.h io.h
+cat.o: cat.c fat.h io.h vfs.h
 	$(CC) $(CFLAGS) -o $@ $<
 	$(CC) $(CFLAGS) -o $@ $<
 
 
-run.o: run.c fat.h io.h fbtext.h run_api.h timer.h vga.h
+run.o: run.c fat.h io.h fbtext.h run_api.h timer.h vga.h vfs.h
 	$(CC) $(CFLAGS) -o $@ $<
 	$(CC) $(CFLAGS) -o $@ $<
 
 
 rtc.o: rtc.c rtc.h
 rtc.o: rtc.c rtc.h
@@ -122,7 +122,7 @@ blkdev.o: blkdev.c blkdev.h ata.h disk.h
 ata.o: ata.c ata.h pci.h timer.h
 ata.o: ata.c ata.h pci.h timer.h
 	$(CC) $(CFLAGS) -o $@ $<
 	$(CC) $(CFLAGS) -o $@ $<
 
 
-fatdetect.o: fatdetect.c fatdetect.h
+fatdetect.o: fatdetect.c fatdetect.h fat.h blkdev.h
 	$(CC) $(CFLAGS) -o $@ $<
 	$(CC) $(CFLAGS) -o $@ $<
 
 
 storage.o: storage.c blkdev.h fatdetect.h disk.h io.h
 storage.o: storage.c blkdev.h fatdetect.h disk.h io.h
@@ -149,16 +149,19 @@ kexec_tramp.o: kexec_tramp.S
 dbg.o: dbg.c dbg.h serial.h
 dbg.o: dbg.c dbg.h serial.h
 	$(CC) $(CFLAGS) -o $@ $<
 	$(CC) $(CFLAGS) -o $@ $<
 
 
-save.o: save.c fat.h io.h
+save.o: save.c fat.h io.h vfs.h
 	$(CC) $(CFLAGS) -o $@ $<
 	$(CC) $(CFLAGS) -o $@ $<
 
 
-rm.o: rm.c fat.h io.h
+rm.o: rm.c fat.h io.h vfs.h
 	$(CC) $(CFLAGS) -o $@ $<
 	$(CC) $(CFLAGS) -o $@ $<
 
 
-mkdir.o: mkdir.c fat.h io.h
+mkdir.o: mkdir.c fat.h io.h vfs.h
 	$(CC) $(CFLAGS) -o $@ $<
 	$(CC) $(CFLAGS) -o $@ $<
 
 
-rmdir.o: rmdir.c fat.h io.h
+rmdir.o: rmdir.c fat.h io.h vfs.h
+	$(CC) $(CFLAGS) -o $@ $<
+
+vfs.o: vfs.c vfs.h fat.h fatdetect.h blkdev.h io.h
 	$(CC) $(CFLAGS) -o $@ $<
 	$(CC) $(CFLAGS) -o $@ $<
 
 
 boot.elf: boot.o
 boot.elf: boot.o
@@ -176,7 +179,7 @@ switch.o: switch.S
 process.o: process.c process.h io.h
 process.o: process.c process.h io.h
 	$(CC) $(CFLAGS) -o $@ $<
 	$(CC) $(CFLAGS) -o $@ $<
 
 
-kernel.elf: vesa_stage.o kernel.o timer.o switch.o process.o io.o rtc.o terminal.o hello.o reboot.o poweroff.o disk.o fat.o ls.o cat.o run.o serial.o serial_ring_buf.o serial_loop.o serial_recv.o bin_recv.o vga.o vga_copy.o gpu.o ati.o nvidia.o font_8x8.o fbtext.o clock.o colors.o display.o cpuinfo.o mouse.o mousecmd.o uhci.o usb.o lsusb.o blkdev.o ata.o fatdetect.o storage.o fatformat.o format.o idle.o kexec.o kexec_tramp.o dbg.o save.o rm.o mkdir.o rmdir.o
+kernel.elf: vesa_stage.o kernel.o timer.o switch.o process.o io.o rtc.o terminal.o hello.o reboot.o poweroff.o disk.o fat.o ls.o cat.o run.o serial.o serial_ring_buf.o serial_loop.o serial_recv.o bin_recv.o vga.o vga_copy.o gpu.o ati.o nvidia.o font_8x8.o fbtext.o clock.o colors.o display.o cpuinfo.o mouse.o mousecmd.o uhci.o usb.o lsusb.o blkdev.o ata.o fatdetect.o storage.o fatformat.o format.o vfs.o idle.o kexec.o kexec_tramp.o dbg.o save.o rm.o mkdir.o rmdir.o
 	$(LD) $(KERNEL_LDFLAGS) -o $@ $^
 	$(LD) $(KERNEL_LDFLAGS) -o $@ $^
 
 
 MBR_LDFLAGS = -T mbr.ld -nostdlib -m elf_i386
 MBR_LDFLAGS = -T mbr.ld -nostdlib -m elf_i386
@@ -325,4 +328,4 @@ dev: kernel.bin kexec_send
 	./kexec_send $(SERIAL_DEV) $(SERIAL_BAUD) $$entry kernel.bin
 	./kexec_send $(SERIAL_DEV) $(SERIAL_BAUD) $$entry kernel.bin
 
 
 clean:
 clean:
-	rm -f boot.o vesa_stage.o kernel.o timer.o switch.o process.o io.o rtc.o terminal.o hello.o reboot.o poweroff.o fat.o ls.o cat.o run.o disk.o serial.o serial_ring_buf.o serial_loop.o serial_recv.o bin_recv.o vga.o vga_copy.o gpu.o ati.o nvidia.o font_8x8.o fbtext.o clock.o colors.o display.o cpuinfo.o mouse.o mousecmd.o uhci.o usb.o lsusb.o blkdev.o ata.o fatdetect.o storage.o fatformat.o format.o idle.o kexec.o kexec_tramp.o dbg.o save.o rm.o mkdir.o rmdir.o mbr.o boot.elf kernel.elf mbr.elf boot.bin mbr.bin kernel.bin boot.bin.tmp boot.bin.patched image.bin floppy.img usb.img final.bin root.img prog.o prog.elf prog.bin space.o space.elf space.bin bootstrap.o bootstrap.elf bootstrap.bin send_serial kexec_send
+	rm -f boot.o vesa_stage.o kernel.o timer.o switch.o process.o io.o rtc.o terminal.o hello.o reboot.o poweroff.o fat.o ls.o cat.o run.o disk.o serial.o serial_ring_buf.o serial_loop.o serial_recv.o bin_recv.o vga.o vga_copy.o gpu.o ati.o nvidia.o font_8x8.o fbtext.o clock.o colors.o display.o cpuinfo.o mouse.o mousecmd.o uhci.o usb.o lsusb.o blkdev.o ata.o fatdetect.o storage.o fatformat.o format.o vfs.o idle.o kexec.o kexec_tramp.o dbg.o save.o rm.o mkdir.o rmdir.o mbr.o boot.elf kernel.elf mbr.elf boot.bin mbr.bin kernel.bin boot.bin.tmp boot.bin.patched image.bin floppy.img usb.img final.bin root.img prog.o prog.elf prog.bin space.o space.elf space.bin bootstrap.o bootstrap.elf bootstrap.bin send_serial kexec_send

+ 9 - 3
blkdev.c

@@ -30,9 +30,11 @@ void blk_scan(void)
 
 
 	blk_dev_count = 0;
 	blk_dev_count = 0;
 
 
-	/* Floppy drive 0 (the FDC layer is single-drive). */
+	/* Floppy drives 0 and 1. */
 	d = add("floppy0", BLK_FLOPPY, 0, 0);
 	d = add("floppy0", BLK_FLOPPY, 0, 0);
 	if (d) { d->present = 1; d->total_sectors = 2880; }
 	if (d) { d->present = 1; d->total_sectors = 2880; }
+	d = add("floppy1", BLK_FLOPPY, 1, 0);
+	if (d) { d->present = 1; d->total_sectors = 2880; }
 
 
 	/* IDE: primary + secondary, master + slave. */
 	/* IDE: primary + secondary, master + slave. */
 	{
 	{
@@ -80,8 +82,10 @@ int blk_read(blk_dev_t *d, unsigned int lba, void *buf, unsigned int count)
 {
 {
 	if (!d || count == 0)
 	if (!d || count == 0)
 		return -1;
 		return -1;
-	if (d->kind == BLK_FLOPPY)
+	if (d->kind == BLK_FLOPPY) {
+		disk_set_drive(d->bus);
 		return disk_read_sectors(lba, buf, count);
 		return disk_read_sectors(lba, buf, count);
+	}
 	return ata_read_sectors(d->bus, d->unit, lba, buf, count);
 	return ata_read_sectors(d->bus, d->unit, lba, buf, count);
 }
 }
 
 
@@ -89,7 +93,9 @@ int blk_write(blk_dev_t *d, unsigned int lba, const void *buf, unsigned int coun
 {
 {
 	if (!d || count == 0)
 	if (!d || count == 0)
 		return -1;
 		return -1;
-	if (d->kind == BLK_FLOPPY)
+	if (d->kind == BLK_FLOPPY) {
+		disk_set_drive(d->bus);
 		return disk_write_sectors(lba, buf, count);
 		return disk_write_sectors(lba, buf, count);
+	}
 	return ata_write_sectors(d->bus, d->unit, lba, buf, count);
 	return ata_write_sectors(d->bus, d->unit, lba, buf, count);
 }
 }

+ 10 - 11
cat.c

@@ -1,34 +1,33 @@
-/* cat command: print file contents to screen (supports paths). */
+/* cat command: print file contents to screen. Usage: cat /<device>/<file>. */
 
 
 #include "fat.h"
 #include "fat.h"
 #include "io.h"
 #include "io.h"
+#include "vfs.h"
 
 
 #define DUMP_BUF_SIZE 4096
 #define DUMP_BUF_SIZE 4096
 
 
 void program_cat_main(const char *filename)
 void program_cat_main(const char *filename)
 {
 {
 	static unsigned char buf[DUMP_BUF_SIZE];
 	static unsigned char buf[DUMP_BUF_SIZE];
+	fat_fs_t *fs;
+	const char *fs_path;
 	unsigned int dir_cluster;
 	unsigned int dir_cluster;
 	char name_8_3[12];
 	char name_8_3[12];
 	int n;
 	int n;
 	unsigned int i;
 	unsigned int i;
 
 
 	if (!filename || !filename[0]) {
 	if (!filename || !filename[0]) {
-		io_putstr("cat: usage cat <file>\n");
+		io_putstr("cat: usage cat /<device>/<file>\n");
 		return;
 		return;
 	}
 	}
 
 
-	n = fat_init();
-	if (n == -2) {
-		io_putstr("cat: disk read error\n");
-		return;
-	}
-	if (n != 0) {
-		io_putstr("cat: no FAT filesystem found\n");
+	vfs_mount_all();
+	if (vfs_resolve(filename, &fs, &fs_path) != 0) {
+		io_putstr("cat: unknown device or invalid path\n");
 		return;
 		return;
 	}
 	}
 
 
-	n = fat_resolve_path(filename, &dir_cluster, name_8_3);
+	n = fat_resolve_path(fs, fs_path, &dir_cluster, name_8_3);
 	if (n == -2) {
 	if (n == -2) {
 		io_putstr("cat: disk error\n");
 		io_putstr("cat: disk error\n");
 		return;
 		return;
@@ -38,7 +37,7 @@ void program_cat_main(const char *filename)
 		return;
 		return;
 	}
 	}
 
 
-	n = fat_read_file_in(dir_cluster, name_8_3, buf, DUMP_BUF_SIZE);
+	n = fat_read_file_in(fs, dir_cluster, name_8_3, buf, DUMP_BUF_SIZE);
 	if (n == -2) {
 	if (n == -2) {
 		io_putstr("cat: disk read error\n");
 		io_putstr("cat: disk read error\n");
 		return;
 		return;

+ 16 - 1
disk.c

@@ -477,6 +477,22 @@ static int fdc_init_once(void)
 	return 0;
 	return 0;
 }
 }
 
 
+void disk_set_drive(unsigned int drive)
+{
+	if (drive > 1)
+		return;
+	if (drive == current_drive && fdc_initialized)
+		return;
+	current_drive = drive;
+	motor_on = 0;
+	fdc_initialized = 0;
+}
+
+unsigned int disk_get_drive(void)
+{
+	return current_drive;
+}
+
 int disk_read_sectors(unsigned int lba, void *buf, unsigned int count)
 int disk_read_sectors(unsigned int lba, void *buf, unsigned int count)
 {
 {
 	unsigned int i;
 	unsigned int i;
@@ -485,7 +501,6 @@ int disk_read_sectors(unsigned int lba, void *buf, unsigned int count)
 		if (fdc_init_once() != 0)
 		if (fdc_init_once() != 0)
 			return -1;
 			return -1;
 	}
 	}
-
 	for (i = 0; i < count; i++) {
 	for (i = 0; i < count; i++) {
 		int attempt, ok = 0;
 		int attempt, ok = 0;
 		for (attempt = 0; attempt < MAX_RETRIES; attempt++) {
 		for (attempt = 0; attempt < MAX_RETRIES; attempt++) {

+ 7 - 0
disk.h

@@ -3,6 +3,13 @@
 #ifndef DISK_H
 #ifndef DISK_H
 #define DISK_H
 #define DISK_H
 
 
+/* Select the floppy drive (0 or 1) used by subsequent disk_read_sectors calls.
+ * Resets FDC state so the next read re-initialises for the new drive. */
+void disk_set_drive(unsigned int drive);
+
+/* Return currently selected drive number. */
+unsigned int disk_get_drive(void);
+
 /* Read count sectors starting at lba into buf.
 /* Read count sectors starting at lba into buf.
  * Returns 0 on success, -1 on error. */
  * Returns 0 on success, -1 on error. */
 int disk_read_sectors(unsigned int lba, void *buf, unsigned int count);
 int disk_read_sectors(unsigned int lba, void *buf, unsigned int count);

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 382 - 403
fat.c


+ 51 - 41
fat.h

@@ -1,52 +1,62 @@
-/* FAT12 filesystem with subdirectory support.
- * A "directory" is identified by its first data cluster; 0 means the root dir.
- * Error conventions:  0 = success, -1 = not found / not ready / full, -2 = disk I/O error. */
+/* FAT12/16/32 filesystem with subdirectory support, device-parameterized.
+ * A "directory" is identified by a cluster: 0 = root for FAT12/16,
+ * root_cluster (2) = root for FAT32, else a subdirectory's first cluster.
+ * Error conventions: 0 = success, -1 = not found / not ready / full / invalid,
+ * -2 = disk I/O error. */
 
 
 #ifndef FAT_H
 #ifndef FAT_H
 #define FAT_H
 #define FAT_H
 
 
-typedef void (*fat_root_callback_t)(const char *name, int is_dir, unsigned int size);
-
-/* Parse BPB from sector 0. Call once before list/read/write.
- * Returns 0 on success, -1 if no valid FAT filesystem, -2 on disk I/O error. */
-int fat_init(void);
-
-/* Iterate root directory, call callback for each file/dir. */
-int fat_list_root(fat_root_callback_t callback);
-
-/* Iterate a directory (0 = root, else first cluster). */
-int fat_list_dir(unsigned int dir_cluster, fat_root_callback_t callback);
-
-/* Read file by 8.3 name into buf, max max_len bytes (root only). */
-int fat_read_file(const char *name_8_3, void *buf, unsigned int max_len);
-
-/* Read a file in a directory (0 = root). */
-int fat_read_file_in(unsigned int dir_cluster, const char *name_8_3, void *buf, unsigned int max_len);
+#include "blkdev.h"
 
 
-/* Create or overwrite a file in the root directory. */
-int fat_write_file(const char *name_8_3, const void *buf, unsigned int size);
+typedef enum { FAT_NONE, FAT12, FAT16, FAT32 } fat_type_t;
 
 
-/* Create or overwrite a file in a directory (0 = root). */
-int fat_write_file_in(unsigned int dir_cluster, const char *name_8_3, const void *buf, unsigned int size);
-
-/* Delete a file from the root directory. */
-int fat_delete_file(const char *name_8_3);
-
-/* Delete a file from a directory (0 = root). */
-int fat_delete_file_in(unsigned int dir_cluster, const char *name_8_3);
-
-/* Create a subdirectory in `parent_cluster` (0 = root). */
-int fat_mkdir(unsigned int parent_cluster, const char *name_8_3);
-
-/* Remove an empty subdirectory from `parent_cluster` (0 = root). */
-int fat_rmdir(unsigned int parent_cluster, const char *name_8_3);
+typedef void (*fat_root_callback_t)(const char *name, int is_dir, unsigned int size);
 
 
-/* Resolve a path "a/b/c" into (parent dir cluster, final 8.3 name).
- * The returned name_8_3 is uppercase and space-padded (11 bytes + NUL). */
-int fat_resolve_path(const char *path, unsigned int *dir_cluster, char name_8_3[12]);
+typedef struct {
+	blk_dev_t *dev;
+	unsigned int part_lba;          /* LBA of the filesystem (partition) start */
+	fat_type_t type;
+	unsigned int bytes_per_sector;
+	unsigned int sectors_per_cluster;
+	unsigned int reserved;
+	unsigned int num_fats;
+	unsigned int sec_per_fat;
+	unsigned int root_entries;      /* 0 for FAT32 */
+	unsigned int root_dir_sectors;
+	unsigned int root_cluster;      /* FAT32 root (2); 0 otherwise */
+	unsigned int root_start;        /* LBA of root dir (FAT12/16) */
+	unsigned int data_start;        /* LBA of first data cluster */
+	unsigned int total_sectors;
+	unsigned int max_cluster;
+	char label[12];                /* trimmed 8.3 volume label + NUL */
+	int mounted;
+} fat_fs_t;
+
+/* Mount (parse BPB + validate FAT media byte) a filesystem at part_lba on dev.
+ * Returns 0 on success, -1 if no valid FAT, -2 on I/O error. */
+int fat_mount(blk_dev_t *dev, unsigned int part_lba, fat_fs_t *fs);
+
+/* Iterate a directory (root or subdir), call callback for each entry. */
+int fat_list_dir(fat_fs_t *fs, unsigned int dir_cluster, fat_root_callback_t callback);
+
+/* Read a file by 8.3 name in a directory. */
+int fat_read_file_in(fat_fs_t *fs, unsigned int dir_cluster, const char *name_8_3,
+		     void *buf, unsigned int max_len);
+
+/* Write / delete / mkdir / rmdir. Return -1 if FAT32 (read-only). */
+int fat_write_file_in(fat_fs_t *fs, unsigned int dir_cluster, const char *name_8_3,
+		      const void *buf, unsigned int size);
+int fat_delete_file_in(fat_fs_t *fs, unsigned int dir_cluster, const char *name_8_3);
+int fat_mkdir(fat_fs_t *fs, unsigned int parent_cluster, const char *name_8_3);
+int fat_rmdir(fat_fs_t *fs, unsigned int parent_cluster, const char *name_8_3);
+
+/* Resolve a path "a/b/c" into (parent dir cluster, final 8.3 name). */
+int fat_resolve_path(fat_fs_t *fs, const char *path, unsigned int *dir_cluster,
+		     char name_8_3[12]);
 
 
 /* Resolve a full path (all components directories) to a directory cluster.
 /* Resolve a full path (all components directories) to a directory cluster.
- * An empty path resolves to the root (cluster 0). */
-int fat_resolve_dir(const char *path, unsigned int *dir_cluster);
+ * An empty path resolves to the root. */
+int fat_resolve_dir(fat_fs_t *fs, const char *path, unsigned int *dir_cluster);
 
 
 #endif
 #endif

+ 1 - 1
fatdetect.h

@@ -3,7 +3,7 @@
 #ifndef FATDETECT_H
 #ifndef FATDETECT_H
 #define FATDETECT_H
 #define FATDETECT_H
 
 
-typedef enum { FAT_NONE, FAT12, FAT16, FAT32 } fat_type_t;
+#include "fat.h"
 
 
 typedef struct {
 typedef struct {
 	fat_type_t type;
 	fat_type_t type;

+ 23 - 21
ls.c

@@ -1,7 +1,9 @@
-/* ls command: list a directory (root by default, or a path). */
+/* ls command: list a directory. `ls` / `ls /` lists mounted filesystems;
+ * `ls /<device>[/dir]` lists a directory on that filesystem. */
 
 
 #include "fat.h"
 #include "fat.h"
 #include "io.h"
 #include "io.h"
+#include "vfs.h"
 
 
 #define BUF_SIZE 12
 #define BUF_SIZE 12
 
 
@@ -38,34 +40,34 @@ static void list_cb(const char *name, int is_dir, unsigned int size)
 
 
 void program_ls_main(const char *path)
 void program_ls_main(const char *path)
 {
 {
-	unsigned int dir_cluster = 0;
+	fat_fs_t *fs;
+	const char *fs_path;
+	unsigned int dir_cluster;
 	int r;
 	int r;
 
 
-	r = fat_init();
-	if (r == -2) {
-		io_putstr("ls: disk read error\n");
-		return;
-	}
-	if (r != 0) {
-		io_putstr("ls: no FAT filesystem found\n");
+	vfs_mount_all();
+
+	if (!path || !path[0] || (path[0] == '/' && path[1] == '\0')) {
+		vfs_list_root();
 		return;
 		return;
 	}
 	}
 
 
-	if (path && path[0]) {
-		r = fat_resolve_dir(path, &dir_cluster);
-		if (r == -2) {
-			io_putstr("ls: disk error\n");
-			return;
-		}
-		if (r != 0) {
-			io_putstr("ls: not a directory\n");
-			return;
-		}
+	if (vfs_resolve(path, &fs, &fs_path) != 0) {
+		io_putstr("ls: unknown device or invalid path\n");
+		return;
 	}
 	}
 
 
-	r = fat_list_dir(dir_cluster, list_cb);
+	r = fat_resolve_dir(fs, fs_path, &dir_cluster);
 	if (r == -2) {
 	if (r == -2) {
-		io_putstr("ls: disk read error\n");
+		io_putstr("ls: disk error\n");
 		return;
 		return;
 	}
 	}
+	if (r != 0) {
+		io_putstr("ls: not a directory\n");
+		return;
+	}
+
+	r = fat_list_dir(fs, dir_cluster, list_cb);
+	if (r == -2)
+		io_putstr("ls: disk read error\n");
 }
 }

+ 12 - 7
mkdir.c

@@ -1,28 +1,33 @@
-/* mkdir command: create a subdirectory. Usage: mkdir <path>. */
+/* mkdir command: create a subdirectory. Usage: mkdir /<device>/<dir>. */
 
 
 #include "fat.h"
 #include "fat.h"
 #include "io.h"
 #include "io.h"
+#include "vfs.h"
 
 
 void program_mkdir_main(const char *arg)
 void program_mkdir_main(const char *arg)
 {
 {
+	fat_fs_t *fs;
+	const char *fs_path;
 	unsigned int dir_cluster;
 	unsigned int dir_cluster;
 	char name_8_3[12];
 	char name_8_3[12];
 	int r;
 	int r;
 
 
 	if (!arg || !arg[0]) {
 	if (!arg || !arg[0]) {
-		io_putstr("mkdir: usage mkdir <dir>\n");
+		io_putstr("mkdir: usage mkdir /<device>/<dir>\n");
 		return;
 		return;
 	}
 	}
 
 
-	r = fat_init();
-	if (r == -2) { io_putstr("mkdir: disk read error\n"); return; }
-	if (r != 0) { io_putstr("mkdir: no FAT filesystem found\n"); return; }
+	vfs_mount_all();
+	if (vfs_resolve(arg, &fs, &fs_path) != 0) {
+		io_putstr("mkdir: unknown device or invalid path\n");
+		return;
+	}
 
 
-	r = fat_resolve_path(arg, &dir_cluster, name_8_3);
+	r = fat_resolve_path(fs, fs_path, &dir_cluster, name_8_3);
 	if (r == -2) { io_putstr("mkdir: disk error\n"); return; }
 	if (r == -2) { io_putstr("mkdir: disk error\n"); return; }
 	if (r != 0) { io_putstr("mkdir: invalid path\n"); return; }
 	if (r != 0) { io_putstr("mkdir: invalid path\n"); return; }
 
 
-	r = fat_mkdir(dir_cluster, name_8_3);
+	r = fat_mkdir(fs, dir_cluster, name_8_3);
 	if (r == -2) { io_putstr("mkdir: disk error\n"); return; }
 	if (r == -2) { io_putstr("mkdir: disk error\n"); return; }
 	if (r != 0) return;  /* fat_mkdir already printed */
 	if (r != 0) return;  /* fat_mkdir already printed */
 	io_putstr("mkdir ok\n");
 	io_putstr("mkdir ok\n");

+ 12 - 7
rm.c

@@ -1,28 +1,33 @@
-/* rm command: delete a file. Usage: rm <path>. */
+/* rm command: delete a file. Usage: rm /<device>/<file>. */
 
 
 #include "fat.h"
 #include "fat.h"
 #include "io.h"
 #include "io.h"
+#include "vfs.h"
 
 
 void program_rm_main(const char *arg)
 void program_rm_main(const char *arg)
 {
 {
+	fat_fs_t *fs;
+	const char *fs_path;
 	unsigned int dir_cluster;
 	unsigned int dir_cluster;
 	char name_8_3[12];
 	char name_8_3[12];
 	int r;
 	int r;
 
 
 	if (!arg || !arg[0]) {
 	if (!arg || !arg[0]) {
-		io_putstr("rm: usage rm <file>\n");
+		io_putstr("rm: usage rm /<device>/<file>\n");
 		return;
 		return;
 	}
 	}
 
 
-	r = fat_init();
-	if (r == -2) { io_putstr("rm: disk read error\n"); return; }
-	if (r != 0) { io_putstr("rm: no FAT filesystem found\n"); return; }
+	vfs_mount_all();
+	if (vfs_resolve(arg, &fs, &fs_path) != 0) {
+		io_putstr("rm: unknown device or invalid path\n");
+		return;
+	}
 
 
-	r = fat_resolve_path(arg, &dir_cluster, name_8_3);
+	r = fat_resolve_path(fs, fs_path, &dir_cluster, name_8_3);
 	if (r == -2) { io_putstr("rm: disk error\n"); return; }
 	if (r == -2) { io_putstr("rm: disk error\n"); return; }
 	if (r != 0) { io_putstr("rm: not found\n"); return; }
 	if (r != 0) { io_putstr("rm: not found\n"); return; }
 
 
-	r = fat_delete_file_in(dir_cluster, name_8_3);
+	r = fat_delete_file_in(fs, dir_cluster, name_8_3);
 	if (r == -2) { io_putstr("rm: disk error\n"); return; }
 	if (r == -2) { io_putstr("rm: disk error\n"); return; }
 	if (r != 0) { io_putstr("rm: file not found\n"); return; }
 	if (r != 0) { io_putstr("rm: file not found\n"); return; }
 	io_putstr("removed\n");
 	io_putstr("removed\n");

+ 12 - 7
rmdir.c

@@ -1,28 +1,33 @@
-/* rmdir command: remove an empty subdirectory. Usage: rmdir <path>. */
+/* rmdir command: remove an empty subdirectory. Usage: rmdir /<device>/<dir>. */
 
 
 #include "fat.h"
 #include "fat.h"
 #include "io.h"
 #include "io.h"
+#include "vfs.h"
 
 
 void program_rmdir_main(const char *arg)
 void program_rmdir_main(const char *arg)
 {
 {
+	fat_fs_t *fs;
+	const char *fs_path;
 	unsigned int dir_cluster;
 	unsigned int dir_cluster;
 	char name_8_3[12];
 	char name_8_3[12];
 	int r;
 	int r;
 
 
 	if (!arg || !arg[0]) {
 	if (!arg || !arg[0]) {
-		io_putstr("rmdir: usage rmdir <dir>\n");
+		io_putstr("rmdir: usage rmdir /<device>/<dir>\n");
 		return;
 		return;
 	}
 	}
 
 
-	r = fat_init();
-	if (r == -2) { io_putstr("rmdir: disk read error\n"); return; }
-	if (r != 0) { io_putstr("rmdir: no FAT filesystem found\n"); return; }
+	vfs_mount_all();
+	if (vfs_resolve(arg, &fs, &fs_path) != 0) {
+		io_putstr("rmdir: unknown device or invalid path\n");
+		return;
+	}
 
 
-	r = fat_resolve_path(arg, &dir_cluster, name_8_3);
+	r = fat_resolve_path(fs, fs_path, &dir_cluster, name_8_3);
 	if (r == -2) { io_putstr("rmdir: disk error\n"); return; }
 	if (r == -2) { io_putstr("rmdir: disk error\n"); return; }
 	if (r != 0) { io_putstr("rmdir: invalid path\n"); return; }
 	if (r != 0) { io_putstr("rmdir: invalid path\n"); return; }
 
 
-	r = fat_rmdir(dir_cluster, name_8_3);
+	r = fat_rmdir(fs, dir_cluster, name_8_3);
 	if (r == -2) { io_putstr("rmdir: disk error\n"); return; }
 	if (r == -2) { io_putstr("rmdir: disk error\n"); return; }
 	if (r != 0) return;  /* fat_rmdir already printed */
 	if (r != 0) return;  /* fat_rmdir already printed */
 	io_putstr("rmdir ok\n");
 	io_putstr("rmdir ok\n");

+ 20 - 34
run.c

@@ -1,4 +1,5 @@
-/* run command: load raw binary from FAT floppy to 0x31000 and execute. */
+/* run command: load raw binary from a FAT filesystem to 0x31000 and execute.
+ * Usage: run /<device>/<file>. */
 
 
 #include "fat.h"
 #include "fat.h"
 #include "fbtext.h"
 #include "fbtext.h"
@@ -7,57 +8,41 @@
 #include "serial.h"
 #include "serial.h"
 #include "timer.h"
 #include "timer.h"
 #include "vga.h"
 #include "vga.h"
+#include "vfs.h"
 
 
 #define PROGRAM_LOAD_ADDR 0x31000
 #define PROGRAM_LOAD_ADDR 0x31000
 #define PROGRAM_LOAD_MAX  0x10000
 #define PROGRAM_LOAD_MAX  0x10000
-#define NAME_BUF_SIZE     12
-
-static void to_8_3(const char *in, unsigned int in_len, char *out)
-{
-	unsigned int i, j, dot;
-	for (i = 0; i < in_len && in[i] == ' '; i++)
-		;
-	dot = i;
-	while (dot < in_len && in[dot] != '\0' && in[dot] != '.' && in[dot] != ' ')
-		dot++;
-	j = 0;
-	while (i < dot && j < 8) {
-		out[j++] = (char)(in[i] >= 'a' && in[i] <= 'z' ? in[i] - 32 : in[i]);
-		i++;
-	}
-	while (j < 8)
-		out[j++] = ' ';
-	if (i < in_len && in[i] == '.')
-		i++;
-	while (i < in_len && in[i] != '\0' && in[i] != ' ' && j < 11) {
-		out[j++] = (char)(in[i] >= 'a' && in[i] <= 'z' ? in[i] - 32 : in[i]);
-		i++;
-	}
-	while (j < 11)
-		out[j++] = ' ';
-	out[11] = '\0';
-}
 
 
 void program_run_main(const char *filename)
 void program_run_main(const char *filename)
 {
 {
-	char name_8_3[NAME_BUF_SIZE];
+	fat_fs_t *fs;
+	const char *fs_path;
+	unsigned int dir_cluster;
+	char name_8_3[12];
 	int n;
 	int n;
 
 
 	if (!filename || !filename[0]) {
 	if (!filename || !filename[0]) {
-		io_putstr("run: usage run <filename>\n");
+		io_putstr("run: usage run /<device>/<file>\n");
+		return;
+	}
+
+	vfs_mount_all();
+	if (vfs_resolve(filename, &fs, &fs_path) != 0) {
+		io_putstr("run: unknown device or invalid path\n");
 		return;
 		return;
 	}
 	}
-	to_8_3(filename, 64, name_8_3);
-	n = fat_init();
+
+	n = fat_resolve_path(fs, fs_path, &dir_cluster, name_8_3);
 	if (n == -2) {
 	if (n == -2) {
 		io_putstr("run: disk read error (see above)\n");
 		io_putstr("run: disk read error (see above)\n");
 		return;
 		return;
 	}
 	}
 	if (n != 0) {
 	if (n != 0) {
-		io_putstr("run: no FAT filesystem found\n");
+		io_putstr("run: file not found\n");
 		return;
 		return;
 	}
 	}
-	n = fat_read_file(name_8_3, (void *)PROGRAM_LOAD_ADDR, PROGRAM_LOAD_MAX);
+
+	n = fat_read_file_in(fs, dir_cluster, name_8_3, (void *)PROGRAM_LOAD_ADDR, PROGRAM_LOAD_MAX);
 	if (n == -2) {
 	if (n == -2) {
 		io_putstr("run: disk read error (see above)\n");
 		io_putstr("run: disk read error (see above)\n");
 		return;
 		return;
@@ -66,6 +51,7 @@ void program_run_main(const char *filename)
 		io_putstr("run: file not found\n");
 		io_putstr("run: file not found\n");
 		return;
 		return;
 	}
 	}
+
 	io_drain_keyboard();
 	io_drain_keyboard();
 	{
 	{
 		struct prog_api api = {
 		struct prog_api api = {

+ 14 - 8
save.c

@@ -1,19 +1,23 @@
-/* save command: write a text string to a file. Usage: save <file> <text...>. */
+/* save command: write a text string to a file.
+ * Usage: save /<device>/<file> <text...>. */
 
 
 #include "fat.h"
 #include "fat.h"
 #include "io.h"
 #include "io.h"
+#include "vfs.h"
 
 
 void program_save_main(const char *arg)
 void program_save_main(const char *arg)
 {
 {
 	char fn[64];
 	char fn[64];
 	unsigned int i, fn_len, text_len;
 	unsigned int i, fn_len, text_len;
+	fat_fs_t *fs;
+	const char *fs_path;
 	unsigned int dir_cluster;
 	unsigned int dir_cluster;
 	char name_8_3[12];
 	char name_8_3[12];
 	const char *text;
 	const char *text;
 	int r;
 	int r;
 
 
 	if (!arg || !arg[0]) {
 	if (!arg || !arg[0]) {
-		io_putstr("save: usage save <file> <text>\n");
+		io_putstr("save: usage save /<device>/<file> <text>\n");
 		return;
 		return;
 	}
 	}
 
 
@@ -31,7 +35,7 @@ void program_save_main(const char *arg)
 	}
 	}
 	fn[fn_len] = '\0';
 	fn[fn_len] = '\0';
 	if (fn_len == 0) {
 	if (fn_len == 0) {
-		io_putstr("save: usage save <file> <text>\n");
+		io_putstr("save: usage save /<device>/<file> <text>\n");
 		return;
 		return;
 	}
 	}
 
 
@@ -44,15 +48,17 @@ void program_save_main(const char *arg)
 	while (text[text_len])
 	while (text[text_len])
 		text_len++;
 		text_len++;
 
 
-	r = fat_init();
-	if (r == -2) { io_putstr("save: disk read error\n"); return; }
-	if (r != 0) { io_putstr("save: no FAT filesystem found\n"); return; }
+	vfs_mount_all();
+	if (vfs_resolve(fn, &fs, &fs_path) != 0) {
+		io_putstr("save: unknown device or invalid path\n");
+		return;
+	}
 
 
-	r = fat_resolve_path(fn, &dir_cluster, name_8_3);
+	r = fat_resolve_path(fs, fs_path, &dir_cluster, name_8_3);
 	if (r == -2) { io_putstr("save: disk error\n"); return; }
 	if (r == -2) { io_putstr("save: disk error\n"); return; }
 	if (r != 0) { io_putstr("save: invalid path\n"); return; }
 	if (r != 0) { io_putstr("save: invalid path\n"); return; }
 
 
-	r = fat_write_file_in(dir_cluster, name_8_3, text, text_len);
+	r = fat_write_file_in(fs, dir_cluster, name_8_3, text, text_len);
 	if (r == -2) { io_putstr("save: disk write error\n"); return; }
 	if (r == -2) { io_putstr("save: disk write error\n"); return; }
 	if (r != 0) { io_putstr("save: write failed\n"); return; }
 	if (r != 0) { io_putstr("save: write failed\n"); return; }
 	io_putstr("saved\n");
 	io_putstr("saved\n");

+ 8 - 8
terminal.c

@@ -799,7 +799,7 @@ void terminal_run(void)
 						if (process_create_arg("rm", program_rm_main, rm_fname) < 0)
 						if (process_create_arg("rm", program_rm_main, rm_fname) < 0)
 							io_putstr("error: too many processes\n");
 							io_putstr("error: too many processes\n");
 					} else if (is_cmd_space(line, line_len)) {
 					} else if (is_cmd_space(line, line_len)) {
-						if (process_create_arg("space", program_run_main, "space.bin") < 0)
+						if (process_create_arg("space", program_run_main, "/floppy1/SPACE.BIN") < 0)
 							io_putstr("error: too many processes\n");
 							io_putstr("error: too many processes\n");
 					} else if (is_cmd_display(line, line_len)) {
 					} else if (is_cmd_display(line, line_len)) {
 						if (process_create("display", program_display_main) < 0)
 						if (process_create("display", program_display_main) < 0)
@@ -835,13 +835,13 @@ void terminal_run(void)
 						io_putstr("hello\n");
 						io_putstr("hello\n");
 						io_putstr("reboot\n");
 						io_putstr("reboot\n");
 						io_putstr("poweroff\n");
 						io_putstr("poweroff\n");
-						io_putstr("ls [dir]\n");
-						io_putstr("cat <file>\n");
-						io_putstr("save <f> <text>\n");
-						io_putstr("rm <file>\n");
-						io_putstr("mkdir <dir>\n");
-						io_putstr("rmdir <dir>\n");
-						io_putstr("run <file>\n");
+						io_putstr("ls [/dev[/dir]]\n");
+						io_putstr("cat /dev/file\n");
+						io_putstr("save /dev/file <text>\n");
+						io_putstr("rm /dev/file\n");
+						io_putstr("mkdir /dev/dir\n");
+						io_putstr("rmdir /dev/dir\n");
+						io_putstr("run /dev/file\n");
 						io_putstr("space\n");
 						io_putstr("space\n");
 						io_putstr("clock\n");
 						io_putstr("clock\n");
 						io_putstr("colors\n");
 						io_putstr("colors\n");

+ 194 - 0
vfs.c

@@ -0,0 +1,194 @@
+/* Virtual filesystem: mount every device with a valid FAT filesystem under `/`. */
+
+#include "vfs.h"
+#include "fatdetect.h"
+#include "io.h"
+
+vfs_mount_t vfs_mounts[VFS_MAX_MOUNTS];
+unsigned int vfs_mount_count;
+
+static void put_dec(unsigned int n)
+{
+	char buf[12];
+	unsigned int i = sizeof(buf) - 1;
+	buf[i] = '\0';
+	if (n == 0) {
+		io_putchar('0');
+		return;
+	}
+	while (n && i > 0) {
+		buf[--i] = (char)('0' + (n % 10));
+		n /= 10;
+	}
+	io_putstr(buf + i);
+}
+
+static void put_size(unsigned int bytes)
+{
+	if (bytes >= 1024u * 1024u * 1024u) {
+		unsigned int gb = bytes / (1024u * 1024u * 1024u);
+		unsigned int tenths = (bytes % (1024u * 1024u * 1024u)) * 10u / (1024u * 1024u * 1024u);
+		put_dec(gb);
+		if (tenths) {
+			io_putchar('.');
+			put_dec(tenths);
+		}
+		io_putstr(" GB");
+	} else if (bytes >= 1024u * 1024u) {
+		unsigned int mb = bytes / (1024u * 1024u);
+		unsigned int tenths = (bytes % (1024u * 1024u)) * 10u / (1024u * 1024u);
+		put_dec(mb);
+		if (tenths) {
+			io_putchar('.');
+			put_dec(tenths);
+		}
+		io_putstr(" MB");
+	} else {
+		put_dec(bytes / 1024u);
+		io_putstr(" KB");
+	}
+}
+
+static const char *fat_name(fat_type_t t)
+{
+	switch (t) {
+	case FAT12: return "FAT12";
+	case FAT16: return "FAT16";
+	case FAT32: return "FAT32";
+	default:    return "FAT";
+	}
+}
+
+static void mount_one(blk_dev_t *dev, unsigned int part_lba, const char *name)
+{
+	fat_fs_t fs;
+	unsigned int i;
+
+	if (vfs_mount_count >= VFS_MAX_MOUNTS)
+		return;
+	if (fat_mount(dev, part_lba, &fs) != 0)
+		return;
+
+	for (i = 0; name[i] && i < sizeof(vfs_mounts[vfs_mount_count].name) - 1; i++)
+		vfs_mounts[vfs_mount_count].name[i] = name[i];
+	vfs_mounts[vfs_mount_count].name[i] = '\0';
+	vfs_mounts[vfs_mount_count].fs = fs;
+	vfs_mounts[vfs_mount_count].mounted = 1;
+	vfs_mount_count++;
+}
+
+static void part_name(char *out, const char *base, unsigned int idx)
+{
+	unsigned int i = 0;
+	while (base[i] && i < 13) {
+		out[i] = base[i];
+		i++;
+	}
+	out[i++] = 'p';
+	out[i++] = (char)('0' + idx + 1);
+	out[i] = '\0';
+}
+
+void vfs_mount_all(void)
+{
+	static unsigned char buf[512];
+	unsigned int i;
+
+	vfs_mount_count = 0;
+	blk_scan();
+
+	for (i = 0; i < blk_dev_count; i++) {
+		blk_dev_t *d = &blk_devs[i];
+
+		if (d->kind == BLK_IDE && !d->present)
+			continue;
+
+		if (d->kind == BLK_FLOPPY) {
+			mount_one(d, 0, d->name);
+			continue;
+		}
+
+		/* IDE: MBR -> FAT partitions, else superfloppy. */
+		{
+			mbr_part_t parts[4];
+			int n, j;
+			int any_fat = 0;
+
+			if (blk_read(d, 0, buf, 1) != 0)
+				continue;
+			n = mbr_parse(buf, parts);
+			for (j = 0; j < n; j++) {
+				char pname[16];
+				if (!parts[j].is_fat || parts[j].start_lba == 0 ||
+				    parts[j].sectors == 0)
+					continue;
+				any_fat = 1;
+				part_name(pname, d->name, parts[j].index);
+				mount_one(d, parts[j].start_lba, pname);
+			}
+			if (!any_fat)
+				mount_one(d, 0, d->name);
+		}
+	}
+}
+
+vfs_mount_t *vfs_find(const char *name)
+{
+	unsigned int i;
+	for (i = 0; i < vfs_mount_count; i++) {
+		unsigned int j = 0;
+		while (vfs_mounts[i].name[j] && name[j] &&
+		       vfs_mounts[i].name[j] == name[j])
+			j++;
+		if (vfs_mounts[i].name[j] == '\0' && name[j] == '\0')
+			return &vfs_mounts[i];
+	}
+	return 0;
+}
+
+void vfs_list_root(void)
+{
+	unsigned int i;
+	for (i = 0; i < vfs_mount_count; i++) {
+		vfs_mount_t *m = &vfs_mounts[i];
+		fat_fs_t *fs = &m->fs;
+		io_putstr(m->name);
+		io_putstr("  ");
+		io_putstr(fat_name(fs->type));
+		io_putchar(' ');
+		put_size(fs->total_sectors * fs->bytes_per_sector);
+		if (fs->label[0]) {
+			io_putstr("  \"");
+			io_putstr(fs->label);
+			io_putchar('"');
+		}
+		io_putchar('\n');
+	}
+}
+
+int vfs_resolve(const char *path, fat_fs_t **fs, const char **fs_path)
+{
+	unsigned int i = 0, j;
+	char name[16];
+	vfs_mount_t *m;
+
+	if (!path || path[0] != '/')
+		return -1;
+
+	i = 1;
+	j = 0;
+	while (path[i] && path[i] != '/' && j < sizeof(name) - 1)
+		name[j++] = path[i++];
+	name[j] = '\0';
+
+	if (j == 0)
+		return -1;  /* path is just "/" */
+
+	m = vfs_find(name);
+	if (!m)
+		return -1;
+
+	*fs = &m->fs;
+	*fs_path = path + i;
+	return 0;
+}

+ 32 - 0
vfs.h

@@ -0,0 +1,32 @@
+/* Virtual filesystem: mounts every device with a valid FAT filesystem under
+ * `/` (e.g. /floppy0, /floppy1, /ide0p1). Provides path resolution so the
+ * shell commands operate on the right filesystem. */
+#ifndef VFS_H
+#define VFS_H
+
+#include "fat.h"
+
+typedef struct {
+	char name[16];
+	fat_fs_t fs;
+	int mounted;
+} vfs_mount_t;
+
+#define VFS_MAX_MOUNTS 12
+extern vfs_mount_t vfs_mounts[VFS_MAX_MOUNTS];
+extern unsigned int vfs_mount_count;
+
+/* Scan devices and mount all detected FAT filesystems. */
+void vfs_mount_all(void);
+
+/* Find a mount by name (NULL if not found). */
+vfs_mount_t *vfs_find(const char *name);
+
+/* Print the mount list (for `ls /`). */
+void vfs_list_root(void);
+
+/* Resolve an absolute path "/<mount>/<path>" into (fs, fs_path). The fs_path
+ * points into `path` (no copy). Returns 0 on success, -1 on error. */
+int vfs_resolve(const char *path, fat_fs_t **fs, const char **fs_path);
+
+#endif

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است