X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/290981180b9abc454e017271a8ebe75478c00e86..8c06c883e7b13c115d5ff207f79d4b68fccd5ad6:/lunaix-os/kernel/fs/mount.c diff --git a/lunaix-os/kernel/fs/mount.c b/lunaix-os/kernel/fs/mount.c index ca80238..97ef359 100644 --- a/lunaix-os/kernel/fs/mount.c +++ b/lunaix-os/kernel/fs/mount.c @@ -3,8 +3,12 @@ #include #include #include +#include +#include #include +LOG_MODULE("fs") + struct llist_header all_mnts = { .next = &all_mnts, .prev = &all_mnts }; struct v_mount* @@ -129,7 +133,11 @@ vfs_mount_at(const char* fs_name, struct v_dnode* mnt_point, int options) { - if (mnt_point->inode && !(mnt_point->inode->itype & VFS_IFDIR)) { + if (device && device->dev_type != DEV_IFVOL) { + return ENOTBLK; + } + + if (mnt_point->inode && (mnt_point->inode->itype & F_MFILE)) { return ENOTDIR; } @@ -138,11 +146,20 @@ vfs_mount_at(const char* fs_name, return ENODEV; } + if (fs->types == FSTYPE_ROFS) { + options |= MNT_RO; + } + + char* dev_name = "sys"; struct v_mount* parent_mnt = mnt_point->mnt; struct v_superblock *sb = vfs_sb_alloc(), *old_sb = mnt_point->super_block; sb->dev = device; mnt_point->super_block = sb; + if (device) { + dev_name = device->name_val; + } + int errno = 0; if (!(errno = fs->mount(sb, mnt_point))) { sb->fs = fs; @@ -153,6 +170,8 @@ vfs_mount_at(const char* fs_name, goto cleanup; } + kprintf("mount: dev=%s, fs=%s, mode=%d", dev_name, fs_name, options); + mnt_point->mnt->flags = options; } else { goto cleanup; @@ -161,6 +180,11 @@ vfs_mount_at(const char* fs_name, return errno; cleanup: + kprintf(KERROR "mount: dev=%s, fs=%s, mode=%d, err=%d", + dev_name, + fs_name, + options, + errno); mnt_point->super_block = old_sb; vfs_sb_free(sb); return errno;