Minor fixes + cleanup in os2 and sys/linux

Add NOFOLLOW to os2.remove
Change Dev from int to u64 and make relavant casts
Fix compat64_arg_pair
This commit is contained in:
jason
2025-01-02 11:03:24 -05:00
parent fdd3b46c10
commit ce1f3b34c0
5 changed files with 7 additions and 8 deletions
+1 -1
View File
@@ -275,7 +275,7 @@ _remove :: proc(name: string) -> Error {
TEMP_ALLOCATOR_GUARD() TEMP_ALLOCATOR_GUARD()
name_cstr := temp_cstring(name) or_return name_cstr := temp_cstring(name) or_return
if fd, errno := linux.open(name_cstr, _OPENDIR_FLAGS); errno == .NONE { if fd, errno := linux.open(name_cstr, _OPENDIR_FLAGS + {.NOFOLLOW}); errno == .NONE {
linux.close(fd) linux.close(fd)
return _get_platform_error(linux.rmdir(name_cstr)) return _get_platform_error(linux.rmdir(name_cstr))
} }
-2
View File
@@ -77,8 +77,6 @@ _mkdir_all :: proc(path: string, perm: int) -> Error {
} }
_remove_all :: proc(path: string) -> Error { _remove_all :: proc(path: string) -> Error {
DT_DIR :: 4
remove_all_dir :: proc(dfd: linux.Fd) -> Error { remove_all_dir :: proc(dfd: linux.Fd) -> Error {
n := 64 n := 64
buf := make([]u8, n) buf := make([]u8, n)
+1 -1
View File
@@ -139,7 +139,7 @@ when size_of(int) == 4 {
// xxx64 system calls take some parameters as pairs of ulongs rather than a single pointer // xxx64 system calls take some parameters as pairs of ulongs rather than a single pointer
@(private) @(private)
compat64_arg_pair :: #force_inline proc "contextless" (a: i64) -> (hi: uint, lo: uint) { compat64_arg_pair :: #force_inline proc "contextless" (a: i64) -> (hi: uint, lo: uint) {
no_sign := uint(a) no_sign := u64(a)
hi = uint(no_sign >> 32) hi = uint(no_sign >> 32)
lo = uint(no_sign & 0xffff_ffff) lo = uint(no_sign & 0xffff_ffff)
return return
+3 -3
View File
@@ -1952,10 +1952,10 @@ sigaltstack :: proc "contextless" (stack: ^Sig_Stack, old_stack: ^Sig_Stack) ->
*/ */
mknod :: proc "contextless" (name: cstring, mode: Mode, dev: Dev) -> (Errno) { mknod :: proc "contextless" (name: cstring, mode: Mode, dev: Dev) -> (Errno) {
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 { when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
ret := syscall(SYS_mknodat, AT_FDCWD, cast(rawptr) name, transmute(u32) mode, dev) ret := syscall(SYS_mknodat, AT_FDCWD, cast(rawptr) name, transmute(u32) mode, cast(uint) dev)
return Errno(-ret) return Errno(-ret)
} else { } else {
ret := syscall(SYS_mknod, cast(rawptr) name, transmute(u32) mode, dev) ret := syscall(SYS_mknod, cast(rawptr) name, transmute(u32) mode, cast(uint) dev)
return Errno(-ret) return Errno(-ret)
} }
} }
@@ -2586,7 +2586,7 @@ mkdirat :: proc "contextless" (dirfd: Fd, name: cstring, mode: Mode) -> (Errno)
Available since Linux 2.6.16. Available since Linux 2.6.16.
*/ */
mknodat :: proc "contextless" (dirfd: Fd, name: cstring, mode: Mode, dev: Dev) -> (Errno) { mknodat :: proc "contextless" (dirfd: Fd, name: cstring, mode: Mode, dev: Dev) -> (Errno) {
ret := syscall(SYS_mknodat, dirfd, cast(rawptr) name, transmute(u32) mode, dev) ret := syscall(SYS_mknodat, dirfd, cast(rawptr) name, transmute(u32) mode, cast(uint) dev)
return Errno(-ret) return Errno(-ret)
} }
+2 -1
View File
@@ -3,7 +3,7 @@ package linux
/* /*
Type for storage device handle. Type for storage device handle.
*/ */
Dev :: distinct int Dev :: distinct u64
/* /*
Type for 32-bit User IDs. Type for 32-bit User IDs.
@@ -153,6 +153,7 @@ when ODIN_ARCH == .amd64 {
uid: Uid, uid: Uid,
gid: Gid, gid: Gid,
rdev: Dev, rdev: Dev,
_: [4]u8,
size: i64, size: i64,
blksize: uint, blksize: uint,
blocks: u64, blocks: u64,