package linux

import "github.com/cyphar/filepath-securejoin/pathrs-lite/internal/linux"

Package linux returns information about what features are supported on the running kernel.

Index

Variables

var HasNewMountAPI = gocompat.SyncOnceValue(func() bool {

	fd, err := unix.OpenTree(-int(unix.EBADF), "/", unix.OPEN_TREE_CLOEXEC)
	if err != nil {
		return false
	}
	_ = unix.Close(fd)

	isNotBackport, _ := kernelversion.GreaterEqualThan(kernelversion.KernelVersion{5, 2})
	return isNotBackport
})

HasNewMountAPI returns whether the new fsopen(2) mount API is supported on the running kernel.

var HasOpenat2 = func() bool {
	if sawOpenat2Error.Load() {
		return false
	}

	fd, err := unix.Openat2(unix.AT_FDCWD, ".", &unix.OpenHow{
		Flags:   unix.O_PATH | unix.O_CLOEXEC,
		Resolve: unix.RESOLVE_NO_SYMLINKS | unix.RESOLVE_IN_ROOT,
	})
	if err != nil {
		sawOpenat2Error.Store(true)
		return false
	}
	_ = unix.Close(fd)
	return true
}

HasOpenat2 returns whether openat2(2) is supported on the running kernel.

Source Files

doc.go mount_linux.go openat2_linux.go

Version
v0.6.1 (latest)
Published
Nov 19, 2025
Platform
linux/amd64
Imports
3 packages
Last checked
21 minutes ago

Tools for package owners.