creat: set flags in opened file descriptor

creat.2 is supposed to be equivalent to open.2 with the
flags O_WRONLY|O_CREAT|O_TRUNC.

However, in MentOS the fd returned by creat.2 has no flags whatsoever
and is thus not writable.

Set the flags of the file descriptor before returning it.
This commit is contained in:
Florian Fischer
2024-01-28 21:50:30 +01:00
parent c3c2ba824e
commit 89e6d75627
+1
View File
@@ -58,6 +58,7 @@ int sys_creat(const char *path, mode_t mode)
// Set the file descriptor id.
task->fd_list[fd].file_struct = file;
task->fd_list[fd].flags_mask = O_WRONLY|O_CREAT|O_TRUNC;
// Return the file descriptor and increment it.
return fd;