99.13. nfs-utils-3.1.1
NFS client and server utilities
| Version | 3.1.1, release 1 |
| Shelf | filesystem — Filesystem utilities, FUSE, and network or encrypted filesystems |
| Phase | 41_system (System), 514 of 1047 in build order |
| Licence | GPL-2.0-or-later |
| Homepage | https://linux-nfs.org/ |
| Build time | 1.7 SBU |
| Installed size | 2.8 MiB in 87 files |
| Recipe | ports/core/filesystem/nfs-utils/kpkgbuild |
About
nfs-utils is the user-space half of NFS: mount.nfs, the helper mount -t nfs runs, for the client, and exportfs, rpc.nfsd and the daemons that serve exports from the kernel’s NFS server, plus the ID mapping and Kerberos pieces both sides use. Where samba is how KDOS talks to Windows machines and phones, NFS is how it shares files with another Unix machine with POSIX ownership, symbolic links and byte-range locks intact. The server is NFSv4 only. The recipe writes two boot services, 63_gssd and 72_nfsd, each of which skips itself until it has something to do (a Kerberos keytab, a share in /etc/exports); see Services. mount.nfs is setuid, so an ordinary user can mount a share listed in fstab.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/filesystem.txt:
samba is the INTEROPERABILITY answer (a Windows laptop, a phone or a printer speaks SMB and often nothing else); nfs-utils is the CORRECTNESS one — SMB does not carry POSIX ownership, symlinks or byte-range locks the way a Linux program expects. The v3 helpers are built and never started.
Sources
nfs-utils-3.1.1.tar.xz(756.2 KiB)
sha2567dbc05eb8b32828b322872b759a62cb3979cb4118f344dd8616813d1390e84e0
upstream: https://www.kernel.org/pub/linux/utils/nfs-utils/3.1.1/nfs-utils-3.1.1.tar.xz
archive copy: sources-2/filesystem--nfs-utils-3.1.1.tar.xz
Dependencies
Depends on: autoconf, automake, libtool, pkgconf, libtirpc, krb5, libcap, keyutils, libevent, sqlite, util-linux, libnl, readline, libxml2, openldap.
Required by: no port names it.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install nfs-utils'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/filesystem/nfs-utils.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/filesystem/nfs-utils
echo '7dbc05eb8b32828b322872b759a62cb3979cb4118f344dd8616813d1390e84e0 nfs-utils-3.1.1.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/nfs-utils
SRC=$SRC_ROOT/nfs-utils-3.1.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf nfs-utils-3.1.1.tar.xz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
autoreconf -f -i
export CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE -include stddef.h -include libgen.h -Wno-error=format"
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--libdir=/usr/lib \
--localstatedir=/var \
--enable-nfsv4 \
--enable-nfsv4server \
--enable-gss \
--disable-svcgss \
--enable-ipv6 \
--enable-caps \
--enable-uuid \
--enable-ldap \
--without-systemd \
--with-statedir=/var/lib/nfs \
--with-rpcgen=internal \
--disable-sbin-override
make
make DESTDIR=$PKG install
rm -f "$PKG/usr/share/man/man7/nfs.systemd.7" \
"$PKG/usr/bin/rpcgen" \
"$PKG/usr/share/man/man1/rpcgen.1" \
"$PKG/var/lib/nfs/state"
test -x "$PKG/usr/sbin/mount.nfs"
test ! -e "$PKG/sbin"
install -d "$PKG/etc/init.d"
cat > "$PKG/etc/init.d/72_nfsd.sh" <<'KDOS_SH'
#!/bin/bash
. /etc/init.d/service_helper
NAME="nfsd"
DAEMON="/usr/sbin/rpc.nfsd"
EXPORTFS="/usr/sbin/exportfs"
PIPEFS="/var/lib/nfs/rpc_pipefs"
case "$1" in
start)
[ ! -x "$DAEMON" ] && { echo "[SKIP] $NAME: $DAEMON not found"; exit 0; }
if ! grep -qEv '^[[:space:]]*(#|$)' /etc/exports 2>/dev/null; then
echo "[SKIP] $NAME: no share in /etc/exports"
exit 0
fi
echo "[KDOS] Starting $NAME..."
modprobe nfsd 2>/dev/null
grep -q " /proc/fs/nfsd nfsd " /proc/mounts || \
mount -t nfsd nfsd /proc/fs/nfsd
mkdir -p "$PIPEFS" /var/lib/nfs/nfsdcld
grep -q " $PIPEFS rpc_pipefs " /proc/mounts || \
mount -t rpc_pipefs sunrpc "$PIPEFS"
# -F and -f: each stays in the foreground for ksvc.
supervise nfsdcld /usr/sbin/nfsdcld -F
"$EXPORTFS" -r
supervise nfsv4.exportd /usr/sbin/nfsv4.exportd -f
"$DAEMON" -N 3 -V 4
;;
stop)
# Threads first, so no request arrives to an export being withdrawn.
"$DAEMON" 0 2>/dev/null
"$EXPORTFS" -ua 2>/dev/null
stop_service nfsv4.exportd
stop_service nfsdcld
;;
status)
check_status nfsv4.exportd
;;
*) echo "Usage: $0 {start|stop|status}"; exit 1 ;;
esac
KDOS_SH
chmod 755 "$PKG/etc/init.d/72_nfsd.sh"
cat > "$PKG/etc/init.d/63_gssd.sh" <<'KDOS_SH'
#!/bin/bash
. /etc/init.d/service_helper
NAME="gssd"
DAEMON="/usr/sbin/rpc.gssd"
PIPEFS="/var/lib/nfs/rpc_pipefs"
case "$1" in
start)
[ ! -x "$DAEMON" ] && { echo "[SKIP] $NAME: $DAEMON not found"; exit 0; }
if [ ! -s /etc/krb5.keytab ]; then
echo "[SKIP] $NAME: no /etc/krb5.keytab"
exit 0
fi
echo "[KDOS] Starting $NAME..."
# sunrpc registers rpc_pipefs; rpcsec_gss_krb5 is what the kernel
# asks for when a sec=krb5 mount arrives.
modprobe sunrpc 2>/dev/null
modprobe rpcsec_gss_krb5 2>/dev/null
mkdir -p "$PIPEFS"
grep -q " $PIPEFS rpc_pipefs " /proc/mounts || \
mount -t rpc_pipefs sunrpc "$PIPEFS"
# -f keeps it in the foreground for ksvc.
supervise "$NAME" "$DAEMON" -f
;;
stop) stop_service "$NAME" ;;
status) check_status "$NAME" ;;
*) echo "Usage: $0 {start|stop|status}"; exit 1 ;;
esac
KDOS_SH
chmod 755 "$PKG/etc/init.d/63_gssd.sh"
The switches, and why each is set:
-D_LARGEFILE64_SOURCE— Exposes musl’sstat64and the other*64names. The internalrpcgenthis build compiles callsstat64()onstruct stat64, which musl declares only under this macro.-include libgen.h— Includes<libgen.h>ahead of every source file.nfsdctl.ccallsbasename()without it, and musl declaresbasenameonly there; upstream builds with-Werror=implicit-function-declaration, so the call stops the build.-include stddef.h— Includes<stddef.h>ahead of every source file, sosize_t,NULLandoffsetofare declared in every file, whichever headers it includes.-Wno-error=format— Turns format-string errors back into warnings. Upstream’s configure adds-Werror=format=2to every compile.--enable-nfsv4— NFSv4 support, withrpc.idmapdandnfsidmapfor mapping names to IDs. Upstream’s default.--enable-nfsv4server— Buildnfsv4.exportd, the export daemon of an NFSv4-only server, which72_nfsdsupervises in place ofrpc.mountd. Off by upstream’s default.--enable-gss— Buildrpc.gssd, the client side of RPCSEC_GSS, which asec=krb5mount needs; linked against krb5. Upstream’s default.--disable-svcgss— Do not buildrpc.svcgssd, the server side of RPCSEC_GSS. Off is upstream’s default.--enable-ipv6— IPv6 transport for the client and server. Upstream’s default.--enable-caps— Link libcap intorpc.statd,sm-notify,nfsdcldandnfsref, which use it to drop capabilities they do not need. Named, the switch makes missing libcap headers a configure error.--enable-uuid— Use libblkid, from util-linux, to find an exported filesystem’s UUID for the export cache, and skip the version check that would otherwise turn the feature off for an old libblkid.--enable-ldap— Build theumich_ldapID-mapping plugin for libnfsidmap, against openldap. Named, the switch makes a missing LDAP library a configure error instead of a silent omission.--without-systemd— Install no systemd units; KDOS has no systemd. Off is also upstream’s default.--with-statedir=/var/lib/nfs— The state directory, whererpc_pipefsis mounted andnfsdcldkeeps its client records. This is upstream’s default, and both boot services mountrpc_pipefsunder the same path.--with-rpcgen=internal— Generate the RPC stubs with therpcgenin nfs-utils’ owntools/directory instead of a system one. Without it, configure looks forrpcgenin/usr/local/bin,/usr/binand/binand stops when it finds none, and the recipe does not depend on rpcsvc-proto, which provides it.--disable-sbin-override— Installmount.nfsand the other mount helpers into--sbindir(/usr/sbin) rather than forcing them into/sbin. On KDOS/sbinis a symbolic link tousr/sbin, and a package carrying a real/sbinwould collide with it; thetest ! -e "$PKG/sbin"line checks that none was written.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/nfs-utils, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf nfs-utils-3.1.1-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/nfs-utils, and runs the triggers its paths call for.
Contents
Installed programs: exportfs, fsidd, mount.nfs, mount.nfs4, mountstats, nfsconf, nfsdcld, nfsdclddb, nfsdclnts, nfsdctl, nfsidmap, nfsiostat, nfsref, nfsstat, nfsv4.exportd, rpc.gssd, rpc.idmapd, rpc.mountd, rpc.nfsd, rpc.statd, rpcctl, rpcdebug, showmount, sm-notify, start-statd, umount.nfs, umount.nfs4.
Installed libraries: libnfsidmap.a, libnfsidmap.so.
Installed directories: /usr/lib/libnfsidmap, /usr/share/licenses/nfs-utils, /var/lib/nfs.
Short descriptions
exportfs |
maintain table of exported NFS file systems |
mount.nfs |
mount a Network File System |
mountstats |
Displays various NFS client per-mount statistics |
nfsconf |
Query various NFS configuration settings |
nfsdcld |
NFSv4 Client Tracking Daemon |
nfsdclddb |
Tool for manipulating the nfsdcld sqlite database |
nfsdclnts |
print various nfs client information for knfsd server. |
nfsdctl |
control program for the Linux kernel NFS server |
nfsidmap |
The NFS idmapper upcall program |
nfsiostat |
Emulate iostat for NFS mount points using /proc/self/mountstats |
nfsref |
manage NFS referrals |
nfsstat |
list NFS statistics |
rpcctl |
Displays SunRPC connection information |
rpcdebug |
set and clear NFS and RPC kernel debug flags |
showmount |
show mount information for an NFS server |
sm-notify |
send reboot notifications to NFS peers |
umount.nfs |
unmount a Network File System |
libnfsidmap.pc |
Library that handles mapping between names and ids for NFSv4. |
Notes
make install also installs the internal rpcgen and its manual page. Both are deleted, because rpcsvc-proto owns /usr/bin/rpcgen and kpkg refuses a path another package owns. nfs.systemd.7, a manual page about the systemd units that is installed with or without them, is deleted too, and so is /var/lib/nfs/state, the empty file make install creates for the NSM state number: rpc.statd and sm-notify write that file themselves when it is missing, and in the package it would be a file kpkg owns that the daemons rewrite.
72_nfsd starts the server with rpc.nfsd -N 3 -V 4: NFSv3 is off, so no portmapper, rpc.mountd, rpc.statd or lock daemon is started, although the build installs them. It loads nfsd, mounts the nfsd and rpc_pipefs filesystems, supervises nfsdcld and nfsv4.exportd in the foreground (-F, -f) so the supervisor can restart them, and runs exportfs -r before starting the kernel threads. Stopping it stops the threads first, so no request arrives for an export that is being withdrawn.
nfsv4.exportd links only with optimisation on: exportd.c defines a C99 inline function with no external definition, which is an undefined reference at -O0.
autoreconf -f -i regenerates the release’s configure and Makefile.in with the tree’s autotools before configuring.