Kernel: Inode::create_file() now takes uid and gid as parameters

This commit is contained in:
Bananymous
2023-07-10 13:32:10 +03:00
parent d5f0448e48
commit 74fc0aa308
6 changed files with 12 additions and 8 deletions

View File

@@ -356,7 +356,7 @@ namespace Kernel
return {};
}
BAN::ErrorOr<void> Ext2Inode::create_file(BAN::StringView name, mode_t mode)
BAN::ErrorOr<void> Ext2Inode::create_file(BAN::StringView name, mode_t mode, uid_t uid, gid_t gid)
{
if (!this->mode().ifdir())
return BAN::Error::from_errno(ENOTDIR);
@@ -378,13 +378,13 @@ namespace Kernel
Ext2::Inode ext2_inode;
ext2_inode.mode = mode;
ext2_inode.uid = 0;
ext2_inode.uid = uid;
ext2_inode.size = 0;
ext2_inode.atime = current_time;
ext2_inode.ctime = current_time;
ext2_inode.mtime = current_time;
ext2_inode.dtime = current_time;
ext2_inode.gid = 0;
ext2_inode.gid = gid;
ext2_inode.links_count = 1;
ext2_inode.blocks = 0;
ext2_inode.flags = 0;

View File

@@ -153,8 +153,12 @@ namespace Kernel
return {};
}
BAN::ErrorOr<void> RamDirectoryInode::create_file(BAN::StringView, mode_t)
BAN::ErrorOr<void> RamDirectoryInode::create_file(BAN::StringView name, mode_t mode, uid_t uid, gid_t gid)
{
(void)name;
(void)mode;
(void)uid;
(void)gid;
ASSERT_NOT_REACHED();
}

View File

@@ -567,7 +567,7 @@ namespace Kernel
auto file_name = absolute_path.sv().substring(index);
auto parent_file = TRY(VirtualFileSystem::get().file_from_absolute_path(m_credentials, directory, O_WRONLY));
TRY(parent_file.inode->create_file(file_name, mode));
TRY(parent_file.inode->create_file(file_name, mode, m_credentials.euid(), m_credentials.egid()));
return 0;
}