xref: /netbsd-src/sbin/mount_portal/mount_portal.8 (revision 7a2e675187698dce371a9e4d9e649bf6dc31e479)
1.\"	$NetBSD: mount_portal.8,v 1.24 2019/05/23 09:15:45 wiz Exp $
2.\"
3.\" Copyright (c) 1993, 1994
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" This code is derived from software donated to Berkeley by
7.\" Jan-Simon Pendry.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. Neither the name of the University nor the names of its contributors
18.\"    may be used to endorse or promote products derived from this software
19.\"    without specific prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE.
32.\"
33.\"	@(#)mount_portal.8	8.3 (Berkeley) 3/27/94
34.\"
35.Dd May 23, 2019
36.Dt MOUNT_PORTAL 8
37.Os
38.Sh NAME
39.Nm mount_portal
40.Nd mount the portal daemon
41.Sh SYNOPSIS
42.Nm
43.Op Fl o Ar options
44.Ar /etc/portal.conf
45.Ar mount_point
46.Sh DESCRIPTION
47The
48.Nm
49command attaches an instance of the portal daemon
50to the global filesystem namespace.
51The conventional mount point is
52.Pa /p .
53The directory specified by
54.Ar mount_point
55is converted to an absolute path before use.
56This command is normally executed by
57.Xr mount 8
58at boot time.
59.Pp
60The options are as follows:
61.Bl -tag -width indent
62.It Fl o
63Options are specified with a
64.Fl o
65flag followed by a comma separated string of options.
66See the
67.Xr mount 8
68man page for possible options and their meanings.
69.El
70.Pp
71The portal daemon provides an
72.Em open
73service.
74Objects opened under the portal mount point are
75dynamically created by the portal daemon according
76to rules specified in the named configuration file.
77Using this mechanism allows descriptors such as sockets
78to be made available in the filesystem namespace.
79.Pp
80The portal daemon works by being passed the full pathname
81of the object being opened.
82The daemon creates an appropriate descriptor according
83to the rules in the configuration file, and then passes the descriptor back
84to the calling process as the result of the open system call.
85.Sh NAMESPACE
86By convention, the portal daemon divides the namespace into sub-namespaces,
87each of which handles objects of a particular type.
88.Pp
89Currently, four sub-namespaces are implemented:
90.Pa tcp ,
91.Pa fs ,
92.Pa rfilter
93and
94.Pa wfilter .
95The
96.Pa tcp
97namespace takes a hostname and a port (slash separated) and
98creates an open TCP/IP connection.
99The
100.Pa fs
101namespace opens the named file, starting back at the root directory.
102This can be used to provide a controlled escape path from
103a chrooted environment.
104.Pp
105The
106.Pa rfilter
107and
108.Pa wfilter
109namespaces open a pipe to a process, typically a data-filter such
110as compression or decompression programs.
111The
112.Pa rfilter
113namespace opens a read-only pipe, while the
114.Pa wfilter
115namespace opens a write-only pipe.
116See the
117.Sx EXAMPLES
118section below for more examples.
119.Sh CONFIGURATION FILE
120The configuration file contains a list of rules.
121Each rule takes one line and consists of two or more
122whitespace separated fields.
123A hash
124.Pq Dq #
125character at beginning of the line, or after whitespace,
126causes the remainder of a line to be ignored.
127Blank lines are ignored.
128.Pp
129The first field is a pathname prefix to match
130against the requested pathname.
131If a match is found, the second field
132tells the daemon what type of object to create.
133Subsequent fields are passed to the creation function.
134.Pp
135The
136.Pa rfilter
137and
138.Pa wfilter
139namespaces have additional meanings for the remaining fields.
140The third field specifies a prefix that is to be stripped off of
141the passed name before passing it on to the pipe program.
142If the prefix does not match, no stripping is performed.
143The fourth argument specifies the program to use for the pipe.
144Any remaining fields are passed to the pipe program.
145If the string
146.Dq Li "%s"
147exists within these remaining fields, it will be replaced by the
148path after stripping is performed.
149If there is no field after the program name,
150.Dq Li "%s"
151will be assumed, to maintain similarity with the
152.Pa tcp
153and
154.Pa fs
155namespaces.
156.Sh FILES
157.Bl -tag -width /p/* -compact
158.It Pa /p/*
159.El
160.Sh EXAMPLES
161A tutorial and several examples are provided in
162.Pa /usr/share/examples/mount_portal .
163The following is an example configuration file.
164.Bd -literal
165# @(#)portal.conf	5.1 (Berkeley) 7/13/92
166tcp/		tcp tcp/
167fs/		file fs/
168echo/		rfilter	echo/	echo %s
169echo_nostrip/	rfilter	nostrip	echo %s
170echo_noslash    rfilter echo_noslash    echo %s
171gzcat/		rfilter gzcat/ gzcat %s
172gzip/		wfilter	gzip/	gzip > %s
173gzip9/		wfilter	gzip9/	gzip -9 > %s
174ftp/		rfilter	ftp/	ftp -Vo - %s
175ftp://		rfilter	nostrip	ftp -Vo - %s
176http://		rfilter	nostrip	ftp -Vo - %s
177bzcat/		rfilter	bzcat/	bzcat %s
178nroff/		rfilter	nroff/	nroff -man %s
179.Ed
180.Pp
181As is true with many other filesystems, a weird sense of humor is handy.
182.Pp
183Notice that after the keynames, like nroff/ and bzcat/, we
184typically use another slash.
185In reality, the
186.Nm
187process changes directory to
188.Pa / ,
189which makes the subsequent slash unnecessary.
190However, the extra slash provides a visual hint
191that we are not operating on an ordinary file.
192An alternative would be to change the configuration
193file to something like:
194.Bd -literal
195nroff%	rfilter	nroff%	nroff -man
196.Ed
197.Pp
198One might then use
199.Bd -literal
200less /p/nroff%/usr/share/man/man8/mount_portal.8
201.Ed
202.Sh SEE ALSO
203.Xr mount 2 ,
204.Xr unmount 2 ,
205.Xr fstab 5 ,
206.Xr mount 8
207.Sh HISTORY
208The
209.Nm
210utility first appeared in
211.Bx 4.4 .
212The
213.Pa rfilter
214and
215.Pa wfilter
216capabilities first appeared in
217.Nx 1.5 .
218The portal kernel driver was removed and
219.Nm
220was converted to use
221.Xr puffs 3
222in
223.Nx 6.0 .
224.Sh BUGS
225This filesystem may not be NFS-exported.
226