9.18 pivot_root

int pivot_root(char *new_root, size_t new_len, char *old_root, size_t old_len);

This syscall pivots the root FS of the system into a new root mountpoint mounted at new_root. old_root will be where the root mountpoint will be moved to. The current working directory is not changed in any way. And this change is system-wide, there is no mount namespace manipulation, unlike Linux.

old_root can not exist inside the old root, and only exist inside new_root.

This syscall returns 0 on success or -1 on failure, with the errno:

EFAULT

One of the buffers (or both) point to invalid memory.

EINVAL

The values passed do not point to actual mountpoints, or point to the same mountpoint.

EACCES

The caller process does not have the MAC_CAP_SYS_MNT capability.