forked from Bananymous/banan-os
Kernel: RamInode verifies that you have not specified mode type
This is kinda weird behaviour, but it ensures the user cannot create e.g. CharacterDevice with mode having IFLNK. The Inode overrider is the only one setting the mode.
This commit is contained in:
parent
8604c55de8
commit
dedb2a2399
|
@ -25,9 +25,9 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
BlockDevice(mode_t mode, uid_t uid, gid_t gid)
|
BlockDevice(mode_t mode, uid_t uid, gid_t gid)
|
||||||
: Device(Mode::IFBLK | mode, uid, gid)
|
: Device(mode, uid, gid)
|
||||||
{
|
{
|
||||||
ASSERT(Device::mode().ifblk());
|
m_inode_info.mode |= Inode::Mode::IFBLK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
CharacterDevice(mode_t mode, uid_t uid, gid_t gid)
|
CharacterDevice(mode_t mode, uid_t uid, gid_t gid)
|
||||||
: Device(Mode::IFCHR | mode, uid, gid)
|
: Device(mode, uid, gid)
|
||||||
{
|
{
|
||||||
ASSERT(Device::mode().ifchr());
|
m_inode_info.mode |= Inode::Mode::IFCHR;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,9 @@ namespace Kernel
|
||||||
RamInode(RamFileSystem& fs, const FullInodeInfo& inode_info)
|
RamInode(RamFileSystem& fs, const FullInodeInfo& inode_info)
|
||||||
: m_fs(fs)
|
: m_fs(fs)
|
||||||
, m_inode_info(inode_info)
|
, m_inode_info(inode_info)
|
||||||
{}
|
{
|
||||||
|
ASSERT((inode_info.mode & Inode::Mode::TYPE_MASK) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RamFileSystem& m_fs;
|
RamFileSystem& m_fs;
|
||||||
|
|
|
@ -45,7 +45,6 @@ namespace Kernel
|
||||||
RamFileInode::RamFileInode(RamFileSystem& fs, const FullInodeInfo& inode_info)
|
RamFileInode::RamFileInode(RamFileSystem& fs, const FullInodeInfo& inode_info)
|
||||||
: RamInode(fs, inode_info)
|
: RamInode(fs, inode_info)
|
||||||
{
|
{
|
||||||
ASSERT((m_inode_info.mode & Inode::Mode::TYPE_MASK) == 0);
|
|
||||||
m_inode_info.mode |= Inode::Mode::IFREG;
|
m_inode_info.mode |= Inode::Mode::IFREG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +107,6 @@ namespace Kernel
|
||||||
: RamInode(fs, inode_info)
|
: RamInode(fs, inode_info)
|
||||||
, m_parent(parent)
|
, m_parent(parent)
|
||||||
{
|
{
|
||||||
ASSERT((m_inode_info.mode & Inode::Mode::TYPE_MASK) == 0);
|
|
||||||
m_inode_info.mode |= Inode::Mode::IFDIR;
|
m_inode_info.mode |= Inode::Mode::IFDIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +261,6 @@ namespace Kernel
|
||||||
: RamInode(fs, inode_info)
|
: RamInode(fs, inode_info)
|
||||||
, m_target(BAN::move(target))
|
, m_target(BAN::move(target))
|
||||||
{
|
{
|
||||||
ASSERT((m_inode_info.mode & Inode::Mode::TYPE_MASK) == 0);
|
|
||||||
m_inode_info.mode |= Inode::Mode::IFLNK;
|
m_inode_info.mode |= Inode::Mode::IFLNK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue