diff --git a/core/sys/linux/bits.odin b/core/sys/linux/bits.odin index b22a021f6..f9dcb45d5 100644 --- a/core/sys/linux/bits.odin +++ b/core/sys/linux/bits.odin @@ -524,7 +524,7 @@ Inotify_Init_Bits :: enum { IN_CLOEXEC = 19, } -Inotify_Events_Bits :: enum u32 { +Inotify_Event_Bits :: enum u32 { IN_ACCESS = 0, IN_MODIFY = 1, IN_ATTRIB = 2, @@ -539,6 +539,16 @@ Inotify_Events_Bits :: enum u32 { IN_DELETE = 9, IN_DELETE_SELF = 10, IN_MOVE_SELF = 11, + IN_UNMOUNT = 13, + IN_Q_OVERFLOW = 14, + IN_IGNORED = 15, + IN_ONLYDIR = 24, + IN_DONT_FOLLOW = 25, + IN_EXCL_UNLINK = 26, + IN_MASK_CREATE = 28, + IN_MASK_ADD = 29, + IN_ISDIR = 30, + IN_ONESHOT = 31, } /* diff --git a/core/sys/linux/constants.odin b/core/sys/linux/constants.odin index 551a4fc40..e568ff2f2 100644 --- a/core/sys/linux/constants.odin +++ b/core/sys/linux/constants.odin @@ -135,13 +135,20 @@ STATX_BASIC_STATS :: Statx_Mask { .BLOCKS, } -IN_ONLYDIR :: 0x01000000 -IN_DONT_FOLLOW :: 0x02000000 -IN_EXCL_UNLINK :: 0x04000000 -IN_MASK_CREATE :: 0x10000000 -IN_MASK_ADD :: 0x20000000 -IN_ISDIR :: 0x40000000 -IN_ONESHOT :: 0x80000000 +IN_ALL_EVENTS :: Inotify_Event_Mask { + .IN_ACCESS, + .IN_MODIFY, + .IN_ATTRIB, + .IN_CLOSE_WRITE, + .IN_CLOSE_NOWRITE, + .IN_OPEN, + .IN_MOVED_FROM, + .IN_MOVED_TO, + .IN_CREATE, + .IN_DELETE, + .IN_DELETE_SELF, + .IN_MOVE_SELF, +} /* Tell `shmget` to create a new key diff --git a/core/sys/linux/sys.odin b/core/sys/linux/sys.odin index 9adeda610..690902f07 100644 --- a/core/sys/linux/sys.odin +++ b/core/sys/linux/sys.odin @@ -2537,8 +2537,13 @@ waitid :: proc "contextless" (id_type: Id_Type, id: Id, sig_info: ^Sig_Info, opt // TODO(flysand): ioprio_get inotify_init :: proc "contextless" () -> (Fd, Errno) { - ret := syscall(SYS_inotify_init) - return errno_unwrap(ret, Fd) + when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 { + ret := syscall(SYS_inotify_init1, 0) + return errno_unwrap(ret, Fd) + } else { + ret := syscall(SYS_inotify_init) + return errno_unwrap(ret, Fd) + } } inotify_init1 :: proc "contextless" (flags: Inotify_Init_Flags) -> (Fd, Errno) { @@ -2556,12 +2561,6 @@ inotify_rm_watch :: proc "contextless" (fd: Fd, wd: Wd) -> (Errno) { 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)uintptr(&event.name) -} - // TODO(flysand): migrate_pages /* diff --git a/core/sys/linux/types.odin b/core/sys/linux/types.odin index 97e593935..42d5cc988 100644 --- a/core/sys/linux/types.odin +++ b/core/sys/linux/types.odin @@ -351,16 +351,14 @@ Poll_Fd :: struct { Inotify_Init_Flags :: bit_set[Inotify_Init_Bits; i32] Inotify_Event :: struct { - wd: Wd, - mask: Inotify_Event_Mask, + wd: Wd, + mask: Inotify_Event_Mask, cookie: u32, - len: u32, - // used in place of __flexarr - // use inotify_event_name to read - name: [0]u8, + len: u32, + name: [0]u8, } -Inotify_Event_Mask :: bit_set[Inotify_Events_Bits; u32] +Inotify_Event_Mask :: bit_set[Inotify_Event_Bits; u32] /* Specifies protection for memory pages.