aboutsummaryrefslogtreecommitdiff
path: root/core/sys/linux
diff options
context:
space:
mode:
authormarcs-feh <marcosfehlauer@protonmail.com>2024-01-22 16:09:44 -0300
committermarcs-feh <marcosfehlauer@protonmail.com>2024-01-22 16:09:44 -0300
commit7b1f58a06a863542e8ee8b7702c8ae7c4c0714b3 (patch)
tree60e59a152d1ec374eb4027e91264abceca7bedbc /core/sys/linux
parent98b539ac5c64004c1bd1d3f8fed5e59028b12739 (diff)
sys/linux: Add binding to ioctl syscall + fd consts
Add binding to ioctl syscall, due to the vast nature of this syscall adding more device specific request values is possible. Also added the stdin, stdout and stderr, to constants.odin
Diffstat (limited to 'core/sys/linux')
-rw-r--r--core/sys/linux/constants.odin15
-rw-r--r--core/sys/linux/sys.odin12
2 files changed, 26 insertions, 1 deletions
diff --git a/core/sys/linux/constants.odin b/core/sys/linux/constants.odin
index 6294602e9..ecd630fa9 100644
--- a/core/sys/linux/constants.odin
+++ b/core/sys/linux/constants.odin
@@ -2,6 +2,21 @@
package linux
/*
+ Standard input file descriptor
+*/
+STDIN_FILENO :: Fd(0)
+
+/*
+ Standard output file descriptor
+*/
+STDOUT_FILENO :: Fd(1)
+
+/*
+ Standard output 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 9a0f18e9f..7bec8eee2 100644
--- a/core/sys/linux/sys.odin
+++ b/core/sys/linux/sys.odin
@@ -216,7 +216,17 @@ 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.
+ Available since Linux 1.0.
+*/
+ioctl :: proc "contextless" (fd: Fd, request: u64, arg: u64) -> (Errno) {
+ ret := syscall(SYS_ioctl, fd, request, arg)
+ return Errno(-ret)
+}
/*
Read the file at a specified offset.