~sircmpwn/hare-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH hare] os+linux: Match resolve_flag values with OS flag values

Details
Message ID
<20240412202444.4960-1-yyp@disroot.org>
DKIM signature
pass
Download raw message
Patch: +7 -19
Signed-off-by: Alexey Yerin <yyp@disroot.org>
---

 os/+linux/dirfdfs.ha | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/os/+linux/dirfdfs.ha b/os/+linux/dirfdfs.ha
index b748b1ef..944a6cf9 100644
--- a/os/+linux/dirfdfs.ha
+++ b/os/+linux/dirfdfs.ha
@@ -17,27 +17,27 @@ use types::c;
//
// Note that on Linux, specifying BENEATH or IN_ROOT will also disable magic
// symlinks.
export type resolve_flag = enum {
	NORMAL,
export type resolve_flag = enum u64 {
	NORMAL = 0,

	// Does not allow symlink resolution to occur for any symlinks which
	// would refer to any anscestor of the fd directory. This disables all
	// absolute symlinks, and any call to open or create with an absolute
	// path.
	BENEATH,
	BENEATH = rt::RESOLVE_BENEATH | rt::RESOLVE_NO_MAGICLINKS,

	// Treat the directory fd as the root directory. This affects
	// open/create for absolute paths, as well as absolute path resolution
	// of symlinks. The effects are similar to chroot.
	IN_ROOT,
	IN_ROOT = rt::RESOLVE_IN_ROOT | rt::RESOLVE_NO_MAGICLINKS,

	// Disables symlink resolution entirely.
	NO_SYMLINKS,
	NO_SYMLINKS = rt::RESOLVE_NO_SYMLINKS,

	// Disallows traversal of mountpoints during path resolution. This is
	// not recommended for general use, as bind mounts are extensively used
	// on many systems.
	NO_XDEV,
	NO_XDEV = rt::RESOLVE_NO_XDEV,
};

type os_filesystem = struct {
@@ -148,19 +148,7 @@ fn _fs_open(
) (io::file | fs::error) = {
	let fs = fs: *os_filesystem;

	oh.resolve = 0u64;
	if (fs.resolve & resolve_flag::BENEATH == resolve_flag::BENEATH) {
		oh.resolve |= rt::RESOLVE_BENEATH | rt::RESOLVE_NO_MAGICLINKS;
	};
	if (fs.resolve & resolve_flag::IN_ROOT == resolve_flag::IN_ROOT) {
		oh.resolve |= rt::RESOLVE_IN_ROOT | rt::RESOLVE_NO_MAGICLINKS;
	};
	if (fs.resolve & resolve_flag::NO_SYMLINKS == resolve_flag::NO_SYMLINKS) {
		oh.resolve |= rt::RESOLVE_NO_SYMLINKS;
	};
	if (fs.resolve & resolve_flag::NO_XDEV == resolve_flag::NO_XDEV) {
		oh.resolve |= rt::RESOLVE_NO_XDEV;
	};
	oh.resolve = fs.resolve;

	let fd = match (rt::openat2(fs.dirfd, path, oh, size(rt::open_how))) {
	case let err: rt::errno =>
-- 
2.44.0

[hare/patches] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<D0IFCUCS8C6I.K3Z43RSR5ERY@fra01>
In-Reply-To
<20240412202444.4960-1-yyp@disroot.org> (view parent)
DKIM signature
missing
Download raw message
hare/patches: SUCCESS in 59s

[os+linux: Match resolve_flag values with OS flag values][0] from [Alexey Yerin][1]

[0]: https://lists.sr.ht/~sircmpwn/hare-dev/patches/50954
[1]: yyp@disroot.org

✓ #1194258 SUCCESS hare/patches/openbsd.yml https://builds.sr.ht/~sircmpwn/job/1194258
✓ #1194256 SUCCESS hare/patches/alpine.yml  https://builds.sr.ht/~sircmpwn/job/1194256
✓ #1194257 SUCCESS hare/patches/freebsd.yml https://builds.sr.ht/~sircmpwn/job/1194257
Details
Message ID
<D0JUXMHJCF90.2RFS3T6ZFHJY1@cmpwn.com>
In-Reply-To
<20240412202444.4960-1-yyp@disroot.org> (view parent)
DKIM signature
pass
Download raw message
Thanks!

To git@git.sr.ht:~sircmpwn/hare
   01f302a2..9a18b3d1  master -> master

FWIW I have a mind to really re-evaluate the shit out of the whole
filesystem interface for Hare at some point in the foreseeable future,
so this might end up being changed in the end.
Reply to thread Export thread (mbox)