1.fp 5 CW 2.de Af 3.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2 4.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9" 5.. 6.de aF 7.ie \\$3 .ft \\$1 8.el \{\ 9.ds ;G \& 10.nr ;G \\n(.f 11.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9" 12\\*(;G 13.ft \\n(;G \} 14.. 15.de L 16.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 17.. 18.de LR 19.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 20.. 21.de RL 22.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" 23.. 24.de EX \" start example 25.ta 1i 2i 3i 4i 5i 6i 26.PP 27.RS 28.PD 0 29.ft 5 30.nf 31.. 32.de EE \" end example 33.fi 34.ft 35.PD 36.RE 37.PP 38.. 39.TH PREROOT 3 40.SH NAME 41preroot \- preroot support 42.SH SYNOPSIS 43.EX 44#include <preroot.h> 45 46char* getpreroot(char* \fIpath\fP, char* \fIcmd\fP); 47int ispreroot(char* \fIdir\fP); 48int realopen(char* \fIpath\fP, int \fImode\fP, int \fIperm\fP); 49void setpreroot(char** \fIargv\fP, char* \fIdir\fP); 50.EE 51.SH DESCRIPTION 52The 53.I preroot 54routines manipulate the process preroot. 55.I preroot 56is a kernel supported per-process two level viewpath. 57All pathnames rooted at 58.L / 59are first searched for in the process preroot directory 60and then in the system root directory. 61Setting the process preroot is a priveleged operation controlled by the 62.IR /etc/preroot (1) 63command. 64.PP 65.L <preroot.h> 66defines the symbol 67.B FS_PREROOT 68for those systems that support preroot. 69The following routines are valid only when 70.B FS_PREROOT 71is defined: 72.TP 73.L getpreroot 74returns a pointer to the absolute pathname of the preroot directory 75for the executable 76.IR cmd . 77The result is placed in 78.IR path . 79If 80.I path 81is 82.B 0 83then 84.IR malloc (3) 85is used to allocate the pathname space. 86.B 0 87is returned if 88.I cmd 89has no preroot or if an error was encountered. 90In this case 91.I errno 92is set to indicate the error. 93.TP 94.L ispreroot 95Non-zero is returned if 96.I dir 97is the current process preroot. 98If 99.I dir 100is 101.B 0 102then non-zero is returned if the current process has a preroot. 103.TP 104.L realopen 105temporarily disables the process preroot and does an 106.IR open (3) 107relative to the system root directory. 108The return value from 109.I open 110is returned. 111If there is no preroot then 112.I realopen 113is equivalent to 114.IR open . 115.TP 116.L setpreroot 117calls 118.IR execvp (3) 119as 120.L "execvp(a\fIrgv\fP[0],\fIargv\fP)" 121with the process preroot set to 122.IR dir . 123.I argv 124must be a 125.BR 0 -terminated 126argument array. 127If 128.I argv 129is 130.B 0 131then the value of 132.I opt_argv 133from 134.IR optget (3) 135is used. 136.L setpreroot 137returns immediately if 138.I dir 139is already the process preroot. 140.SH "SEE ALSO" 141/etc/preroot(1) 142.SH BUGS 143Preroot semantics should be preserved when reading directories. 144The 145.I ast 146.IR directory (3) 147routines do this. 148.IR 3d (1) 149viewpathing does 150.I preroot 151the right way. 152