NFSSVC(2)
π NFSSVC(2) π the NFS services system call, bestie
okay so real talk, this is page 2 of the System Calls Manual, she's named nfssvc, and she is the NFS services girlie. no cap. π¦
β¨ NAME β¨
nfssvc β NFS services. that's it, that's the whole name. π
π LIBRARY π
Standard C Library (libc, -lc). yes bestie, she lives in libc.
πΈ SYNOPSIS πΈ
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/time.h>
#include <nfs/rpcv2.h>
#include <nfsserver/nfs.h>
#include <unistd.h>
int
nfssvc(int flags, void *argstructp);
π« DESCRIPTION π«
okay so here's the vibe: the nfssvc() system call is what the NFS daemons use to pass information into and out of the kernel, and also to enter the kernel as a server daemon. main character energy, fr.
The flags argument is a handful of bits that say what action gets taken once you're in the kernel, and argstructp points to one of three structures depending on which of those bits are set in flags. three!! choices!! the range!!
π§ client side π§
On the client side, nfsiod(8) calls nfssvc() with the flags argument set to NFSSVC_BIOD and argstructp set to NULL, to enter the kernel as a block I/O server daemon. iconic.
For NQNFS, mount_nfs(8) calls nfssvc() with the NFSSVC_MNTD flag, optionally or'd with the flags NFSSVC_GOTAUTH and NFSSVC_AUTHINFAIL, along with a pointer to a:
struct nfsd_cargs {
char *ncd_dirp; /* Mount dir path */
uid_t ncd_authuid; /* Effective uid */
int ncd_authtype; /* Type of authenticator */
int ncd_authlen; /* Length of authenticator string */
u_char *ncd_authstr; /* Authenticator string */
int ncd_verflen; /* and the verifier */
u_char *ncd_verfstr;
NFSKERBKEY_T ncd_key; /* Session key */
};
structure. π The initial call has only the NFSSVC_MNTD flag set, to specify service for the mount point. Now β if the mount point is using Kerberos, then mount_nfs(8) will return from nfssvc() with errno == ENEEDAUTH whenever the client side requires an ``rcmd'' authentication ticket for the user. Then mount_nfs(8) will attempt to get the Kerberos ticket, and if it succeeds it calls nfssvc() with the flags NFSSVC_MNTD and NFSSVC_GOTAUTH after filling the ticket into the ncd_authstr field and setting the ncd_authlen and ncd_authtype fields of the nfsd_cargs structure. And if mount_nfs(8) failed to get that ticket? then nfssvc() gets called with the flags NFSSVC_MNTD, NFSSVC_GOTAUTH and NFSSVC_AUTHINFAIL to denote a failed authentication attempt. sad girl hours, truly π
π server side π
On the server side, nfssvc() is called with the flag NFSSVC_NFSD and a pointer to a:
struct nfsd_srvargs {
struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
uid_t nsd_uid; /* Effective uid mapped to cred */
uint32_t nsd_haddr; /* Ip address of client */
struct ucred nsd_cr; /* Cred. uid maps to */
int nsd_authlen; /* Length of auth string (ret) */
u_char *nsd_authstr; /* Auth string (ret) */
int nsd_verflen; /* and the verifier */
u_char *nsd_verfstr;
struct timeval nsd_timestamp; /* timestamp from verifier */
uint32_t nsd_ttl; /* credential ttl (sec) */
NFSKERBKEY_T nsd_key; /* Session key */
};
to enter the kernel as an nfsd(8) daemon. So whenever an nfsd(8) daemon receives a Kerberos authentication ticket, it returns from nfssvc() with errno == ENEEDAUTH. Then nfsd(8) will attempt to authenticate that ticket and generate a set of credentials on the server for the ``user id'' specified in the field nsd_uid. how, you ask? first authenticate the Kerberos ticket, then map the Kerberos principal to a local name, then get a set of credentials for that user via getpwnam(3) and getgrouplist(3). that's the pipeline bestie. If all of that succeeds, nfsd(8) calls nfssvc() with the NFSSVC_NFSD and NFSSVC_AUTHIN flags set, to pass the credential mapping in nsd_cr into the kernel so it gets cached on the server socket for that client. And if the authentication failed, nfsd(8) calls nfssvc() with the flags NFSSVC_NFSD and NFSSVC_AUTHINFAIL to denote an authentication failure. periodt.
The master nfsd(8) server daemon calls nfssvc() with the flag NFSSVC_ADDSOCK and a pointer to a:
struct nfsd_args {
int sock; /* Socket to serve */
caddr_t name; /* Client address for connection based sockets */
int namelen;/* Length of name */
};
to pass a server side NFS socket into the kernel for servicing by the nfsd(8) daemons. slay. π
π«Ά RETURN VALUES π«Ά
Normally nfssvc() does not return β unless the server is terminated by a signal, and in that case a value of 0 is returned. Otherwise, -1 is returned and the global variable errno is set to specify the error. yeah, that's the deal.
π ERRORS π
[ENEEDAUTH]β this special error value is really used for authentication support, particularly Kerberos, as explained up above. it's giving "not actually an error, bestie".[EPERM]β the caller is not the super-user. π« sorry girl.
π₯ SEE ALSO π₯
mount_nfs(8), nfsd(8), nfsiod(8)
π HISTORY π
The nfssvc() system call first appeared in 4.4BSD. a legend was born and we are simply living in her legacy. β¨
π BUGS π
The nfssvc() system call is designed specifically for the NFS support daemons and as such is specific to their requirements. It should really return values to indicate the need for authentication support, since ENEEDAUTH is not really an error. Several fields of the argument structures are assumed to be valid and sometimes to be unchanged from a previous call, such that nfssvc() must be used with extreme care.
bestie. EXTREME. CARE. π₯ this is not a drill β those fields are assumed valid, and sometimes assumed unchanged from a previous call, and that is exactly the kind of thing that will ruin your entire week. treat her with respect. π
and that's the page!! π this one came from the Debian crew and she's dated June 9, 1993, so she is an elder icon and we stan her forever. stay safe out there with your nfssvc() calls, mwah ππ
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1989, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms