154681Sbostic.\"
2*66469Sbostic.\" Copyright (c) 1992, 1993, 1994
362951Sbostic.\"	The Regents of the University of California.  All rights reserved.
454681Sbostic.\" All rights reserved.
554681Sbostic.\"
654681Sbostic.\" This code is derived from software donated to Berkeley by
754681Sbostic.\" Jan-Simon Pendry.
854681Sbostic.\"
954681Sbostic.\" %sccs.include.redist.roff%
1054681Sbostic.\"
11*66469Sbostic.\"	@(#)mount_fdesc.8	8.2 (Berkeley) 03/27/94
1254681Sbostic.\"
1354681Sbostic.\"
1454681Sbostic.Dd
1554681Sbostic.Dt MOUNT_FDESC 8
1654681Sbostic.Os BSD 4.4
1754681Sbostic.Sh NAME
1854681Sbostic.Nm mount_fdesc
1960535Spendry.Nd mount the file-descriptor file system
2054681Sbostic.Sh SYNOPSIS
2154681Sbostic.Nm mount_fdesc
22*66469Sbostic.Op Fl o Ar options
23*66469Sbostic.Ar fdesc
24*66469Sbostic.Ar mount_point
2554681Sbostic.Sh DESCRIPTION
2654681SbosticThe
2754681Sbostic.Nm mount_fdesc
2854681Sbosticcommand attaches an instance of the per-process file descriptor
2954681Sbosticnamespace to the global filesystem namespace.
3054681SbosticThe conventional mount point is
3160535Spendry.Pa /dev
3260535Spendryand the filesystem should be union mounted in order to augment,
3360535Spendryrather than replace, the existing entries in
3460535Spendry.Pa /dev .
3554681SbosticThis command is normally executed by
3654681Sbostic.Xr mount 8
3754681Sbosticat boot time.
3854681Sbostic.Pp
39*66469SbosticThe options are as follows:
40*66469Sbostic.Bl -tag -width indent
41*66469Sbostic.It Fl o
42*66469SbosticOptions are specified with a
43*66469Sbostic.Fl o
44*66469Sbosticflag followed by a comma separated string of options.
45*66469SbosticSee the
46*66469Sbostic.Xr mount 8
47*66469Sbosticman page for possible options and their meanings.
48*66469Sbostic.El
49*66469Sbostic.Pp
5060535SpendryThe contents of the mount point are
5160535Spendry.Pa fd ,
5260535Spendry.Pa stderr ,
5360535Spendry.Pa stdin ,
5460535Spendry.Pa stdout
5560535Spendryand
5660535Spendry.Pa tty .
5760535Spendry.Pp
5860535Spendry.Pa fd
5960535Spendryis a directory whose contents
6060535Spendryappear as a list of numbered files
6154681Sbosticwhich correspond to the open files of the process reading the
6254681Sbosticdirectory.
6354681SbosticThe files
6454681Sbostic.Pa /dev/fd/0
6554681Sbosticthrough
6654681Sbostic.Pa /dev/fd/#
6754681Sbosticrefer to file descriptors which can be accessed through the file
6854681Sbosticsystem.
6954681SbosticIf the file descriptor is open and the mode the file is being opened
7054681Sbosticwith is a subset of the mode of the existing descriptor, the call:
7154681Sbostic.Bd -literal -offset indent
7254681Sbosticfd = open("/dev/fd/0", mode);
7354681Sbostic.Ed
7454681Sbostic.Pp
7554681Sbosticand the call:
7654681Sbostic.Bd -literal -offset indent
7754681Sbosticfd = fcntl(0, F_DUPFD, 0);
7854681Sbostic.Ed
7954681Sbostic.Pp
8054681Sbosticare equivalent.
8154681Sbostic.Pp
8260535SpendryThe files
8354681Sbostic.Pa /dev/stdin ,
8454681Sbostic.Pa /dev/stdout
8554681Sbosticand
8654681Sbostic.Pa /dev/stderr
8760535Spendryappear as symlinks to the relevant entry in the
8860535Spendry.Pa /dev/fd
8960535Spendrysub-directory.
9060535SpendryOpening them is equivalent to the following calls:
9154681Sbostic.Bd -literal -offset indent
9254681Sbosticfd = fcntl(STDIN_FILENO,  F_DUPFD, 0);
9354681Sbosticfd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
9454681Sbosticfd = fcntl(STDERR_FILENO, F_DUPFD, 0);
9554681Sbostic.Ed
9654681Sbostic.Pp
9754681SbosticFlags to the
9854681Sbostic.Xr open 2
9954681Sbosticcall other than
10054681Sbostic.Dv O_RDONLY ,
10154681Sbostic.Dv O_WRONLY
10254681Sbosticand
10354681Sbostic.Dv O_RDWR
10454681Sbosticare ignored.
10560535Spendry.Pp
10660535SpendryThe
10760535Spendry.Pa /dev/tty
10860535Spendryentry is an indirect reference to the current process's controlling terminal.
10960535SpendryIt appears as a named pipe (FIFO) but behaves in exactly the same way as
11060535Spendrythe real controlling terminal device.
11154681Sbostic.Sh FILES
11254681Sbostic.Bl -tag -width /dev/stderr -compact
11354681Sbostic.It Pa /dev/fd/#
11454681Sbostic.It Pa /dev/stdin
11554681Sbostic.It Pa /dev/stdout
11654681Sbostic.It Pa /dev/stderr
11760535Spendry.It Pa /dev/tty
11854681Sbostic.El
11954681Sbostic.Sh SEE ALSO
12054681Sbostic.Xr mount 2 ,
12154681Sbostic.Xr unmount 2 ,
12254681Sbostic.Xr tty 4 ,
123*66469Sbostic.Xr fstab 5 ,
124*66469Sbostic.Xr mount 8
12554681Sbostic.Sh CAVEATS
12654681SbosticNo
12754681Sbostic.Pa .
12854681Sbosticand
12954681Sbostic.Pa ..
13060535Spendryentries appear when listing the contents of the
13160535Spendry.Pa /dev/fd
13260535Spendrydirectory.
13354681SbosticThis makes sense in the context of this filesystem, but is inconsistent
13454681Sbosticwith usual filesystem conventions.
13554681SbosticHowever, it is still possible to refer to both
13654681Sbostic.Pa .
13754681Sbosticand
13854681Sbostic.Pa ..
13954681Sbosticin a pathname.
14054681Sbostic.Pp
14154681SbosticThis filesystem may not be NFS-exported.
14254681Sbostic.Sh HISTORY
14354681SbosticThe
14462950Sbostic.Nm mount_fdesc
14562950Sbosticutility first appeared in 4.4BSD.
146