~sircmpwn/hare unlisted

9152cf6099b68bb2c3786a076bc6e16bc4423ea3 — Umar Getagazov 2 months ago 5b6e7a1
fs, unix::umask: don't clear file mode bits

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

M fs/fs.ha
M unix/+linux/umask.ha
M fs/fs.ha => fs/fs.ha +1 -6
@@ 21,16 21,12 @@ export fn open(fs: *fs, path: str, flags: flags...) (*io::stream | error) = {

// Creates a new file and opens it for writing. If no flags are provided, the
// default read/write mode is WRONLY.
//
// Only the permission bits of the mode are used. If other bits are set, they
// are discarded.
export fn create(
	fs: *fs,
	path: str,
	mode: mode,
	flags: flags...
) (*io::stream | error) = {
	mode &= 0o777;
	return match (fs.create) {
		null => errors::unsupported,
		f: *createfunc => f(fs, path, mode, flags...),


@@ 177,9 173,8 @@ export fn mksubdir(fs: *fs, path: str) (*fs | error) = {
	};
};

// Changes mode flags on a file or directory. Type bits are discared.
// Changes mode flags on a file or directory.
export fn chmod(fs: *fs, path: str, mode: mode) (void | error) = {
	mode &= 0o777;
	return match (fs.chmod) {
		f: *chmodfunc => f(fs, path, mode),
		null => errors::unsupported,

M unix/+linux/umask.ha => unix/+linux/umask.ha +1 -2
@@ 3,9 3,8 @@ 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.
// previous value of the mask.
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),