summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kernel/FileSystem/FileDescriptor.cpp7
-rw-r--r--Kernel/FileSystem/FileDescriptor.h2
-rw-r--r--Kernel/Process.cpp8
3 files changed, 11 insertions, 6 deletions
diff --git a/Kernel/FileSystem/FileDescriptor.cpp b/Kernel/FileSystem/FileDescriptor.cpp
index e76f7d7b6a..68bc0c8329 100644
--- a/Kernel/FileSystem/FileDescriptor.cpp
+++ b/Kernel/FileSystem/FileDescriptor.cpp
@@ -328,3 +328,10 @@ const Socket* FileDescriptor::socket() const
return nullptr;
return static_cast<const Socket*>(m_file.ptr());
}
+
+void FileDescriptor::set_file_flags(dword flags)
+{
+ m_is_blocking = !(flags & O_NONBLOCK);
+ m_should_append = flags & O_APPEND;
+ m_file_flags = flags;
+}
diff --git a/Kernel/FileSystem/FileDescriptor.h b/Kernel/FileSystem/FileDescriptor.h
index 60d7cc5679..b6d1256c2b 100644
--- a/Kernel/FileSystem/FileDescriptor.h
+++ b/Kernel/FileSystem/FileDescriptor.h
@@ -72,7 +72,7 @@ public:
void set_should_append(bool s) { m_should_append = s; }
dword file_flags() const { return m_file_flags; }
- void set_file_flags(dword flags) { m_file_flags = flags; }
+ void set_file_flags(dword);
bool is_socket() const;
Socket* socket();
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 0f82792c35..99a43d9472 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -1012,7 +1012,6 @@ int Process::sys$fcntl(int fd, int cmd, dword arg)
case F_GETFL:
return descriptor->file_flags();
case F_SETFL:
- // FIXME: Support changing O_NONBLOCK
descriptor->set_file_flags(arg);
break;
default:
@@ -1125,10 +1124,9 @@ int Process::sys$open(const char* path, int options, mode_t mode)
auto descriptor = result.value();
if (options & O_DIRECTORY && !descriptor->is_directory())
return -ENOTDIR; // FIXME: This should be handled by VFS::open.
- descriptor->set_blocking(!(options & O_NONBLOCK));
- descriptor->set_should_append(options & O_APPEND);
- dword flags = (options & O_CLOEXEC) ? FD_CLOEXEC : 0;
- m_fds[fd].set(move(descriptor), flags);
+ descriptor->set_file_flags(options);
+ dword fd_flags = (options & O_CLOEXEC) ? FD_CLOEXEC : 0;
+ m_fds[fd].set(move(descriptor), fd_flags);
return fd;
}