Scroll to navigation

PREROOT(3) Library Functions Manual PREROOT(3)

NAME

preroot - preroot support

SYNOPSIS

#include <preroot.h>
char*    getpreroot(char* path, char* cmd);
int      ispreroot(char* dir);
int      realopen(char* path, int mode, int perm);
void     setpreroot(char** argv, char* dir);

DESCRIPTION

The preroot routines manipulate the process preroot. preroot is a kernel supported per-process two level viewpath. All pathnames rooted at / are first searched for in the process preroot directory and then in the system root directory. Setting the process preroot is a priveleged operation controlled by the /etc/preroot(1) command.

<preroot.h> defines the symbol FS_PREROOT for those systems that support preroot. The following routines are valid only when FS_PREROOT is defined:

getpreroot
returns a pointer to the absolute pathname of the preroot directory for the executable cmd. The result is placed in path. If path is 0 then malloc(3) is used to allocate the pathname space. 0 is returned if cmd has no preroot or if an error was encountered. In this case errno is set to indicate the error.
ispreroot
Non-zero is returned if dir is the current process preroot. If dir is 0 then non-zero is returned if the current process has a preroot.
realopen
temporarily disables the process preroot and does an open(3) relative to the system root directory. The return value from open is returned. If there is no preroot then realopen is equivalent to open.
setpreroot
calls execvp(3) as execvp(argv[0],argv) with the process preroot set to dir. argv must be a 0-terminated argument array. If argv is 0 then the value of opt_argv from optget(3) is used. setpreroot returns immediately if dir is already the process preroot.

SEE ALSO

/etc/preroot(1)

BUGS

Preroot semantics should be preserved when reading directories. The ast directory(3) routines do this. 3d(1) viewpathing does preroot the right way.