From f2ea6c3d4c32c0a6ed160980bf19219d64ddccab Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 23 Jan 2021 15:29:58 +0100 Subject: [PATCH] Ext2FS: Don't create a directory when asked to create a socket file (mode & S_IFDIR) is not enough to check if "mode" is a directory, we have to check all the bits in the S_IFMT mask. Use the is_directory() helper to fix this bug. --- Kernel/FileSystem/Ext2FileSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 53f44c1d4e..ad761c79d0 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -1043,7 +1043,7 @@ bool Ext2FSInode::write_directory(const Vector& entries) KResultOr> Ext2FSInode::create_child(const String& name, mode_t mode, dev_t dev, uid_t uid, gid_t gid) { - if (mode & S_IFDIR) + if (::is_directory(mode)) return fs().create_directory(identifier(), name, mode, uid, gid); return fs().create_inode(identifier(), name, mode, 0, dev, uid, gid); }