aboutsummaryrefslogtreecommitdiff
path: root/core/sys/linux
diff options
context:
space:
mode:
authorA1029384756 <hayden.gray104@gmail.com>2024-11-13 08:52:33 -0500
committerA1029384756 <hayden.gray104@gmail.com>2024-11-13 08:52:33 -0500
commit1b313a4db055750a3760414ad4e8c82a749792df (patch)
treeddf90d9bb65452200af0ea3dccfd88db6e985edd /core/sys/linux
parent37441bd7306d8f7c5775ec84d0c8efb4d73a8fe4 (diff)
core:sys/linux - flags, spacing, inotify_init
Diffstat (limited to 'core/sys/linux')
-rw-r--r--core/sys/linux/bits.odin12
-rw-r--r--core/sys/linux/constants.odin21
-rw-r--r--core/sys/linux/sys.odin15
-rw-r--r--core/sys/linux/types.odin12
4 files changed, 37 insertions, 23 deletions
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.