core:sys/linux - implemented inotify

core:sys/linux - added constants and spacing
This commit is contained in:
A1029384756
2024-11-12 23:53:52 -05:00
parent 91bd5d4418
commit bb20338987
4 changed files with 72 additions and 3 deletions
+23 -3
View File
@@ -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)
}
// TODO(flysand): inotify_add_watch
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_rm_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)
}
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