mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 11:16:47 +00:00
为vfs挂载文件系统增加挂载点路径参数
This commit is contained in:
parent
339053a20e
commit
86a5f25e07
@ -10,25 +10,31 @@
|
||||
|
||||
// 为filesystem_type_t结构体实例化一个链表头
|
||||
static struct vfs_filesystem_type_t vfs_fs = {"filesystem", 0};
|
||||
struct vfs_superblock_t *vfs_root_sb = NULL;
|
||||
|
||||
/**
|
||||
* @brief 挂载文件系统
|
||||
*
|
||||
* @param path 要挂载到的路径
|
||||
* @param name 文件系统名
|
||||
* @param blk 块设备结构体
|
||||
* @return struct vfs_superblock_t*
|
||||
* @return struct vfs_superblock_t* 挂载后,文件系统的超级块
|
||||
*/
|
||||
struct vfs_superblock_t *vfs_mount_fs(char *name, struct block_device *blk)
|
||||
struct vfs_superblock_t *vfs_mount_fs(const char *path, char *name, struct block_device *blk)
|
||||
{
|
||||
|
||||
// todo: 选择挂载点
|
||||
struct vfs_filesystem_type_t *p = NULL;
|
||||
for (p = &vfs_fs; p; p = p->next)
|
||||
{
|
||||
if (!strcmp(p->name, name)) // 存在符合的文件系统
|
||||
{
|
||||
return p->read_superblock(blk);
|
||||
struct vfs_superblock_t *sb = p->read_superblock(blk);
|
||||
if (strcmp(path, "/") == 0) // 如果挂载到的是'/'挂载点,则让其成为最顶层的文件系统
|
||||
vfs_root_sb = sb;
|
||||
return sb;
|
||||
}
|
||||
}
|
||||
|
||||
kdebug("unsupported fs: %s", name);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <common/fcntl.h>
|
||||
#include <common/blk_types.h>
|
||||
|
||||
struct vfs_superblock_t *vfs_root_sb = NULL;
|
||||
extern struct vfs_superblock_t *vfs_root_sb;
|
||||
|
||||
#define VFS_DPT_MBR 0 // MBR分区表
|
||||
#define VFS_DPT_GPT 1 // GPT分区表
|
||||
@ -175,11 +175,12 @@ uint64_t vfs_unregister_filesystem(struct vfs_filesystem_type_t *fs);
|
||||
/**
|
||||
* @brief 挂载文件系统
|
||||
*
|
||||
* @param path 要挂载到的路径
|
||||
* @param name 文件系统名
|
||||
* @param blk 块设备结构体
|
||||
* @return struct vfs_superblock_t*
|
||||
* @return struct vfs_superblock_t* 挂载后,文件系统的超级块
|
||||
*/
|
||||
struct vfs_superblock_t *vfs_mount_fs(char *name, struct block_device *blk);
|
||||
struct vfs_superblock_t *vfs_mount_fs(const char *path, char *name, struct block_device *blk);
|
||||
|
||||
/**
|
||||
* @brief 按照路径查找文件
|
||||
|
@ -28,7 +28,7 @@ struct vfs_superblock_t *fat32_register_partition(uint8_t ahci_ctrl_num, uint8_t
|
||||
{
|
||||
|
||||
// 挂载文件系统到vfs
|
||||
return vfs_mount_fs("FAT32", (ahci_gendisk0.partition + 0));
|
||||
return vfs_mount_fs("/", "FAT32", (ahci_gendisk0.partition + 0));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1263,6 +1263,6 @@ void fat32_init()
|
||||
vfs_register_filesystem(&fat32_fs_type);
|
||||
|
||||
// 挂载根文件系统
|
||||
vfs_root_sb = fat32_register_partition(0, 0, 0);
|
||||
fat32_register_partition(0, 0, 0);
|
||||
kinfo("FAT32 initialized.");
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user