aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaytan <laytanlaats@hotmail.com>2024-08-13 15:30:50 +0200
committerGitHub <noreply@github.com>2024-08-13 15:30:50 +0200
commit55be3e60a06f0c7988d2f070816d7e7cc3aeee09 (patch)
treee99aa2a36b043293c58eec2747991edf049abe11
parent62911539cd8c3fc5372e0e65285b6db8fd704cd5 (diff)
parentc7af8af76a6c6173a410b6cde9f52ad22bcea707 (diff)
Merge pull request #3125 from marcs-feh/master
sys/linux: Add binding to ioctl syscall + standard fd constants.
-rw-r--r--core/sys/linux/constants.odin15
-rw-r--r--core/sys/linux/sys.odin13
2 files changed, 27 insertions, 1 deletions
diff --git a/core/sys/linux/constants.odin b/core/sys/linux/constants.odin
index f3e9f5ff9..129444d0f 100644
--- a/core/sys/linux/constants.odin
+++ b/core/sys/linux/constants.odin
@@ -1,6 +1,21 @@
package linux
/*
+ Standard input file descriptor
+*/
+STDIN_FILENO :: Fd(0)
+
+/*
+ Standard output file descriptor
+*/
+STDOUT_FILENO :: Fd(1)
+
+/*
+ Standard error file descriptor
+*/
+STDERR_FILENO :: Fd(2)
+
+/*
Special file descriptor to pass to `*at` functions to specify
that relative paths are relative to current directory.
*/
diff --git a/core/sys/linux/sys.odin b/core/sys/linux/sys.odin
index ec7357c48..d729ab330 100644
--- a/core/sys/linux/sys.odin
+++ b/core/sys/linux/sys.odin
@@ -232,7 +232,18 @@ rt_sigprocmask :: proc "contextless" (mask_kind: Sig_Mask_Kind, new_set: ^Sig_Se
return Errno(-ret)
}
-// TODO(flysand): ioctl
+/*
+ Control devices. The ioctl syscall is a bit special because
+ its argument is usually a pointer to some driver-specific structure.
+ The request value is device-specific. Consult your LibC implementation's
+ ioctls.h file to learn more. The returned value of ioctl *may* be an error
+ code value instead of a memory address depending on the request type.
+ Available since Linux 1.0.
+*/
+ioctl :: proc "contextless" (fd: Fd, request: u32, arg: uintptr) -> (uintptr) {
+ ret := syscall(SYS_ioctl, fd, request, arg)
+ return uintptr(ret)
+}
/*
Read the file at a specified offset.