feat(kernel/syscalls): add fcntl() syscall

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
EnderIce2 2025-03-21 01:58:14 +00:00
parent b05a6a14e8
commit 2080d1f2b7
No known key found for this signature in database
GPG Key ID: 2EE20AF089811A5A
2 changed files with 24 additions and 0 deletions

View File

@ -830,6 +830,25 @@ typedef enum
* - #EINVAL if the request is invalid * - #EINVAL if the request is invalid
*/ */
SYS_IOCTL, SYS_IOCTL,
/**
* @brief Function control
*
* @code
* int fcntl(int fd, int cmd, void *arg);
* @endcode
*
* @details Manipulates the underlying parameters of a device.
*
* @param fd File descriptor referring to the device
* @param cmd Device-specific request code
* @param arg Argument for the request
*
* @return
* - #EOK on success
* - #EBADF if `fd` is not valid
* - #EINVAL if the request is invalid
*/
SYS_FCNTL,
/* File Status */ /* File Status */
@ -1678,6 +1697,9 @@ typedef enum
/** @copydoc SYS_IOCTL */ /** @copydoc SYS_IOCTL */
#define call_ioctl(fd, request, argp) syscall3(SYS_IOCTL, (scarg)fd, (scarg)request, (scarg)argp) #define call_ioctl(fd, request, argp) syscall3(SYS_IOCTL, (scarg)fd, (scarg)request, (scarg)argp)
/** @copydoc SYS_FCNTL */
#define call_fcntl(fd, cmd, arg) syscall3(SYS_FCNTL, (scarg)fd, (scarg)cmd, (scarg)arg)
/* File Status */ /* File Status */
/** @copydoc SYS_STAT */ /** @copydoc SYS_STAT */

View File

@ -135,6 +135,7 @@ static int sys_close(SysFrm *Frame, int fd)
} }
static int sys_ioctl(SysFrm *Frame, int fd, unsigned long request, void *argp) { return -ENOSYS; } static int sys_ioctl(SysFrm *Frame, int fd, unsigned long request, void *argp) { return -ENOSYS; }
static int sys_fcntl(SysFrm *Frame, int fd, int cmd, void *arg) { return -ENOSYS; }
static int sys_stat(SysFrm *Frame, const char *pathname, struct stat *statbuf) { return -ENOSYS; } static int sys_stat(SysFrm *Frame, const char *pathname, struct stat *statbuf) { return -ENOSYS; }
static int sys_fstat(SysFrm *Frame, int fd, struct stat *statbuf) { return -ENOSYS; } static int sys_fstat(SysFrm *Frame, int fd, struct stat *statbuf) { return -ENOSYS; }
static int sys_lstat(SysFrm *Frame, const char *pathname, struct stat *statbuf) { return -ENOSYS; } static int sys_lstat(SysFrm *Frame, const char *pathname, struct stat *statbuf) { return -ENOSYS; }
@ -275,6 +276,7 @@ __constructor void __init_native_syscalls(void)
scTbl[SYS_OPEN] = {"SYS_OPEN", (void *)sys_open}; scTbl[SYS_OPEN] = {"SYS_OPEN", (void *)sys_open};
scTbl[SYS_CLOSE] = {"SYS_CLOSE", (void *)sys_close}; scTbl[SYS_CLOSE] = {"SYS_CLOSE", (void *)sys_close};
scTbl[SYS_IOCTL] = {"SYS_IOCTL", (void *)sys_ioctl}; scTbl[SYS_IOCTL] = {"SYS_IOCTL", (void *)sys_ioctl};
scTbl[SYS_FCNTL] = {"SYS_FCNTL", (void *)sys_fcntl};
/* File Status */ /* File Status */
scTbl[SYS_STAT] = {"SYS_STAT", (void *)sys_stat}; scTbl[SYS_STAT] = {"SYS_STAT", (void *)sys_stat};