Kernel/LibC: implement chmod syscall + libc wrapper
This commit is contained in:
@@ -242,6 +242,16 @@ namespace Kernel
|
||||
return {};
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> Ext2Inode::chmod_impl(mode_t mode)
|
||||
{
|
||||
ASSERT((mode & Inode::Mode::TYPE_MASK) == 0);
|
||||
if (m_inode.mode == mode)
|
||||
return {};
|
||||
m_inode.mode = (m_inode.mode & Inode::Mode::TYPE_MASK) | mode;
|
||||
TRY(sync());
|
||||
return {};
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> Ext2Inode::list_next_inodes_impl(off_t offset, DirectoryEntryList* list, size_t list_size)
|
||||
{
|
||||
ASSERT(mode().ifdir());
|
||||
|
||||
@@ -129,6 +129,14 @@ namespace Kernel
|
||||
return truncate_impl(size);
|
||||
}
|
||||
|
||||
BAN::ErrorOr<void> Inode::chmod(mode_t mode)
|
||||
{
|
||||
ASSERT((mode & Inode::Mode::TYPE_MASK) == 0);
|
||||
LockGuard _(m_lock);
|
||||
Thread::TerminateBlocker blocker(Thread::current());
|
||||
return chmod_impl(mode);
|
||||
}
|
||||
|
||||
bool Inode::has_data() const
|
||||
{
|
||||
LockGuard _(m_lock);
|
||||
|
||||
@@ -26,6 +26,14 @@ namespace Kernel
|
||||
this->rdev = 0;
|
||||
}
|
||||
|
||||
|
||||
BAN::ErrorOr<void> RamInode::chmod_impl(mode_t mode)
|
||||
{
|
||||
ASSERT((mode & Inode::Mode::TYPE_MASK) == 0);
|
||||
m_inode_info.mode = (m_inode_info.mode & Inode::Mode::TYPE_MASK) | mode;
|
||||
return {};
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
RAM FILE INODE
|
||||
@@ -193,9 +201,9 @@ namespace Kernel
|
||||
{
|
||||
BAN::RefPtr<RamInode> inode;
|
||||
if (Mode(mode).ifreg())
|
||||
inode = TRY(RamFileInode::create(m_fs, mode, uid, gid));
|
||||
inode = TRY(RamFileInode::create(m_fs, mode & ~Inode::Mode::TYPE_MASK, uid, gid));
|
||||
else if (Mode(mode).ifdir())
|
||||
inode = TRY(RamDirectoryInode::create(m_fs, ino(), mode, uid, gid));
|
||||
inode = TRY(RamDirectoryInode::create(m_fs, ino(), mode & ~Inode::Mode::TYPE_MASK, uid, gid));
|
||||
else
|
||||
ASSERT_NOT_REACHED();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user