Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
linux-namespaces.hh File Reference
#include <filesystem>

Go to the source code of this file.

Functions

void nix::tryEnterPrivateMountNamespace ()
void nix::remountReadOnlyWritable (const std::filesystem::path &path)
void nix::restoreMountNamespace ()
void nix::tryUnshareFilesystem ()
bool nix::userNamespacesSupported ()
bool nix::mountAndPidNamespacesSupported ()

Function Documentation

◆ remountReadOnlyWritable()

void nix::remountReadOnlyWritable ( const std::filesystem::path & path)

Remount path writable if its mount is read-only, leaving already-writable mounts untouched. This throws if we aren't in a private mount namespace, since remounting would leak into the host mount table.

◆ restoreMountNamespace()

void nix::restoreMountNamespace ( )

Restore the parent mount namespace saved when we entered a private one. Ignored if tryEnterPrivateMountNamespace() never succeeded.

◆ tryEnterPrivateMountNamespace()

void nix::tryEnterPrivateMountNamespace ( )

Save the parent mount namespace and enter a private one via unshare(CLONE_NEWNS).

◆ tryUnshareFilesystem()

void nix::tryUnshareFilesystem ( )

Cause this thread to try to not share any FS attributes with the main thread, because this causes setns() in restoreMountNamespace() to fail.

This is best effort – EPERM and ENOSYS failures are just ignored.