mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 07:04:59 +00:00
Kernel: Allow passing initial UID and GID when creating new inodes
If we're creating something that should have a different owner than the current process's UID/GID, we need to plumb that all the way through VFS down to the FS functions.
This commit is contained in:
parent
82760998a9
commit
4abbedb6e4
11 changed files with 41 additions and 33 deletions
|
@ -1284,7 +1284,7 @@ bool Ext2FS::set_block_allocation_state(BlockIndex block_index, bool new_state)
|
|||
return true;
|
||||
}
|
||||
|
||||
RefPtr<Inode> Ext2FS::create_directory(InodeIdentifier parent_id, const String& name, mode_t mode, int& error)
|
||||
RefPtr<Inode> Ext2FS::create_directory(InodeIdentifier parent_id, const String& name, mode_t mode, uid_t uid, gid_t gid, int& error)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(parent_id.fsid() == fsid());
|
||||
|
@ -1296,7 +1296,7 @@ RefPtr<Inode> Ext2FS::create_directory(InodeIdentifier parent_id, const String&
|
|||
|
||||
// NOTE: When creating a new directory, make the size 1 block.
|
||||
// There's probably a better strategy here, but this works for now.
|
||||
auto inode = create_inode(parent_id, name, mode, block_size(), 0, error);
|
||||
auto inode = create_inode(parent_id, name, mode, block_size(), 0, uid, gid, error);
|
||||
if (!inode)
|
||||
return nullptr;
|
||||
|
||||
|
@ -1328,7 +1328,7 @@ RefPtr<Inode> Ext2FS::create_directory(InodeIdentifier parent_id, const String&
|
|||
return inode;
|
||||
}
|
||||
|
||||
RefPtr<Inode> Ext2FS::create_inode(InodeIdentifier parent_id, const String& name, mode_t mode, off_t size, dev_t dev, int& error)
|
||||
RefPtr<Inode> Ext2FS::create_inode(InodeIdentifier parent_id, const String& name, mode_t mode, off_t size, dev_t dev, uid_t uid, gid_t gid, int& error)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(parent_id.fsid() == fsid());
|
||||
|
@ -1378,8 +1378,8 @@ RefPtr<Inode> Ext2FS::create_inode(InodeIdentifier parent_id, const String& name
|
|||
ext2_inode e2inode;
|
||||
memset(&e2inode, 0, sizeof(ext2_inode));
|
||||
e2inode.i_mode = mode;
|
||||
e2inode.i_uid = current->process().euid();
|
||||
e2inode.i_gid = current->process().egid();
|
||||
e2inode.i_uid = uid;
|
||||
e2inode.i_gid = gid;
|
||||
e2inode.i_size = size;
|
||||
e2inode.i_atime = now.tv_sec;
|
||||
e2inode.i_ctime = now.tv_sec;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue