cleanup
This commit is contained in:
parent
2ffd7cf6a2
commit
3c3b8be419
17 changed files with 4 additions and 3909 deletions
|
@ -247,9 +247,7 @@
|
||||||
./etc/rc.d/lockd
|
./etc/rc.d/lockd
|
||||||
./etc/rc.d/lpd
|
./etc/rc.d/lpd
|
||||||
./etc/rc.d/mopd
|
./etc/rc.d/mopd
|
||||||
./etc/rc.d/mountd
|
|
||||||
./etc/rc.d/mrouted
|
./etc/rc.d/mrouted
|
||||||
./etc/rc.d/nfsd
|
|
||||||
./etc/rc.d/npppd
|
./etc/rc.d/npppd
|
||||||
./etc/rc.d/nsd
|
./etc/rc.d/nsd
|
||||||
./etc/rc.d/ntpd
|
./etc/rc.d/ntpd
|
||||||
|
@ -367,13 +365,11 @@
|
||||||
./sbin/mount_tmpfs
|
./sbin/mount_tmpfs
|
||||||
./sbin/mount_udf
|
./sbin/mount_udf
|
||||||
./sbin/mount_vnd
|
./sbin/mount_vnd
|
||||||
./sbin/mountd
|
|
||||||
./sbin/ncheck
|
./sbin/ncheck
|
||||||
./sbin/ncheck_ffs
|
./sbin/ncheck_ffs
|
||||||
./sbin/newfs
|
./sbin/newfs
|
||||||
./sbin/newfs_ext2fs
|
./sbin/newfs_ext2fs
|
||||||
./sbin/newfs_msdos
|
./sbin/newfs_msdos
|
||||||
./sbin/nfsd
|
|
||||||
./sbin/nologin
|
./sbin/nologin
|
||||||
./sbin/pfctl
|
./sbin/pfctl
|
||||||
./sbin/pflogd
|
./sbin/pflogd
|
||||||
|
@ -560,7 +556,6 @@
|
||||||
./usr/bin/netstat
|
./usr/bin/netstat
|
||||||
./usr/bin/newaliases
|
./usr/bin/newaliases
|
||||||
./usr/bin/newsyslog
|
./usr/bin/newsyslog
|
||||||
./usr/bin/nfsstat
|
|
||||||
./usr/bin/nice
|
./usr/bin/nice
|
||||||
./usr/bin/nl
|
./usr/bin/nl
|
||||||
./usr/bin/nm
|
./usr/bin/nm
|
||||||
|
|
|
@ -61,7 +61,7 @@ EXAMPLES_600=bgpd.conf doas.conf dvmrpd.conf eigrpd.conf hostapd.conf \
|
||||||
RCDAEMONS=amd apmd bgpd bgplgd bootparamd cron dhcpd dhcpleased dhcp6leased \
|
RCDAEMONS=amd apmd bgpd bgplgd bootparamd cron dhcpd dhcpleased dhcp6leased \
|
||||||
dhcrelay dhcrelay6 dvmrpd eigrpd ftpd ftpproxy ftpproxy6 hostapd \
|
dhcrelay dhcrelay6 dvmrpd eigrpd ftpd ftpproxy ftpproxy6 hostapd \
|
||||||
hotplugd httpd identd ifstated iked inetd isakmpd iscsid ldapd \
|
hotplugd httpd identd ifstated iked inetd isakmpd iscsid ldapd \
|
||||||
ldattach ldomd ldpd lockd lpd mopd mountd mrouted nfsd npppd nsd ntpd \
|
ldattach ldomd ldpd lockd lpd mopd mrouted npppd nsd ntpd \
|
||||||
ospf6d ospfd pflogd portmap rad radiusd rarpd rbootd relayd resolvd \
|
ospf6d ospfd pflogd portmap rad radiusd rarpd rbootd relayd resolvd \
|
||||||
ripd route6d sasyncd sensorsd slowcgi slaacd smtpd sndiod snmpd spamd \
|
ripd route6d sasyncd sensorsd slowcgi slaacd smtpd sndiod snmpd spamd \
|
||||||
spamlogd sshd statd syslogd tftpd tftpproxy unbound \
|
spamlogd sshd statd syslogd tftpd tftpproxy unbound \
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/bin/ksh
|
|
||||||
#
|
|
||||||
# $OpenBSD: mountd,v 1.8 2018/01/11 21:09:26 rpe Exp $
|
|
||||||
|
|
||||||
daemon="/sbin/mountd"
|
|
||||||
|
|
||||||
. /etc/rc.d/rc.subr
|
|
||||||
|
|
||||||
pexp="mountd: \[priv\]"
|
|
||||||
rc_stop=NO
|
|
||||||
|
|
||||||
rc_pre() {
|
|
||||||
[[ -s /etc/exports ]] && grep -qv '^#' /etc/exports &&
|
|
||||||
rm -f /var/db/mountdtab &&
|
|
||||||
echo -n > /var/db/mountdtab
|
|
||||||
}
|
|
||||||
|
|
||||||
rc_cmd $1
|
|
|
@ -1,17 +0,0 @@
|
||||||
#!/bin/ksh
|
|
||||||
#
|
|
||||||
# $OpenBSD: nfsd,v 1.9 2022/08/29 19:14:25 ajacoutot Exp $
|
|
||||||
|
|
||||||
daemon="/sbin/nfsd"
|
|
||||||
daemon_flags="-tun 4"
|
|
||||||
|
|
||||||
. /etc/rc.d/rc.subr
|
|
||||||
|
|
||||||
pexp="(${daemon}( |$)|nfsd: (master|server)$)"
|
|
||||||
rc_reload=NO
|
|
||||||
|
|
||||||
rc_pre() {
|
|
||||||
[[ -s /etc/exports ]] && grep -qv '^#' /etc/exports
|
|
||||||
}
|
|
||||||
|
|
||||||
rc_cmd $1
|
|
|
@ -6,8 +6,8 @@ SUBDIR= atactl badsect bioctl clri dhcp6leased dhcpleased \
|
||||||
isakmpd kbd ldattach mknod mount \
|
isakmpd kbd ldattach mknod mount \
|
||||||
mount_cd9660 mount_ext2fs mount_ffs mount_msdos \
|
mount_cd9660 mount_ext2fs mount_ffs mount_msdos \
|
||||||
mount_nfs mount_ntfs mount_tmpfs mount_udf \
|
mount_nfs mount_ntfs mount_tmpfs mount_udf \
|
||||||
mount_vnd mountd ncheck_ffs newfs newfs_ext2fs newfs_msdos \
|
mount_vnd ncheck_ffs newfs newfs_ext2fs newfs_msdos \
|
||||||
nfsd nologin pdisk pfctl pflogd ping quotacheck \
|
nologin pdisk pfctl pflogd ping quotacheck \
|
||||||
reboot resolvd restore route savecore scan_ffs \
|
reboot resolvd restore route savecore scan_ffs \
|
||||||
scsi slaacd shutdown swapctl sysctl ttyflags tunefs vnconfig \
|
scsi slaacd shutdown swapctl sysctl ttyflags tunefs vnconfig \
|
||||||
umount unwind wsconsctl
|
umount unwind wsconsctl
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
# $OpenBSD: Makefile,v 1.5 2022/08/29 17:00:30 deraadt Exp $
|
|
||||||
|
|
||||||
PROG= mountd
|
|
||||||
MAN= exports.5 mountd.8
|
|
||||||
|
|
||||||
LDADD= -lutil
|
|
||||||
DPADD= ${LIBUTIL}
|
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
|
||||||
|
|
||||||
# Don't compile mountd as static binary by default
|
|
||||||
LDSTATIC=
|
|
|
@ -1,291 +0,0 @@
|
||||||
.\" $OpenBSD: exports.5,v 1.27 2020/05/16 16:58:11 jmc Exp $
|
|
||||||
.\" $NetBSD: exports.5,v 1.9 1996/02/18 11:57:50 fvdl Exp $
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 1989, 1991, 1993
|
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\" 3. Neither the name of the University nor the names of its contributors
|
|
||||||
.\" may be used to endorse or promote products derived from this software
|
|
||||||
.\" without specific prior written permission.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
.\" SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.\" @(#)exports.5 8.3 (Berkeley) 3/29/95
|
|
||||||
.\"
|
|
||||||
.Dd $Mdocdate: May 16 2020 $
|
|
||||||
.Dt EXPORTS 5
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm exports
|
|
||||||
.Nd define remote mount points for NFS mount requests
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
file specifies remote mount points for the NFS
|
|
||||||
mount protocol per the NFS server specification; see
|
|
||||||
.%T "Network File System Protocol Specification" ,
|
|
||||||
RFC 1094, Appendix A and
|
|
||||||
.%T "NFS: Network File System Version 3 Specification" ,
|
|
||||||
RFC 1813, Appendix I.
|
|
||||||
.Pp
|
|
||||||
Each line in the file
|
|
||||||
(other than comment lines that begin with a
|
|
||||||
.Dq # )
|
|
||||||
specifies the mount point(s) and export flags within one local server
|
|
||||||
filesystem for one or more hosts.
|
|
||||||
A host may be specified only once for each local filesystem on the
|
|
||||||
server and there may be only one default entry for each server
|
|
||||||
filesystem that applies to all other hosts.
|
|
||||||
The latter exports the filesystem to the
|
|
||||||
.Dq world
|
|
||||||
and should
|
|
||||||
be used only when the filesystem contains public information.
|
|
||||||
.Pp
|
|
||||||
In a mount entry,
|
|
||||||
the first field(s) specify the directory path(s) within a server filesystem
|
|
||||||
that can be mounted on by the corresponding client(s).
|
|
||||||
There are two forms of this specification.
|
|
||||||
The first is to list all mount points as absolute
|
|
||||||
directory paths separated by whitespace.
|
|
||||||
The second is to specify the pathname of the root of the filesystem
|
|
||||||
followed by the
|
|
||||||
.Fl alldirs
|
|
||||||
flag;
|
|
||||||
this form allows the host(s) to mount at any point within the filesystem,
|
|
||||||
including regular files.
|
|
||||||
The pathnames must not have any symbolic links in them and should not have
|
|
||||||
any
|
|
||||||
.Dq \&.
|
|
||||||
or
|
|
||||||
.Dq \&.\&.
|
|
||||||
components.
|
|
||||||
Mount points for a filesystem may appear on multiple lines each with
|
|
||||||
different sets of hosts and export options.
|
|
||||||
.Pp
|
|
||||||
The second component of a line specifies how the filesystem is to be
|
|
||||||
exported to the host set.
|
|
||||||
The option flags specify whether the filesystem
|
|
||||||
is exported read-only or read-write and how the client UID is mapped to
|
|
||||||
user credentials on the server.
|
|
||||||
.Pp
|
|
||||||
Export options are specified as follows:
|
|
||||||
.Pp
|
|
||||||
.Sm off
|
|
||||||
.Fl maproot No = Ar user
|
|
||||||
.Sm on
|
|
||||||
The credential of the specified user is used for remote access by root.
|
|
||||||
The credential includes all the groups to which the user is a member
|
|
||||||
on the local machine (see
|
|
||||||
.Xr id 1 ) .
|
|
||||||
The
|
|
||||||
.Ar user
|
|
||||||
may be specified by name or number.
|
|
||||||
.Pp
|
|
||||||
.Sm off
|
|
||||||
.Fl maproot No = Ar user:group1:group2:...
|
|
||||||
.Sm on
|
|
||||||
The colon separated list is used to specify the precise credential
|
|
||||||
to be used for remote access by root.
|
|
||||||
The elements of the list may be either names or numbers.
|
|
||||||
Note that user: should be used to distinguish a credential containing
|
|
||||||
no groups from a complete credential for that user.
|
|
||||||
.Pp
|
|
||||||
.Sm off
|
|
||||||
.Fl mapall No = Ar user
|
|
||||||
.Sm on
|
|
||||||
or
|
|
||||||
.Sm off
|
|
||||||
.Fl mapall No = Ar user:group1:group2:...
|
|
||||||
.Sm on
|
|
||||||
Specifies a mapping for all client UIDs (including root)
|
|
||||||
using the same semantics as
|
|
||||||
.Fl maproot .
|
|
||||||
.Pp
|
|
||||||
The option
|
|
||||||
.Fl r
|
|
||||||
is a synonym for
|
|
||||||
.Fl maproot
|
|
||||||
in an effort to be backward compatible with older export file formats.
|
|
||||||
.Pp
|
|
||||||
In the absence of
|
|
||||||
.Fl maproot
|
|
||||||
and
|
|
||||||
.Fl mapall
|
|
||||||
options, remote accesses by root will result in using a credential of -2:-2.
|
|
||||||
All other users will be mapped to their remote credential.
|
|
||||||
If a
|
|
||||||
.Fl maproot
|
|
||||||
option is given,
|
|
||||||
remote access by root will be mapped to that credential instead of -2:-2.
|
|
||||||
If a
|
|
||||||
.Fl mapall
|
|
||||||
option is given,
|
|
||||||
all users (including root) will be mapped to that credential in
|
|
||||||
place of their own.
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fl ro
|
|
||||||
option specifies that the filesystem should be exported read-only
|
|
||||||
(default read/write).
|
|
||||||
The option
|
|
||||||
.Fl o
|
|
||||||
is a synonym for
|
|
||||||
.Fl ro
|
|
||||||
in an effort to be backward compatible with older export file formats.
|
|
||||||
.Pp
|
|
||||||
The third component of a line specifies the host set to which the line applies.
|
|
||||||
The set may be specified in three ways.
|
|
||||||
The first way is to list the host name(s) separated by whitespace.
|
|
||||||
(Standard internet
|
|
||||||
.Dq dot
|
|
||||||
addresses may be used in place of names.)
|
|
||||||
The second way is to specify a
|
|
||||||
.Dq netgroup
|
|
||||||
as defined in the netgroup file (see
|
|
||||||
.Xr netgroup 5 ) .
|
|
||||||
The third way is to specify an internet subnetwork using a network and
|
|
||||||
network mask that is defined as the set of all hosts with addresses within
|
|
||||||
the subnetwork.
|
|
||||||
This latter approach requires less overhead within the
|
|
||||||
kernel and is recommended for cases where the export line refers to a
|
|
||||||
large number of clients within an administrative subnet.
|
|
||||||
.Pp
|
|
||||||
The first two cases are specified by simply listing the name(s) separated
|
|
||||||
by whitespace.
|
|
||||||
All names are checked to see if they are
|
|
||||||
.Dq netgroup
|
|
||||||
names
|
|
||||||
first and are assumed to be hostnames otherwise.
|
|
||||||
Using the full domain specification for a hostname can normally
|
|
||||||
circumvent the problem of a host that has the same name as a netgroup.
|
|
||||||
The third case is specified by the flag
|
|
||||||
.Sm off
|
|
||||||
.Fl network No = Ar netname
|
|
||||||
.Sm on
|
|
||||||
and optionally
|
|
||||||
.Sm off
|
|
||||||
.Fl mask No = Ar netmask .
|
|
||||||
.Sm on
|
|
||||||
If the mask is not specified, it will default to the mask for that network
|
|
||||||
class (A, B or C; see
|
|
||||||
.Xr inet_addr 3 ) .
|
|
||||||
.Pp
|
|
||||||
For example:
|
|
||||||
.Bd -literal -offset indent
|
|
||||||
/usr /usr/local -maproot=0:10 friends
|
|
||||||
/usr -maproot=daemon grumpy.cis.uoguelph.ca 131.104.48.16
|
|
||||||
/usr -ro -mapall=nobody
|
|
||||||
/u -maproot=bin: -network=131.104.48 -mask=255.255.255.0
|
|
||||||
/u2 -maproot=root friends
|
|
||||||
/u2 -alldirs -network=cis-net -mask=cis-mask
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
Given that
|
|
||||||
.Pa /usr ,
|
|
||||||
.Pa /u
|
|
||||||
and
|
|
||||||
.Pa /u2
|
|
||||||
are
|
|
||||||
local filesystem mount points, the above example specifies the following:
|
|
||||||
.Pa /usr
|
|
||||||
is exported to hosts
|
|
||||||
.Em friends
|
|
||||||
where
|
|
||||||
.Em friends
|
|
||||||
is specified in the netgroup file
|
|
||||||
with users mapped to their remote credentials and
|
|
||||||
root mapped to UID 0 and GID 10.
|
|
||||||
It is exported read-write and the hosts in
|
|
||||||
.Dq friends
|
|
||||||
can mount either
|
|
||||||
.Pa /usr
|
|
||||||
or
|
|
||||||
.Pa /usr/local .
|
|
||||||
It is exported to
|
|
||||||
.Em 131.104.48.16
|
|
||||||
and
|
|
||||||
.Em grumpy.cis.uoguelph.ca
|
|
||||||
with users mapped to their remote credentials and
|
|
||||||
root mapped to the user and groups associated with
|
|
||||||
.Dq daemon ;
|
|
||||||
it is exported to the rest of the world as read-only with
|
|
||||||
all users mapped to the user and groups associated with
|
|
||||||
.Dq nobody .
|
|
||||||
.Pp
|
|
||||||
.Pa /u
|
|
||||||
is exported to all hosts on the subnetwork
|
|
||||||
.Em 131.104.48
|
|
||||||
with root mapped to the UID for
|
|
||||||
.Dq bin
|
|
||||||
and with no group access.
|
|
||||||
.Pp
|
|
||||||
.Pa /u2
|
|
||||||
is exported to the hosts in
|
|
||||||
.Dq friends
|
|
||||||
with root mapped to UID and groups
|
|
||||||
associated with
|
|
||||||
.Dq root ;
|
|
||||||
it is exported to all hosts on network
|
|
||||||
.Dq cis-net
|
|
||||||
allowing mounts at any
|
|
||||||
directory within /u2.
|
|
||||||
.Sh FILES
|
|
||||||
.Bl -tag -width /etc/examples/exports -compact
|
|
||||||
.It Pa /etc/exports
|
|
||||||
Default remote mount point file.
|
|
||||||
.It Pa /etc/examples/exports
|
|
||||||
Example remote mount point file.
|
|
||||||
.El
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr netgroup 5 ,
|
|
||||||
.Xr mountd 8 ,
|
|
||||||
.Xr nfsd 8 ,
|
|
||||||
.Xr showmount 8
|
|
||||||
.Sh BUGS
|
|
||||||
The export options are tied to the local mount points in the kernel and
|
|
||||||
must be non-contradictory for any exported subdirectory of the local
|
|
||||||
server mount point.
|
|
||||||
It is recommended that all exported directories within the same server
|
|
||||||
filesystem be specified on adjacent lines going down the tree.
|
|
||||||
You cannot specify a hostname that is also the name of a netgroup.
|
|
||||||
Specifying the full domain specification for a hostname can normally
|
|
||||||
circumvent the problem.
|
|
||||||
.Pp
|
|
||||||
Regarding
|
|
||||||
.Fl alldirs ,
|
|
||||||
because NFS mount filehandles are filesystem wide the
|
|
||||||
.Fl alldirs
|
|
||||||
option applies to exports of the entire filesystem \(em even mount points
|
|
||||||
that are higher up elsewhere in the directory hierarchy.
|
|
||||||
Hence if the server has a filesystem
|
|
||||||
.Pa /export
|
|
||||||
and you wished to export the sub-directory
|
|
||||||
.Bd -literal -offset indent
|
|
||||||
/export/root/client -alldirs client.foo.com
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
you must realize that this also allows mounts to be requested
|
|
||||||
against other locations in the
|
|
||||||
.Pa /export
|
|
||||||
filesystem; thus the host client.foo.com is also permitted to
|
|
||||||
mount the directory
|
|
||||||
.Pa /export/root/client2
|
|
||||||
if it exists.
|
|
|
@ -1,116 +0,0 @@
|
||||||
.\" $OpenBSD: mountd.8,v 1.21 2022/07/30 07:19:30 jsg Exp $
|
|
||||||
.\" $NetBSD: mountd.8,v 1.11 1996/02/18 11:57:51 fvdl Exp $
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 1989, 1991, 1993
|
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\" 3. Neither the name of the University nor the names of its contributors
|
|
||||||
.\" may be used to endorse or promote products derived from this software
|
|
||||||
.\" without specific prior written permission.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
.\" SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.\" @(#)mountd.8 8.4 (Berkeley) 4/28/95
|
|
||||||
.\"
|
|
||||||
.Dd $Mdocdate: July 30 2022 $
|
|
||||||
.Dt MOUNTD 8
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm mountd
|
|
||||||
.Nd service remote NFS mount requests
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Nm mountd
|
|
||||||
.Op Fl d
|
|
||||||
.Op Ar exportsfile
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
.Nm
|
|
||||||
is the server for NFS mount requests from other client machines.
|
|
||||||
.Nm
|
|
||||||
listens for service requests at the port indicated in the NFS
|
|
||||||
server specification; see
|
|
||||||
.%T "Network File System Protocol Specification" ,
|
|
||||||
RFC 1094, Appendix A and
|
|
||||||
.%T "NFS: Network File System Version 3 Protocol Specification" ,
|
|
||||||
RFC 1813, Appendix I.
|
|
||||||
.Pp
|
|
||||||
The options are as follows:
|
|
||||||
.Bl -tag -width Ds
|
|
||||||
.It Fl d
|
|
||||||
Enable debugging mode.
|
|
||||||
.Nm
|
|
||||||
will not detach from the controlling terminal and will print
|
|
||||||
debugging messages to stderr.
|
|
||||||
.It Ar exportsfile
|
|
||||||
The
|
|
||||||
.Ar exportsfile
|
|
||||||
argument specifies an alternate location
|
|
||||||
for the exports file.
|
|
||||||
.El
|
|
||||||
.Pp
|
|
||||||
When
|
|
||||||
.Nm
|
|
||||||
is started,
|
|
||||||
it loads the export host addresses and options into the kernel
|
|
||||||
using the
|
|
||||||
.Xr mount 2
|
|
||||||
system call.
|
|
||||||
After changing the exports file,
|
|
||||||
a hangup signal should be sent to the
|
|
||||||
.Nm
|
|
||||||
daemon
|
|
||||||
to get it to reload the export information.
|
|
||||||
After sending the
|
|
||||||
.Dv SIGHUP
|
|
||||||
(kill \-HUP `cat /var/run/mountd.pid`),
|
|
||||||
check the syslog output to see if
|
|
||||||
.Nm
|
|
||||||
logged any parsing
|
|
||||||
errors in the exports file.
|
|
||||||
.Sh FILES
|
|
||||||
.Bl -tag -width /var/run/mountd.pid -compact
|
|
||||||
.It Pa /etc/exports
|
|
||||||
list of exported filesystems
|
|
||||||
.It Pa /var/db/mountdtab
|
|
||||||
list of exported filesystems currently mounted
|
|
||||||
.It Pa /var/run/mountd.pid
|
|
||||||
PID of the currently running
|
|
||||||
.Nm
|
|
||||||
.El
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr nfsstat 1 ,
|
|
||||||
.Xr exports 5 ,
|
|
||||||
.Xr nfsd 8 ,
|
|
||||||
.Xr portmap 8 ,
|
|
||||||
.Xr showmount 8
|
|
||||||
.Sh HISTORY
|
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
utility first appeared in
|
|
||||||
.Bx 4.3 Reno .
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Fl n
|
|
||||||
flag historically allowed clients to use non-reserved ports
|
|
||||||
when communicating with
|
|
||||||
.Nm .
|
|
||||||
In
|
|
||||||
.Ox ,
|
|
||||||
a reserved port is always used.
|
|
2427
sbin/mountd/mountd.c
2427
sbin/mountd/mountd.c
File diff suppressed because it is too large
Load diff
|
@ -1,39 +0,0 @@
|
||||||
/* $OpenBSD: pathnames.h,v 1.3 2003/06/02 20:06:16 millert Exp $ */
|
|
||||||
/* $NetBSD: pathnames.h,v 1.6 1995/03/18 14:58:35 cgd Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1989, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* @(#)pathnames.h 8.1 (Berkeley) 6/5/93
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <paths.h>
|
|
||||||
|
|
||||||
#define _PATH_EXPORTS "/etc/exports"
|
|
||||||
#define _PATH_RMOUNTLIST "/var/db/mountdtab"
|
|
||||||
#define _PATH_MOUNTDPID "/var/run/mountd.pid"
|
|
|
@ -1,9 +0,0 @@
|
||||||
# $OpenBSD: Makefile,v 1.9 2022/08/29 17:00:30 deraadt Exp $
|
|
||||||
|
|
||||||
PROG= nfsd
|
|
||||||
MAN= nfsd.8
|
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
|
||||||
|
|
||||||
# Don't compile nfsd as static binary by default
|
|
||||||
LDSTATIC=
|
|
|
@ -1,95 +0,0 @@
|
||||||
.\" $OpenBSD: nfsd.8,v 1.20 2022/07/30 07:19:30 jsg Exp $
|
|
||||||
.\" $NetBSD: nfsd.8,v 1.7 1996/02/18 11:58:24 fvdl Exp $
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 1989, 1991, 1993
|
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\" 3. Neither the name of the University nor the names of its contributors
|
|
||||||
.\" may be used to endorse or promote products derived from this software
|
|
||||||
.\" without specific prior written permission.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
.\" SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.\" @(#)nfsd.8 8.4 (Berkeley) 3/29/95
|
|
||||||
.\"
|
|
||||||
.Dd $Mdocdate: July 30 2022 $
|
|
||||||
.Dt NFSD 8
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm nfsd
|
|
||||||
.Nd remote NFS server
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Nm nfsd
|
|
||||||
.Op Fl rtu
|
|
||||||
.Op Fl n Ar num_servers
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
.Nm
|
|
||||||
runs on a server machine to service NFS
|
|
||||||
requests from client machines.
|
|
||||||
At least one
|
|
||||||
.Nm
|
|
||||||
must be running for a machine to operate as a server.
|
|
||||||
.Pp
|
|
||||||
Unless otherwise specified, four servers for UDP
|
|
||||||
transport are started.
|
|
||||||
.Pp
|
|
||||||
The options are as follows:
|
|
||||||
.Bl -tag -width Ds
|
|
||||||
.It Fl n Ar num_servers
|
|
||||||
Specifies how many servers to create (max 20).
|
|
||||||
.It Fl r
|
|
||||||
Register the NFS service with
|
|
||||||
.Xr portmap 8
|
|
||||||
without creating any servers.
|
|
||||||
This option can be used along with the
|
|
||||||
.Fl u
|
|
||||||
or
|
|
||||||
.Fl t
|
|
||||||
options to re-register NFS if the portmap server is restarted.
|
|
||||||
.It Fl t
|
|
||||||
Serve TCP NFS clients.
|
|
||||||
.It Fl u
|
|
||||||
Serve UDP NFS clients.
|
|
||||||
.El
|
|
||||||
.Pp
|
|
||||||
For example,
|
|
||||||
.Dq Li "nfsd -u -t -n 6"
|
|
||||||
serves UDP and TCP transports using six daemons.
|
|
||||||
.Pp
|
|
||||||
A server should run enough daemons to handle
|
|
||||||
the maximum level of concurrency from its clients,
|
|
||||||
typically four to six.
|
|
||||||
.Pp
|
|
||||||
.Nm
|
|
||||||
listens for service requests at the port indicated in the NFS
|
|
||||||
server specification; see RFCs 1094 and 1813.
|
|
||||||
.Sh EXIT STATUS
|
|
||||||
.Ex -std nfsd
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr nfsstat 1 ,
|
|
||||||
.Xr nfssvc 2 ,
|
|
||||||
.Xr mountd 8 ,
|
|
||||||
.Xr portmap 8
|
|
||||||
.Sh HISTORY
|
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
utility first appeared in
|
|
||||||
.Bx 4.3 Reno .
|
|
339
sbin/nfsd/nfsd.c
339
sbin/nfsd/nfsd.c
|
@ -1,339 +0,0 @@
|
||||||
/* $OpenBSD: nfsd.c,v 1.45 2025/01/16 12:46:03 kn Exp $ */
|
|
||||||
/* $NetBSD: nfsd.c,v 1.19 1996/02/18 23:18:56 mycroft Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1989, 1993, 1994
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* Rick Macklem at The University of Guelph.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <sys/uio.h>
|
|
||||||
#include <sys/ucred.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
#include <rpc/rpc.h>
|
|
||||||
#include <rpc/pmap_clnt.h>
|
|
||||||
#include <rpc/pmap_prot.h>
|
|
||||||
|
|
||||||
#include <nfs/rpcv2.h>
|
|
||||||
#include <nfs/nfsproto.h>
|
|
||||||
#include <nfs/nfs.h>
|
|
||||||
|
|
||||||
#include <err.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <grp.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <syslog.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
/* Global defs */
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define syslog(e, s, ...) \
|
|
||||||
do { \
|
|
||||||
fprintf(stderr, (s), ##__VA_ARGS__); \
|
|
||||||
fprintf(stderr, "\n"); \
|
|
||||||
} while (0)
|
|
||||||
int debug = 1;
|
|
||||||
#else
|
|
||||||
int debug = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct nfsd_srvargs nsd;
|
|
||||||
|
|
||||||
void nonfs(int);
|
|
||||||
void reapchild(int);
|
|
||||||
void usage(void);
|
|
||||||
|
|
||||||
#define MAXNFSDCNT 20
|
|
||||||
#define DEFNFSDCNT 4
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Nfs server daemon mostly just a user context for nfssvc()
|
|
||||||
*
|
|
||||||
* 1 - do file descriptor and signal cleanup
|
|
||||||
* 2 - fork the nfsd(s)
|
|
||||||
* 3 - create server socket(s)
|
|
||||||
* 4 - register socket with portmap
|
|
||||||
*
|
|
||||||
* For connectionless protocols, just pass the socket into the kernel via.
|
|
||||||
* nfssvc().
|
|
||||||
* For connection based sockets, loop doing accepts. When you get a new
|
|
||||||
* socket from accept, pass the msgsock into the kernel via. nfssvc().
|
|
||||||
* The arguments are:
|
|
||||||
* -r - reregister with portmapper
|
|
||||||
* -t - support tcp nfs clients
|
|
||||||
* -u - support udp nfs clients
|
|
||||||
* followed by "n" which is the number of nfsds' to fork off
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
struct nfsd_args nfsdargs;
|
|
||||||
struct sockaddr_in inetaddr;
|
|
||||||
int ch, i;
|
|
||||||
int nfsdcnt = DEFNFSDCNT, on, reregister = 0, sock;
|
|
||||||
int udpflag = 0, tcpflag = 0, tcpsock;
|
|
||||||
const char *errstr = NULL;
|
|
||||||
|
|
||||||
/* Start by writing to both console and log. */
|
|
||||||
openlog("nfsd", LOG_PID | LOG_PERROR, LOG_DAEMON);
|
|
||||||
|
|
||||||
if (unveil("/", "") == -1) {
|
|
||||||
syslog(LOG_ERR, "unveil /: %s", strerror(errno));
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
if (unveil(NULL, NULL) == -1) {
|
|
||||||
syslog(LOG_ERR, "unveil: %s", strerror(errno));
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "n:rtu")) != -1)
|
|
||||||
switch (ch) {
|
|
||||||
case 'n':
|
|
||||||
nfsdcnt = strtonum(optarg, 1, MAXNFSDCNT, &errstr);
|
|
||||||
if (errstr) {
|
|
||||||
syslog(LOG_ERR, "nfsd count is %s: %s", errstr, optarg);
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
reregister = 1;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
tcpflag = 1;
|
|
||||||
break;
|
|
||||||
case 'u':
|
|
||||||
udpflag = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
argv += optind;
|
|
||||||
argc -= optind;
|
|
||||||
|
|
||||||
if (!(tcpflag || udpflag))
|
|
||||||
udpflag = 1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX
|
|
||||||
* Backward compatibility, trailing number is the count of daemons.
|
|
||||||
*/
|
|
||||||
if (argc > 1)
|
|
||||||
usage();
|
|
||||||
if (argc == 1) {
|
|
||||||
nfsdcnt = strtonum(argv[0], 1, MAXNFSDCNT, &errstr);
|
|
||||||
if (errstr) {
|
|
||||||
syslog(LOG_ERR, "nfsd count is %s: %s", errstr, optarg);
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debug == 0) {
|
|
||||||
daemon(0, 0);
|
|
||||||
(void)signal(SIGHUP, SIG_IGN);
|
|
||||||
(void)signal(SIGINT, SIG_IGN);
|
|
||||||
(void)signal(SIGQUIT, SIG_IGN);
|
|
||||||
(void)signal(SIGSYS, nonfs);
|
|
||||||
}
|
|
||||||
(void)signal(SIGCHLD, reapchild);
|
|
||||||
|
|
||||||
if (reregister) {
|
|
||||||
if (udpflag &&
|
|
||||||
(!pmap_set(RPCPROG_NFS, 2, IPPROTO_UDP, NFS_PORT) ||
|
|
||||||
!pmap_set(RPCPROG_NFS, 3, IPPROTO_UDP, NFS_PORT))) {
|
|
||||||
syslog(LOG_ERR, "can't register with portmap for UDP (%s).",
|
|
||||||
strerror(errno));
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
if (tcpflag &&
|
|
||||||
(!pmap_set(RPCPROG_NFS, 2, IPPROTO_TCP, NFS_PORT) ||
|
|
||||||
!pmap_set(RPCPROG_NFS, 3, IPPROTO_TCP, NFS_PORT))) {
|
|
||||||
syslog(LOG_ERR, "can't register with portmap for TCP (%s).",
|
|
||||||
strerror(errno));
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Cut back to writing to log only. */
|
|
||||||
closelog();
|
|
||||||
openlog("nfsd", LOG_PID, LOG_DAEMON);
|
|
||||||
|
|
||||||
for (i = 0; i < nfsdcnt; i++) {
|
|
||||||
switch (fork()) {
|
|
||||||
case -1:
|
|
||||||
syslog(LOG_ERR, "fork: %s", strerror(errno));
|
|
||||||
return (1);
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
setproctitle("server");
|
|
||||||
nsd.nsd_nfsd = NULL;
|
|
||||||
if (nfssvc(NFSSVC_NFSD, &nsd) == -1) {
|
|
||||||
syslog(LOG_ERR, "nfssvc: %s", strerror(errno));
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we are serving udp, set up the socket. */
|
|
||||||
if (udpflag) {
|
|
||||||
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
|
|
||||||
syslog(LOG_ERR, "can't create udp socket");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
memset(&inetaddr, 0, sizeof inetaddr);
|
|
||||||
inetaddr.sin_family = AF_INET;
|
|
||||||
inetaddr.sin_addr.s_addr = INADDR_ANY;
|
|
||||||
inetaddr.sin_port = htons(NFS_PORT);
|
|
||||||
inetaddr.sin_len = sizeof(inetaddr);
|
|
||||||
if (bind(sock, (struct sockaddr *)&inetaddr,
|
|
||||||
sizeof(inetaddr)) == -1) {
|
|
||||||
syslog(LOG_ERR, "can't bind udp addr");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
if (!pmap_set(RPCPROG_NFS, 2, IPPROTO_UDP, NFS_PORT) ||
|
|
||||||
!pmap_set(RPCPROG_NFS, 3, IPPROTO_UDP, NFS_PORT)) {
|
|
||||||
syslog(LOG_ERR, "can't register with udp portmap");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
nfsdargs.sock = sock;
|
|
||||||
nfsdargs.name = NULL;
|
|
||||||
nfsdargs.namelen = 0;
|
|
||||||
if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) == -1) {
|
|
||||||
syslog(LOG_ERR, "can't Add UDP socket");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
(void)close(sock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now set up the master server socket waiting for tcp connections. */
|
|
||||||
on = 1;
|
|
||||||
if (!tcpflag)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
|
||||||
syslog(LOG_ERR, "can't create tcp socket");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
if (setsockopt(tcpsock,
|
|
||||||
SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1)
|
|
||||||
syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %s", strerror(errno));
|
|
||||||
memset(&inetaddr, 0, sizeof inetaddr);
|
|
||||||
inetaddr.sin_family = AF_INET;
|
|
||||||
inetaddr.sin_addr.s_addr = INADDR_ANY;
|
|
||||||
inetaddr.sin_port = htons(NFS_PORT);
|
|
||||||
inetaddr.sin_len = sizeof(inetaddr);
|
|
||||||
if (bind(tcpsock, (struct sockaddr *)&inetaddr,
|
|
||||||
sizeof (inetaddr)) == -1) {
|
|
||||||
syslog(LOG_ERR, "can't bind tcp addr");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
if (listen(tcpsock, 5) == -1) {
|
|
||||||
syslog(LOG_ERR, "listen failed");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
if (!pmap_set(RPCPROG_NFS, 2, IPPROTO_TCP, NFS_PORT) ||
|
|
||||||
!pmap_set(RPCPROG_NFS, 3, IPPROTO_TCP, NFS_PORT)) {
|
|
||||||
syslog(LOG_ERR, "can't register tcp with portmap");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
setproctitle("master");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Loop forever accepting connections and passing the sockets
|
|
||||||
* into the kernel for the mounts.
|
|
||||||
*/
|
|
||||||
for (;;) {
|
|
||||||
struct sockaddr_in inetpeer;
|
|
||||||
int ret, msgsock;
|
|
||||||
socklen_t len = sizeof(inetpeer);
|
|
||||||
|
|
||||||
if ((msgsock = accept(tcpsock,
|
|
||||||
(struct sockaddr *)&inetpeer, &len)) == -1) {
|
|
||||||
if (errno == EWOULDBLOCK || errno == EINTR ||
|
|
||||||
errno == ECONNABORTED)
|
|
||||||
continue;
|
|
||||||
syslog(LOG_ERR, "accept failed: %s", strerror(errno));
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
memset(inetpeer.sin_zero, 0, sizeof(inetpeer.sin_zero));
|
|
||||||
if (setsockopt(msgsock, SOL_SOCKET,
|
|
||||||
SO_KEEPALIVE, &on, sizeof(on)) == -1)
|
|
||||||
syslog(LOG_ERR,
|
|
||||||
"setsockopt SO_KEEPALIVE: %s", strerror(errno));
|
|
||||||
nfsdargs.sock = msgsock;
|
|
||||||
nfsdargs.name = (caddr_t)&inetpeer;
|
|
||||||
nfsdargs.namelen = len;
|
|
||||||
if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) == -1) {
|
|
||||||
syslog(LOG_ERR, "can't Add TCP socket");
|
|
||||||
}
|
|
||||||
(void)close(msgsock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
usage(void)
|
|
||||||
{
|
|
||||||
(void)fprintf(stderr, "usage: nfsd [-rtu] [-n num_servers]\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nonfs(int signo)
|
|
||||||
{
|
|
||||||
int save_errno = errno;
|
|
||||||
struct syslog_data sdata = SYSLOG_DATA_INIT;
|
|
||||||
|
|
||||||
syslog_r(LOG_ERR, &sdata, "missing system call: NFS not available.");
|
|
||||||
errno = save_errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
reapchild(int signo)
|
|
||||||
{
|
|
||||||
int save_errno = errno;
|
|
||||||
|
|
||||||
while (wait3(NULL, WNOHANG, NULL) > 0)
|
|
||||||
continue;
|
|
||||||
errno = save_errno;
|
|
||||||
}
|
|
|
@ -18,7 +18,7 @@ SUBDIR= apply arch at aucat audioctl awk banner \
|
||||||
m4 mail make mandoc mesg mg \
|
m4 mail make mandoc mesg mg \
|
||||||
midicat mixerctl mkdep mklocale mktemp nc netstat \
|
midicat mixerctl mkdep mklocale mktemp nc netstat \
|
||||||
newsyslog \
|
newsyslog \
|
||||||
nfsstat nice nm nl nohup openssl pagesize passwd paste patch pctr \
|
nice nm nl nohup openssl pagesize passwd paste patch pctr \
|
||||||
pkg-config pkill \
|
pkg-config pkill \
|
||||||
pr printenv printf quota radioctl rcs rdist rdistd \
|
pr printenv printf quota radioctl rcs rdist rdistd \
|
||||||
readlink realpath renice rev rpcgen rpcinfo rs rsync rup rusers rwall \
|
readlink realpath renice rev rpcgen rpcinfo rs rsync rup rusers rwall \
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
# $OpenBSD: Makefile,v 1.6 2004/12/14 23:07:12 pedro Exp $
|
|
||||||
|
|
||||||
PROG= nfsstat
|
|
||||||
DPADD= ${LIBKVM}
|
|
||||||
LDADD= -lkvm
|
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
|
|
@ -1,99 +0,0 @@
|
||||||
.\" $OpenBSD: nfsstat.1,v 1.19 2022/07/30 07:19:31 jsg Exp $
|
|
||||||
.\" $NetBSD: nfsstat.1,v 1.8 1996/03/03 17:21:28 thorpej Exp $
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 1989, 1990, 1993
|
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\" 3. Neither the name of the University nor the names of its contributors
|
|
||||||
.\" may be used to endorse or promote products derived from this software
|
|
||||||
.\" without specific prior written permission.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
.\" SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.\" from: @(#)nfsstat.1 8.1 (Berkeley) 6/6/93
|
|
||||||
.\"
|
|
||||||
.Dd $Mdocdate: July 30 2022 $
|
|
||||||
.Dt NFSSTAT 1
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm nfsstat
|
|
||||||
.Nd display NFS statistics
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.Nm nfsstat
|
|
||||||
.Op Fl cs
|
|
||||||
.Op Fl M Ar core
|
|
||||||
.Op Fl N Ar system
|
|
||||||
.Op Fl w Ar wait
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
.Nm
|
|
||||||
displays statistics kept about NFS client and server activity.
|
|
||||||
If neither
|
|
||||||
.Fl M
|
|
||||||
nor
|
|
||||||
.Fl N
|
|
||||||
option was specified, statistics will be obtained from the running system
|
|
||||||
by calling
|
|
||||||
.Xr sysctl 2 .
|
|
||||||
Otherwise the specified core and system will be used to fetch
|
|
||||||
data by means of
|
|
||||||
.Xr kvm 3 .
|
|
||||||
.Pp
|
|
||||||
The options are as follows:
|
|
||||||
.Bl -tag -width Ds
|
|
||||||
.It Fl c
|
|
||||||
Display client statistics only.
|
|
||||||
.It Fl M Ar core
|
|
||||||
Extract values associated with the name list from the specified core
|
|
||||||
instead of the default
|
|
||||||
.Pa /dev/kmem .
|
|
||||||
.It Fl N Ar system
|
|
||||||
Extract the name list from the specified system instead of the default
|
|
||||||
.Pa /bsd .
|
|
||||||
.It Fl s
|
|
||||||
Display server statistics only.
|
|
||||||
.It Fl w Ar wait
|
|
||||||
Display a shorter summary of NFS
|
|
||||||
activity for both the client and server at
|
|
||||||
.Ar wait
|
|
||||||
second intervals.
|
|
||||||
.El
|
|
||||||
.Sh FILES
|
|
||||||
.Bl -tag -width /dev/kmem -compact
|
|
||||||
.It Pa /bsd
|
|
||||||
default kernel namelist
|
|
||||||
.It Pa /dev/kmem
|
|
||||||
default memory file
|
|
||||||
.El
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr fstat 1 ,
|
|
||||||
.Xr netstat 1 ,
|
|
||||||
.Xr ps 1 ,
|
|
||||||
.Xr systat 1 ,
|
|
||||||
.Xr sysctl 2 ,
|
|
||||||
.Xr kvm 3 ,
|
|
||||||
.Xr iostat 8 ,
|
|
||||||
.Xr pstat 8 ,
|
|
||||||
.Xr vmstat 8
|
|
||||||
.Sh HISTORY
|
|
||||||
The
|
|
||||||
.Nm
|
|
||||||
command appeared in
|
|
||||||
.Bx 4.3 Reno .
|
|
|
@ -1,431 +0,0 @@
|
||||||
/* $OpenBSD: nfsstat.c,v 1.38 2023/03/08 04:43:12 guenther Exp $ */
|
|
||||||
/* $NetBSD: nfsstat.c,v 1.7 1996/03/03 17:21:30 thorpej Exp $ */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1983, 1989, 1993
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to Berkeley by
|
|
||||||
* Rick Macklem at The University of Guelph.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <nfs/rpcv2.h>
|
|
||||||
#include <nfs/nfsproto.h>
|
|
||||||
#include <nfs/nfs.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <kvm.h>
|
|
||||||
#include <nlist.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <paths.h>
|
|
||||||
#include <err.h>
|
|
||||||
|
|
||||||
#define SHOW_SERVER 0x01
|
|
||||||
#define SHOW_CLIENT 0x02
|
|
||||||
#define SHOW_ALL (SHOW_SERVER | SHOW_CLIENT)
|
|
||||||
|
|
||||||
struct nlist nl[] = {
|
|
||||||
#define N_NFSSTAT 0
|
|
||||||
{ "_nfsstats" },
|
|
||||||
{ "" },
|
|
||||||
};
|
|
||||||
kvm_t *kd;
|
|
||||||
volatile sig_atomic_t signalled; /* set if alarm goes off "early" */
|
|
||||||
int nfs_id;
|
|
||||||
|
|
||||||
void getnfsstats(struct nfsstats *);
|
|
||||||
void printhdr(void);
|
|
||||||
void intpr(u_int);
|
|
||||||
void sidewaysintpr(u_int, u_int);
|
|
||||||
void usage(void);
|
|
||||||
void catchalarm(int);
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
u_int interval, display = SHOW_ALL;
|
|
||||||
extern int optind;
|
|
||||||
extern char *optarg;
|
|
||||||
char *memf, *nlistf;
|
|
||||||
const char *errstr;
|
|
||||||
int ch;
|
|
||||||
|
|
||||||
interval = 0;
|
|
||||||
memf = nlistf = NULL;
|
|
||||||
while ((ch = getopt(argc, argv, "cM:N:sw:")) != -1)
|
|
||||||
switch(ch) {
|
|
||||||
case 'M':
|
|
||||||
memf = optarg;
|
|
||||||
break;
|
|
||||||
case 'N':
|
|
||||||
nlistf = optarg;
|
|
||||||
break;
|
|
||||||
case 'w':
|
|
||||||
interval = (u_int)strtonum(optarg, 0, 1000, &errstr);
|
|
||||||
if (errstr)
|
|
||||||
errx(1, "invalid interval %s: %s",
|
|
||||||
optarg, errstr);
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
display = SHOW_SERVER;
|
|
||||||
break;
|
|
||||||
case 'c':
|
|
||||||
display = SHOW_CLIENT;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
if (argc) {
|
|
||||||
interval = (u_int)strtonum(*argv, 0, 1000, &errstr);
|
|
||||||
if (errstr)
|
|
||||||
errx(1, "invalid interval %s: %s", *argv, errstr);
|
|
||||||
++argv;
|
|
||||||
--argc;
|
|
||||||
}
|
|
||||||
if (nlistf || memf) {
|
|
||||||
char errbuf[_POSIX2_LINE_MAX];
|
|
||||||
|
|
||||||
if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf)) == 0)
|
|
||||||
errx(1, "nfsstat: %s", errbuf);
|
|
||||||
if (kvm_nlist(kd, nl) != 0)
|
|
||||||
errx(1, "kvm_nlist: can't get names");
|
|
||||||
} else {
|
|
||||||
int mib[4];
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
mib[0] = CTL_VFS;
|
|
||||||
mib[1] = VFS_GENERIC;
|
|
||||||
mib[2] = VFS_MAXTYPENUM;
|
|
||||||
len = sizeof(nfs_id);
|
|
||||||
if (sysctl(mib, 3, &nfs_id, &len, NULL, 0))
|
|
||||||
err(1, "sysctl: VFS_MAXTYPENUM");
|
|
||||||
|
|
||||||
for (; nfs_id; nfs_id--) {
|
|
||||||
struct vfsconf vfsc;
|
|
||||||
|
|
||||||
mib[0] = CTL_VFS;
|
|
||||||
mib[1] = VFS_GENERIC;
|
|
||||||
mib[2] = VFS_CONF;
|
|
||||||
mib[3] = nfs_id;
|
|
||||||
|
|
||||||
len = sizeof(vfsc);
|
|
||||||
if (sysctl(mib, 4, &vfsc, &len, NULL, 0))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!strcmp(vfsc.vfc_name, MOUNT_NFS))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (nfs_id == 0)
|
|
||||||
errx(1, "cannot find nfs filesystem id");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (interval)
|
|
||||||
sidewaysintpr(interval, display);
|
|
||||||
else
|
|
||||||
intpr(display);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
getnfsstats(struct nfsstats *p)
|
|
||||||
{
|
|
||||||
if (kd) {
|
|
||||||
if (kvm_read(kd, nl[N_NFSSTAT].n_value, p, sizeof(*p)) != sizeof(*p))
|
|
||||||
errx(1, "kvm_read failed");
|
|
||||||
} else {
|
|
||||||
int mib[3];
|
|
||||||
size_t len = sizeof(*p);
|
|
||||||
|
|
||||||
mib[0] = CTL_VFS;
|
|
||||||
mib[1] = nfs_id; /* 2 */
|
|
||||||
mib[2] = NFS_NFSSTATS;
|
|
||||||
|
|
||||||
if (sysctl(mib, 3, p, &len, NULL, 0))
|
|
||||||
err(1, "sysctl");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Print a description of the nfs stats.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
intpr(u_int display)
|
|
||||||
{
|
|
||||||
struct nfsstats nfsstats;
|
|
||||||
|
|
||||||
getnfsstats(&nfsstats);
|
|
||||||
|
|
||||||
if (display & SHOW_CLIENT) {
|
|
||||||
printf("Client Info:\n");
|
|
||||||
printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
|
|
||||||
"Getattr", "Setattr", "Lookup", "Readlink", "Read",
|
|
||||||
"Write", "Create", "Remove");
|
|
||||||
printf("%9llu %9llu %9llu %9llu %9llu %9llu %9llu %9llu\n",
|
|
||||||
nfsstats.rpccnt[NFSPROC_GETATTR],
|
|
||||||
nfsstats.rpccnt[NFSPROC_SETATTR],
|
|
||||||
nfsstats.rpccnt[NFSPROC_LOOKUP],
|
|
||||||
nfsstats.rpccnt[NFSPROC_READLINK],
|
|
||||||
nfsstats.rpccnt[NFSPROC_READ],
|
|
||||||
nfsstats.rpccnt[NFSPROC_WRITE],
|
|
||||||
nfsstats.rpccnt[NFSPROC_CREATE],
|
|
||||||
nfsstats.rpccnt[NFSPROC_REMOVE]);
|
|
||||||
printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
|
|
||||||
"Rename", "Link", "Symlink", "Mkdir", "Rmdir",
|
|
||||||
"Readdir", "RdirPlus", "Access");
|
|
||||||
printf("%9llu %9llu %9llu %9llu %9llu %9llu %9llu %9llu\n",
|
|
||||||
nfsstats.rpccnt[NFSPROC_RENAME],
|
|
||||||
nfsstats.rpccnt[NFSPROC_LINK],
|
|
||||||
nfsstats.rpccnt[NFSPROC_SYMLINK],
|
|
||||||
nfsstats.rpccnt[NFSPROC_MKDIR],
|
|
||||||
nfsstats.rpccnt[NFSPROC_RMDIR],
|
|
||||||
nfsstats.rpccnt[NFSPROC_READDIR],
|
|
||||||
nfsstats.rpccnt[NFSPROC_READDIRPLUS],
|
|
||||||
nfsstats.rpccnt[NFSPROC_ACCESS]);
|
|
||||||
printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
|
|
||||||
"Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit");
|
|
||||||
printf("%9llu %9llu %9llu %9llu %9llu\n",
|
|
||||||
nfsstats.rpccnt[NFSPROC_MKNOD],
|
|
||||||
nfsstats.rpccnt[NFSPROC_FSSTAT],
|
|
||||||
nfsstats.rpccnt[NFSPROC_FSINFO],
|
|
||||||
nfsstats.rpccnt[NFSPROC_PATHCONF],
|
|
||||||
nfsstats.rpccnt[NFSPROC_COMMIT]);
|
|
||||||
printf("Rpc Info:\n");
|
|
||||||
printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
|
|
||||||
"TimedOut", "Invalid", "X Replies", "Retries", "Requests",
|
|
||||||
"FrcSync");
|
|
||||||
printf("%9llu %9llu %9llu %9llu %9llu %9llu\n",
|
|
||||||
nfsstats.rpctimeouts,
|
|
||||||
nfsstats.rpcinvalid,
|
|
||||||
nfsstats.rpcunexpected,
|
|
||||||
nfsstats.rpcretries,
|
|
||||||
nfsstats.rpcrequests,
|
|
||||||
nfsstats.forcedsync);
|
|
||||||
printf("Cache Info:\n");
|
|
||||||
printf("%9.9s %9.9s %9.9s %9.9s",
|
|
||||||
"Attr Hits", "Misses", "Lkup Hits", "Misses");
|
|
||||||
printf(" %9.9s %9.9s %9.9s %9.9s\n",
|
|
||||||
"BioR Hits", "Misses", "BioW Hits", "Misses");
|
|
||||||
printf("%9llu %9llu %9llu %9llu",
|
|
||||||
nfsstats.attrcache_hits, nfsstats.attrcache_misses,
|
|
||||||
nfsstats.lookupcache_hits, nfsstats.lookupcache_misses);
|
|
||||||
printf(" %9llu %9llu %9llu %9llu\n",
|
|
||||||
nfsstats.biocache_reads-nfsstats.read_bios,
|
|
||||||
nfsstats.read_bios,
|
|
||||||
nfsstats.biocache_writes-nfsstats.write_bios,
|
|
||||||
nfsstats.write_bios);
|
|
||||||
printf("%9.9s %9.9s %9.9s %9.9s",
|
|
||||||
"BioRLHits", "Misses", "BioD Hits", "Misses");
|
|
||||||
printf(" %9.9s %9.9s\n", "DirE Hits", "Misses");
|
|
||||||
printf("%9llu %9llu %9llu %9llu",
|
|
||||||
nfsstats.biocache_readlinks-nfsstats.readlink_bios,
|
|
||||||
nfsstats.readlink_bios,
|
|
||||||
nfsstats.biocache_readdirs-nfsstats.readdir_bios,
|
|
||||||
nfsstats.readdir_bios);
|
|
||||||
printf(" %9llu %9llu\n",
|
|
||||||
nfsstats.direofcache_hits, nfsstats.direofcache_misses);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (display == SHOW_ALL)
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
if (display & SHOW_SERVER) {
|
|
||||||
printf("Server Info:\n");
|
|
||||||
printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
|
|
||||||
"Getattr", "Setattr", "Lookup", "Readlink", "Read",
|
|
||||||
"Write", "Create", "Remove");
|
|
||||||
printf("%9llu %9llu %9llu %9llu %9llu %9llu %9llu %9llu\n",
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_GETATTR],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_SETATTR],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_LOOKUP],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_READLINK],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_READ],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_WRITE],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_CREATE],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_REMOVE]);
|
|
||||||
printf("%9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s\n",
|
|
||||||
"Rename", "Link", "Symlink", "Mkdir", "Rmdir",
|
|
||||||
"Readdir", "RdirPlus", "Access");
|
|
||||||
printf("%9llu %9llu %9llu %9llu %9llu %9llu %9llu %9llu\n",
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_RENAME],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_LINK],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_SYMLINK],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_MKDIR],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_RMDIR],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_READDIR],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_READDIRPLUS],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_ACCESS]);
|
|
||||||
printf("%9.9s %9.9s %9.9s %9.9s %9.9s\n",
|
|
||||||
"Mknod", "Fsstat", "Fsinfo", "PathConf", "Commit");
|
|
||||||
printf("%9llu %9llu %9llu %9llu %9llu\n",
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_MKNOD],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_FSSTAT],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_FSINFO],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_PATHCONF],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_COMMIT]);
|
|
||||||
printf("Server Ret-Failed\n");
|
|
||||||
printf("%17llu\n", nfsstats.srvrpc_errs);
|
|
||||||
printf("Server Faults\n");
|
|
||||||
printf("%13llu\n", nfsstats.srv_errs);
|
|
||||||
printf("Server Cache Stats:\n");
|
|
||||||
printf("%9.9s %9.9s %9.9s %9.9s\n",
|
|
||||||
"Inprog", "Idem", "Non-idem", "Misses");
|
|
||||||
printf("%9llu %9llu %9llu %9llu\n",
|
|
||||||
nfsstats.srvcache_inproghits,
|
|
||||||
nfsstats.srvcache_idemdonehits,
|
|
||||||
nfsstats.srvcache_nonidemdonehits,
|
|
||||||
nfsstats.srvcache_misses);
|
|
||||||
printf("Server Write Gathering:\n");
|
|
||||||
printf("%9.9s %9.9s %9.9s\n",
|
|
||||||
"WriteOps", "WriteRPC", "Opsaved");
|
|
||||||
printf("%9llu %9llu %9llu\n",
|
|
||||||
nfsstats.srvvop_writes,
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_WRITE],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_WRITE] - nfsstats.srvvop_writes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Print a running summary of nfs statistics.
|
|
||||||
* Repeat display every interval seconds, showing statistics
|
|
||||||
* collected over that interval. Assumes that interval is non-zero.
|
|
||||||
* First line printed at top of screen is always cumulative.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
sidewaysintpr(u_int interval, u_int display)
|
|
||||||
{
|
|
||||||
struct nfsstats nfsstats, lastst;
|
|
||||||
int hdrcnt;
|
|
||||||
sigset_t emptyset;
|
|
||||||
|
|
||||||
(void)signal(SIGALRM, catchalarm);
|
|
||||||
signalled = 0;
|
|
||||||
(void)alarm(interval);
|
|
||||||
bzero(&lastst, sizeof(lastst));
|
|
||||||
|
|
||||||
for (hdrcnt = 1;;) {
|
|
||||||
if (!--hdrcnt) {
|
|
||||||
printhdr();
|
|
||||||
hdrcnt = 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
getnfsstats(&nfsstats);
|
|
||||||
|
|
||||||
if (display & SHOW_CLIENT)
|
|
||||||
printf("Client: "
|
|
||||||
"%8llu %8llu %8llu %8llu %8llu %8llu %8llu %8llu\n",
|
|
||||||
nfsstats.rpccnt[NFSPROC_GETATTR] -
|
|
||||||
lastst.rpccnt[NFSPROC_GETATTR],
|
|
||||||
nfsstats.rpccnt[NFSPROC_LOOKUP] -
|
|
||||||
lastst.rpccnt[NFSPROC_LOOKUP],
|
|
||||||
nfsstats.rpccnt[NFSPROC_READLINK] -
|
|
||||||
lastst.rpccnt[NFSPROC_READLINK],
|
|
||||||
nfsstats.rpccnt[NFSPROC_READ] -
|
|
||||||
lastst.rpccnt[NFSPROC_READ],
|
|
||||||
nfsstats.rpccnt[NFSPROC_WRITE] -
|
|
||||||
lastst.rpccnt[NFSPROC_WRITE],
|
|
||||||
nfsstats.rpccnt[NFSPROC_RENAME] -
|
|
||||||
lastst.rpccnt[NFSPROC_RENAME],
|
|
||||||
nfsstats.rpccnt[NFSPROC_ACCESS] -
|
|
||||||
lastst.rpccnt[NFSPROC_ACCESS],
|
|
||||||
(nfsstats.rpccnt[NFSPROC_READDIR] -
|
|
||||||
lastst.rpccnt[NFSPROC_READDIR]) +
|
|
||||||
(nfsstats.rpccnt[NFSPROC_READDIRPLUS] -
|
|
||||||
lastst.rpccnt[NFSPROC_READDIRPLUS]));
|
|
||||||
if (display & SHOW_SERVER)
|
|
||||||
printf("Server: "
|
|
||||||
"%8llu %8llu %8llu %8llu %8llu %8llu %8llu %8llu\n",
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_GETATTR] -
|
|
||||||
lastst.srvrpccnt[NFSPROC_GETATTR],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_LOOKUP] -
|
|
||||||
lastst.srvrpccnt[NFSPROC_LOOKUP],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_READLINK] -
|
|
||||||
lastst.srvrpccnt[NFSPROC_READLINK],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_READ] -
|
|
||||||
lastst.srvrpccnt[NFSPROC_READ],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_WRITE] -
|
|
||||||
lastst.srvrpccnt[NFSPROC_WRITE],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_RENAME] -
|
|
||||||
lastst.srvrpccnt[NFSPROC_RENAME],
|
|
||||||
nfsstats.srvrpccnt[NFSPROC_ACCESS] -
|
|
||||||
lastst.srvrpccnt[NFSPROC_ACCESS],
|
|
||||||
(nfsstats.srvrpccnt[NFSPROC_READDIR] -
|
|
||||||
lastst.srvrpccnt[NFSPROC_READDIR]) +
|
|
||||||
(nfsstats.srvrpccnt[NFSPROC_READDIRPLUS] -
|
|
||||||
lastst.srvrpccnt[NFSPROC_READDIRPLUS]));
|
|
||||||
lastst = nfsstats;
|
|
||||||
fflush(stdout);
|
|
||||||
sigemptyset(&emptyset);
|
|
||||||
if (!signalled)
|
|
||||||
sigsuspend(&emptyset);
|
|
||||||
signalled = 0;
|
|
||||||
(void)alarm(interval);
|
|
||||||
}
|
|
||||||
/*NOTREACHED*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
printhdr(void)
|
|
||||||
{
|
|
||||||
printf(" %8.8s %8.8s %8.8s %8.8s %8.8s %8.8s %8.8s %8.8s\n",
|
|
||||||
"Getattr", "Lookup", "Readlink", "Read", "Write", "Rename",
|
|
||||||
"Access", "Readdir");
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Called if an interval expires before sidewaysintpr has completed a loop.
|
|
||||||
* Sets a flag to not wait for the alarm.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
catchalarm(int signo)
|
|
||||||
{
|
|
||||||
signalled = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
usage(void)
|
|
||||||
{
|
|
||||||
extern char *__progname;
|
|
||||||
|
|
||||||
fprintf(stderr, "usage: %s [-cs] [-M core] [-N system] [-w wait]\n",
|
|
||||||
__progname);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue