commit 3bb391b7fd0cd073f9fdd1858a58a6254938a911
parent a46ffebb5194b4547ef400008f1ebe00c7fe3730
Author: Lorenz (xha) <me@xha.li>
Date: Wed, 27 Dec 2023 05:38:03 +0100
*BSD: fsflags_to_bsd return unsupported instead of abort()
Signed-off-by: Lorenz (xha) <me@xha.li>
Diffstat:
2 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/os/+freebsd/dirfdfs.ha b/os/+freebsd/dirfdfs.ha
@@ -108,7 +108,7 @@ fn _fs_open(
return io::fdopen(fd);
};
-fn fsflags_to_bsd(flags: fs::flag) int = {
+fn fsflags_to_bsd(flags: fs::flag) (int | errors::unsupported) = {
let out = rt::O_NOCTTY | rt::O_CLOEXEC;
if (flags & fs::flag::WRONLY > 0) {
out |= rt::O_WRONLY;
@@ -152,14 +152,10 @@ fn fsflags_to_bsd(flags: fs::flag) int = {
if (flags & fs::flag::NOCLOEXEC > 0) {
out &= ~rt::O_CLOEXEC;
};
- if (flags & fs::flag::PATH > 0) {
- abort("fs::flag::PATH is not supported on FreeBSD");
- };
- if (flags & fs::flag::NOATIME > 0) {
- abort("fs::flag::NOATIME is not supported on FreeBSD");
- };
- if (flags & fs::flag::TMPFILE > 0) {
- abort("fs::flag::TMPFILE is not supported on FreeBSD");
+ if (flags & fs::flag::PATH > 0
+ || flags & fs::flag::NOATIME > 0
+ || flags & fs::flag::TMPFILE > 0) {
+ return errors::unsupported;
};
return out;
};
@@ -173,7 +169,7 @@ fn fs_open_file(
for (let i = 0z; i < len(flags); i += 1z) {
oflags |= flags[i];
};
- return _fs_open(fs, path, fsflags_to_bsd(oflags), 0);
+ return _fs_open(fs, path, fsflags_to_bsd(oflags)?, 0);
};
fn fs_open(
@@ -196,7 +192,7 @@ fn fs_create_file(
oflags |= flags[i];
};
oflags |= fs::flag::CREATE;
- return _fs_open(fs, path, fsflags_to_bsd(oflags), mode)?;
+ return _fs_open(fs, path, fsflags_to_bsd(oflags)?, mode)?;
};
fn fs_create(
diff --git a/os/+openbsd/dirfdfs.ha b/os/+openbsd/dirfdfs.ha
@@ -17,7 +17,7 @@ type os_filesystem = struct {
getdents_bufsz: size,
};
-fn fsflags_to_bsd(flags: fs::flag) int = {
+fn fsflags_to_bsd(flags: fs::flag) (int | errors::unsupported) = {
let out = rt::O_CLOEXEC;
if (flags & fs::flag::RDONLY > 0) {
out |= rt::O_RDONLY;
@@ -57,17 +57,11 @@ fn fsflags_to_bsd(flags: fs::flag) int = {
if (flags & fs::flag::NOCLOEXEC > 0) {
out &= ~rt::O_CLOEXEC;
};
- if (flags & fs::flag::PATH > 0) {
- abort("fs::flag::PATH is not supported on OpenBSD");
- };
- if (flags & fs::flag::NOATIME > 0) {
- abort("fs::flag::NOATIME > 0 is not supported on OpenBSD");
- };
- if (flags & fs::flag::TMPFILE > 0) {
- abort("fs::flag::TMPFILE is not supported on OpenBSD");
- };
- if (flags & fs::flag::CTTY > 0) {
- abort("fs::flag::CTTY is not supported on OpenBSD");
+ if (flags & fs::flag::PATH > 0
+ || flags & fs::flag::NOATIME > 0
+ || flags & fs::flag::TMPFILE > 0
+ || flags & fs::flag::CTTY > 0) {
+ return errors::unsupported;
};
return out;
};
@@ -99,7 +93,7 @@ fn fs_open_file(
for (let i = 0z; i < len(flags); i += 1z) {
oflags |= flags[i];
};
- return _fs_open(fs, path, fsflags_to_bsd(oflags), 0);
+ return _fs_open(fs, path, fsflags_to_bsd(oflags)?, 0);
};
fn fs_open(
@@ -139,7 +133,7 @@ fn fs_create_file(
oflags |= flags[i];
};
oflags |= fs::flag::CREATE;
- return _fs_open(fs, path, fsflags_to_bsd(oflags), mode)?;
+ return _fs_open(fs, path, fsflags_to_bsd(oflags)?, mode)?;
};
fn fs_create(