1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +00:00

Kernel: Use symbolic constants for file modes

This fixes a bug where the mode of a FIFO was reported as 001000 instead
of 0010000 (you see the difference? me nethier), and hopefully doesn't
introduce new bugs. I've left 0777 and similar in a few places, because
that is *more* readable than its symbolic version.
This commit is contained in:
Sergey Bugaev 2020-06-16 22:03:51 +03:00 committed by Andreas Kling
parent fd985b1f48
commit e0d0d52455
5 changed files with 52 additions and 30 deletions

View file

@ -125,8 +125,8 @@ KResultOr<NonnullRefPtr<Inode>> TmpFS::create_inode(InodeIdentifier parent_id, c
KResult TmpFS::create_directory(InodeIdentifier parent_id, const String& name, mode_t mode, uid_t uid, gid_t gid)
{
// Ensure it's a directory.
mode &= ~0170000;
mode |= 0040000;
mode &= ~S_IFMT;
mode |= S_IFDIR;
auto result = create_inode(parent_id, name, mode, 0, 0, uid, gid);
if (result.is_error())
return result.error();
@ -155,7 +155,7 @@ NonnullRefPtr<TmpFSInode> TmpFSInode::create(TmpFS& fs, InodeMetadata metadata,
NonnullRefPtr<TmpFSInode> TmpFSInode::create_root(TmpFS& fs)
{
InodeMetadata metadata;
metadata.mode = 0041777;
metadata.mode = S_IFDIR | S_ISVTX | 0777;
return create(fs, metadata, { fs.fsid(), 1 });
}