hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 745f516ebe243f77c482adca582f744d47eadcbb
parent 519f2f5303984a58d487b0a22e70f477efa5f2ab
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 14 Mar 2021 11:46:58 -0400

os: fix RDONLY/WRONLY open flags

Diffstat:
Mfs/types.ha | 2++
Mos/+linux/dirfdfs.ha | 18++++++++++--------
2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/fs/types.ha b/fs/types.ha @@ -154,7 +154,9 @@ export type flags = enum int { RSYNC = 0o4010000, DIRECTORY = 0o200000, NOFOLLOW = 0o400000, + NOATIME = 0o1000000, CLOEXEC = 0o2000000, + PATH = 0o10000000, TMPFILE = 0o20200000, }; diff --git a/os/+linux/dirfdfs.ha b/os/+linux/dirfdfs.ha @@ -6,6 +6,8 @@ use path; use rt; use strings; +use strconv; + // Controls how symlinks are followed (or not) in a dirfd filesystem. Support // for this feature varies, you should gate usage of this enum behind a build // tag. @@ -146,12 +148,12 @@ fn fs_open( oflags |= flags[i]: int; }; - if (oflags: fs::flags & fs::flags::RDWR == fs::flags::RDWR) { + if ((oflags: fs::flags & fs::flags::RDWR) == fs::flags::RDWR) { iomode = io::mode::RDWR; - } else if (oflags: fs::flags & fs::flags::RDONLY == fs::flags::RDONLY) { - iomode = io::mode::READ; - } else if (oflags: fs::flags & fs::flags::RDONLY == fs::flags::RDONLY) { + } else if ((oflags: fs::flags & fs::flags::WRONLY) == fs::flags::WRONLY) { iomode = io::mode::WRITE; + } else if ((oflags: fs::flags & fs::flags::PATH) != fs::flags::PATH) { + iomode = io::mode::READ; }; let oh = rt::open_how { @@ -179,12 +181,12 @@ fn fs_create( }; oflags |= fs::flags::CREATE: int; - if (oflags: fs::flags & fs::flags::RDWR == fs::flags::RDWR) { + if ((oflags: fs::flags & fs::flags::RDWR) == fs::flags::RDWR) { iomode = io::mode::RDWR; - } else if (oflags: fs::flags & fs::flags::RDONLY == fs::flags::RDONLY) { - iomode = io::mode::READ; - } else if (oflags: fs::flags & fs::flags::RDONLY == fs::flags::RDONLY) { + } else if ((oflags: fs::flags & fs::flags::WRONLY) == fs::flags::WRONLY) { iomode = io::mode::WRITE; + } else if ((oflags: fs::flags & fs::flags::PATH) != fs::flags::PATH) { + iomode = io::mode::READ; }; let oh = rt::open_how {