MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / SysSetFileStatusFlags

Function SysSetFileStatusFlags

Kernel/src/arch/x86_64/syscalls.cpp:2062–2077  ·  view source on GitHub ↗

//////////////////////// \brief SysSetFileStatusFlags(fd, flags) Set a file handle's mode/status flags \param fd (int) file descriptor \param flags (int) new status flags \return 0 on success, negative error code on failure ////////////////////////

Source from the content-addressed store, hash-verified

2060/// \return 0 on success, negative error code on failure
2061/////////////////////////////
2062long SysSetFileStatusFlags(regs64_t* r){
2063 int fd = static_cast<int>(SC_ARG0(r));
2064 int nFlags = static_cast<int>(SC_ARG1(r));
2065 fs_fd_t* handle;
2066
2067 process_t* currentProcess = Scheduler::GetCurrentProcess();
2068 if(static_cast<unsigned>(fd) > currentProcess->fileDescriptors.get_length() || !(handle = currentProcess->fileDescriptors[fd])){
2069 return -EBADF;
2070 }
2071
2072 int mask = (O_APPEND | O_NONBLOCK); // Only update append or nonblock
2073
2074 handle->mode = (handle->mode & ~mask) | (nFlags & mask);
2075
2076 return 0;
2077}
2078
2079/////////////////////////////
2080/// \brief SysSelect(nfds, readfds, writefds, exceptfds, timeout) Set a file handle's mode/status flags

Callers

nothing calls this directly

Calls 2

GetCurrentProcessFunction · 0.85
get_lengthMethod · 0.45

Tested by

no test coverage detected