From bb2033898781affb1dbca2cb9e8635e1db237c4f Mon Sep 17 00:00:00 2001 From: A1029384756 Date: Tue, 12 Nov 2024 23:53:52 -0500 Subject: core:sys/linux - implemented inotify core:sys/linux - added constants and spacing --- core/sys/linux/sys.odin | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'core/sys/linux/sys.odin') 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 -- cgit v1.2.3