core:sys/linux - flags, spacing, inotify_init

This commit is contained in:
A1029384756
2024-11-13 08:52:33 -05:00
committed by flysand7
parent f6b0ea160b
commit 59adcf6c46
4 changed files with 37 additions and 23 deletions

View File

@@ -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,
}
/*

View File

@@ -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

View File

@@ -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
/*

View File

@@ -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.