summaryrefslogtreecommitdiff
path: root/usr/src/lib/libast/common/man/preroot.3
blob: 025fc221c0b2882227fc34e723059786dd65da70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
.fp 5 CW
.de Af
.ds ;G \\*(;G\\f\\$1\\$3\\f\\$2
.if !\\$4 .Af \\$2 \\$1 "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
..
.de aF
.ie \\$3 .ft \\$1
.el \{\
.ds ;G \&
.nr ;G \\n(.f
.Af "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
\\*(;G
.ft \\n(;G \}
..
.de L
.aF 5 \\n(.f "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
..
.de LR
.aF 5 1 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
..
.de RL
.aF 1 5 "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7"
..
.de EX		\" start example
.ta 1i 2i 3i 4i 5i 6i
.PP
.RS 
.PD 0
.ft 5
.nf
..
.de EE		\" end example
.fi
.ft
.PD
.RE
.PP
..
.TH PREROOT 3
.SH NAME
preroot \- preroot support
.SH SYNOPSIS
.EX
#include <preroot.h>

char*    getpreroot(char* \fIpath\fP, char* \fIcmd\fP);
int      ispreroot(char* \fIdir\fP);
int      realopen(char* \fIpath\fP, int \fImode\fP, int \fIperm\fP);
void     setpreroot(char** \fIargv\fP, char* \fIdir\fP);
.EE
.SH DESCRIPTION
The
.I preroot
routines manipulate the process preroot.
.I preroot
is a kernel supported per-process two level viewpath.
All pathnames rooted at
.L /
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
.IR /etc/preroot (1)
command.
.PP
.L <preroot.h>
defines the symbol
.B FS_PREROOT
for those systems that support preroot.
The following routines are valid only when
.B FS_PREROOT
is defined:
.TP
.L getpreroot
returns a pointer to the absolute pathname of the preroot directory
for the executable
.IR cmd .
The result is placed in
.IR path .
If
.I path
is
.B 0
then
.IR malloc (3)
is used to allocate the pathname space.
.B 0
is returned if
.I cmd
has no preroot or if an error was encountered.
In this case
.I errno
is set to indicate the error.
.TP
.L ispreroot
Non-zero is returned if 
.I dir
is the current process preroot.
If 
.I dir
is
.B 0
then non-zero is returned if the current process has a preroot.
.TP
.L realopen
temporarily disables the process preroot and does an
.IR open (3)
relative to the system root directory.
The return value from
.I open
is returned.
If there is no preroot then
.I realopen
is equivalent to
.IR open .
.TP
.L setpreroot
calls
.IR execvp (3)
as
.L "execvp(a\fIrgv\fP[0],\fIargv\fP)"
with the process preroot set to
.IR dir .
.I argv
must be a
.BR 0 -terminated
argument array.
If 
.I argv
is
.B 0
then the value of
.I opt_argv
from
.IR optget (3)
is used.
.L setpreroot
returns immediately if
.I dir
is already the process preroot.
.SH "SEE ALSO"
/etc/preroot(1)
.SH BUGS
Preroot semantics should be preserved when reading directories.
The
.I ast
.IR directory (3)
routines do this.
.IR 3d (1)
viewpathing does 
.I preroot
the right way.