X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/290981180b9abc454e017271a8ebe75478c00e86..8ce769cc52e91ff3cdb8eda4b1f5d8fe58241688:/lunaix-os/kernel/fs/mount.c diff --git a/lunaix-os/kernel/fs/mount.c b/lunaix-os/kernel/fs/mount.c index ca80238..7db9513 100644 --- a/lunaix-os/kernel/fs/mount.c +++ b/lunaix-os/kernel/fs/mount.c @@ -3,8 +3,11 @@ #include #include #include +#include #include +LOG_MODULE("fs") + struct llist_header all_mnts = { .next = &all_mnts, .prev = &all_mnts }; struct v_mount* @@ -129,6 +132,10 @@ vfs_mount_at(const char* fs_name, struct v_dnode* mnt_point, int options) { + if (device && device->dev_type != DEV_IFVOL) { + return ENOTBLK; + } + if (mnt_point->inode && !(mnt_point->inode->itype & VFS_IFDIR)) { return ENOTDIR; } @@ -138,11 +145,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 +169,8 @@ vfs_mount_at(const char* fs_name, goto cleanup; } + kprintf("mount: dev=%s, fs=%s, mode=%d\n", dev_name, fs_name, options); + mnt_point->mnt->flags = options; } else { goto cleanup; @@ -161,6 +179,11 @@ vfs_mount_at(const char* fs_name, return errno; cleanup: + kprintf(KERROR "mount: dev=%s, fs=%s, mode=%d, err=%d\n", + dev_name, + fs_name, + options, + errno); mnt_point->super_block = old_sb; vfs_sb_free(sb); return errno;