From 005c6af302054df425f515520acf9dc094edbd38 Mon Sep 17 00:00:00 2001 From: Justas Dabrila Date: Mon, 23 Dec 2019 16:34:20 +0200 Subject: [PATCH 1/2] Fix improper _unix_open binding that was ignoring the mode arg --- core/os/os_linux.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/os/os_linux.odin b/core/os/os_linux.odin index cf03dac71..0f244c526 100644 --- a/core/os/os_linux.odin +++ b/core/os/os_linux.odin @@ -259,7 +259,7 @@ foreign libc { @(link_name="__errno_location") __errno_location :: proc() -> ^int ---; @(link_name="syscall") syscall :: proc(number: Syscall, #c_vararg args: ..any) -> int ---; - @(link_name="open") _unix_open :: proc(path: cstring, flags: int, #c_vararg mode: ..any) -> Handle ---; + @(link_name="open") _unix_open :: proc(path: cstring, flags: int, mode: int) -> Handle ---; @(link_name="close") _unix_close :: proc(fd: Handle) -> int ---; @(link_name="read") _unix_read :: proc(fd: Handle, buf: rawptr, size: int) -> int ---; @(link_name="write") _unix_write :: proc(fd: Handle, buf: rawptr, size: int) -> int ---; From 38a9a2b7fc0b0430b7a664719d4ce2e6bf836256 Mon Sep 17 00:00:00 2001 From: Justas Dabrila Date: Mon, 23 Dec 2019 16:35:10 +0200 Subject: [PATCH 2/2] Linux: write_entire_file sets 644 permissions on open. --- core/os/os.odin | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/os/os.odin b/core/os/os.odin index d5ac23b62..11cc59a8f 100644 --- a/core/os/os.odin +++ b/core/os/os.odin @@ -99,7 +99,14 @@ write_entire_file :: proc(name: string, data: []byte, truncate := true) -> (succ if truncate { flags |= O_TRUNC; } - fd, err := open(name, flags, 0); + + mode: int = 0; + when OS == "linux" { + // NOTE(justasd): 644 (owner read, write; group read; others read) + mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; + } + + fd, err := open(name, flags, mode); if err != 0 { return false; }