fs: move fs init into kernel cmdline

Previously, any partition with an ext2 filesystem would be mounted by
the gpt header parser. With this patch, the kernel cmdline `root=val` is
responsible for mounting the root filesystem.
This commit is contained in:
Michael Shaw 2023-10-19 11:08:54 -04:00
commit 25a828437a
10 changed files with 150 additions and 32 deletions

View file

@ -141,7 +141,7 @@ struct ext2fs {
uint32_t block_size;
};
struct ext2fs *ext2_init_fs(struct block_device *bdev);
struct fs *ext2_init_fs(struct block_device *bdev);
/* Filesystem block sizes are not equal to block device block sizes */
int ext2_read_block(struct ext2fs *fs, void *buf, size_t block);

View file

@ -40,14 +40,15 @@ struct file {
uint64_t size; /* size of the file */
uint64_t pos; /* current position in the file */
void *fs_data;
void *fs_file;
};
struct fs_ops {
int (*read)(void *fs, struct file *file, void *buf, size_t offset, size_t size);
int (*write)(void *fs, struct file *file, void *buf, size_t offset, size_t size);
int (*read)(void *fs, struct file *file, void *buf, size_t size);
int (*write)(void *fs, struct file *file, void *buf, size_t size);
int (*open)(void *fs, struct file *file, const char *path);
int (*close)(void *fs, struct file *file);
int (*seek)(void *fs, struct file *file, size_t offset);
};
struct fs {
@ -56,4 +57,6 @@ struct fs {
struct fs_ops ops;
};
void vfs_init(const char *rootfs);
#endif /* _VFS_H_ */

View file

@ -28,6 +28,7 @@ struct block_device {
};
struct block_device *block_register(char *name, struct block_device_ops *ops, void *data, size_t block_count, size_t block_size);
struct block_device *block_get_device(const char *name);
int block_read(struct block_device *bdev, void *buf, size_t offset, size_t size);
int block_write(struct block_device *bdev, void *buf, size_t offset, size_t size);

View file

@ -12,6 +12,7 @@
void *memcpy(void *dest, const void *src, size_t num);
int memcmp(const void *aa, const void *bb, size_t num);
int strcmp(const char *a, const char *b);
int strncmp(const char *a, const char *b, size_t n);
void *memset(void *str, int c, size_t n);
char *strcpy(char *dest, const char *src);
char *strncpy(char *dest, const char *src, size_t n);