vfs.h 914 B

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