Open matsievskiysv opened 2 years ago
Hi @matsievskiysv - sorry for the long delay, been having a lot of stuff IRL taking priority. I hope to get back to you in one of the following days!
Hi @matsievskiysv
According to the code in systemio.h
at line 80,
static constexpr int O_RDONLY = 0x00000000;
static constexpr int O_WRONLY = 0x00000001;
static constexpr int O_RDWR = 0x00000002;
which defines the value of the flags used by the open
syscall.
However, it cannot write data into the file correctly, if we only set O_WRONLY
when calling open
syscall.
Looking at the conditional statements at lines 408-409, it input fd
and 3
as parameter
if (!FileIOData::fdInUse(fd, O_WRONLY | O_RDWR))
and then checks for the existence of the "write" flag using fdInUse at line193
else if ((fileFlags[fd] & flag) == static_cast<unsigned>(flag))
it requires the flag to be 0x3
to be true. Therefore, setting it only to O_WRONLY
may result in a write failure.
Hi @mortbopet
Ideally, writing to a file should be allowed as long as it satisfies either O_WRONLY
or O_RDWR
. However, here it is specified that both conditions must be met for a write operation to proceed. I would like to inquire whether the author has any specific reason for this additional requirement.
might this be related to https://github.com/mortbopet/Ripes/issues/316 - and subsequently, solved in https://github.com/mortbopet/Ripes/pull/325?
Hello! I'm having trobble using
write
system call. The following program is supposed to open file, write a string to it and close file.open
system call creates file with 644 permissions butwrite
always fails. Call arguments appear to be in order. What could be the problem?