aboutsummaryrefslogtreecommitdiff
path: root/core/sys/linux/sys.odin
diff options
context:
space:
mode:
authorA1029384756 <hayden.gray104@gmail.com>2024-11-12 23:53:52 -0500
committerA1029384756 <hayden.gray104@gmail.com>2024-11-13 00:05:58 -0500
commitbb2033898781affb1dbca2cb9e8635e1db237c4f (patch)
tree41e895e80209091c555db4e5b292601e293bb70c /core/sys/linux/sys.odin
parent91bd5d44187cc8ad48452db665acf7eb8a5cb19b (diff)
core:sys/linux - implemented inotify
core:sys/linux - added constants and spacing
Diffstat (limited to 'core/sys/linux/sys.odin')
-rw-r--r--core/sys/linux/sys.odin26
1 files changed, 23 insertions, 3 deletions
diff --git a/core/sys/linux/sys.odin b/core/sys/linux/sys.odin
index c5894d78b..819edc4a5 100644
--- a/core/sys/linux/sys.odin
+++ b/core/sys/linux/sys.odin
@@ -2536,11 +2536,31 @@ waitid :: proc "contextless" (id_type: Id_Type, id: Id, sig_info: ^Sig_Info, opt
// TODO(flysand): ioprio_get
-// TODO(flysand): inotify_init
+inotify_init :: proc "contextless" () -> (Fd, Errno) {
+ ret := syscall(SYS_inotify_init)
+ return errno_unwrap(ret, Fd)
+}
+
+inotify_init1 :: proc "contextless" (flags: Inotify_Init_Flags) -> (Fd, Errno) {
+ ret := syscall(SYS_inotify_init1, transmute(i32)flags)
+ return errno_unwrap(ret, Fd)
+}
-// TODO(flysand): inotify_add_watch
+inotify_add_watch :: proc "contextless" (fd: Fd, pathname: cstring, mask: Inotify_Event_Mask) -> (Wd, Errno) {
+ ret := syscall(SYS_inotify_add_watch, fd, transmute(uintptr) pathname, transmute(u32) mask)
+ return errno_unwrap(ret, Wd)
+}
-// TODO(flysand): inotify_rm_watch
+inotify_rm_watch :: proc "contextless" (fd: Fd, wd: Wd) -> (Errno) {
+ ret := syscall(SYS_inotify_rm_watch, fd, wd)
+ return Errno(-ret)
+}
+
+// helper procedure to access the data within an `Inotify_Event`
+// since Odin doesn't have an alternative to `__flexarr`
+inotify_event_name :: proc "contextless" (event: ^Inotify_Event) -> cstring {
+ return transmute(cstring)&event.name
+}
// TODO(flysand): migrate_pages