commit 9152cf6099b68bb2c3786a076bc6e16bc4423ea3
parent 5b6e7a1ad54a68b09afb68e1be099a46052ef5a7
Author: Umar Getagazov <umar@handlerug.me>
Date: Sun, 11 Jul 2021 03:32:05 +0700
fs, unix::umask: don't clear file mode bits
Signed-off-by: Umar Getagazov <umar@handlerug.me>
Diffstat:
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/fs/fs.ha b/fs/fs.ha
@@ -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,
diff --git a/unix/+linux/umask.ha b/unix/+linux/umask.ha
@@ -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),