~sircmpwn/hare unlisted

bc6041a4fbc18f4cc66670109732941c948be1db — Umar Getagazov 2 months ago 4e72da5
unix: add umask wrapper for Linux

Signed-off-by: Umar Getagazov <umar@handlerug.me>
4 files changed, 19 insertions(+), 3 deletions(-)

M scripts/gen-stdlib
M stdlib.mk
R unix/{nice+linux.ha => +linux/nice.ha}
A unix/+linux/umask.ha
M scripts/gen-stdlib => scripts/gen-stdlib +2 -1
@@ 770,7 770,8 @@ unicode() {
unix() {
	# XXX: getuid and setuid are probably platform-specific too
	gen_srcs unix \
		nice'$(PLATFORM)'.ha \
		'$(PLATFORM)/nice.ha' \
		'$(PLATFORM)/umask.ha' \
		getuid.ha \
		setuid.ha
	gen_ssa unix errors

M stdlib.mk => stdlib.mk +4 -2
@@ 1099,7 1099,8 @@ $(HARECACHE)/unicode/unicode.ssa: $(stdlib_unicode_srcs) $(stdlib_rt)

# unix
stdlib_unix_srcs= \
	$(STDLIB)/unix/nice$(PLATFORM).ha \
	$(STDLIB)/unix/$(PLATFORM)/nice.ha \
	$(STDLIB)/unix/$(PLATFORM)/umask.ha \
	$(STDLIB)/unix/getuid.ha \
	$(STDLIB)/unix/setuid.ha



@@ 2290,7 2291,8 @@ $(TESTCACHE)/unicode/unicode.ssa: $(testlib_unicode_srcs) $(testlib_rt)

# unix
testlib_unix_srcs= \
	$(STDLIB)/unix/nice$(PLATFORM).ha \
	$(STDLIB)/unix/$(PLATFORM)/nice.ha \
	$(STDLIB)/unix/$(PLATFORM)/umask.ha \
	$(STDLIB)/unix/getuid.ha \
	$(STDLIB)/unix/setuid.ha


R unix/nice+linux.ha => unix/+linux/nice.ha +0 -0
A unix/+linux/umask.ha => unix/+linux/umask.ha +13 -0
@@ 0,0 1,13 @@
use errors;
use fs;
use rt;

// Sets the file mode creation mask for the current process and return the
// previous value of the mask. Only the file permission bits are used.
export fn umask(mode: fs::mode) (fs::mode | errors::error) = {
	mode &= 0o777;
	return match (rt::umask(mode)) {
		mode: rt::mode_t => mode: fs::mode,
		err: rt::errno => errors::errno(err),
	};
};