xref: /openbsd/lib/libc/sys/nfssvc.2 (revision 91f110e0)
1.\"	$OpenBSD: nfssvc.2,v 1.21 2014/03/24 01:54:58 guenther Exp $
2.\"	$NetBSD: nfssvc.2,v 1.6 1995/02/27 12:35:08 cgd Exp $
3.\"
4.\" Copyright (c) 1989, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"	@(#)nfssvc.2	8.1 (Berkeley) 6/9/93
32.\"
33.Dd $Mdocdate: March 24 2014 $
34.Dt NFSSVC 2
35.Os
36.Sh NAME
37.Nm nfssvc
38.Nd NFS services
39.Sh SYNOPSIS
40.Fd #include <unistd.h>
41.Fd #include <nfs/nfs.h>
42.Ft int
43.Fn nfssvc "int flags" "void *argstructp"
44.Sh DESCRIPTION
45The
46.Fn nfssvc
47function is used by NFS daemons to pass information into the kernel
48and also to enter the kernel as a server daemon.
49The
50.Fa flags
51argument consists of several bits that show what action is to be taken
52once in the kernel and the
53.Fa argstructp
54points to one of two structures depending on which bits are set in
55flags.
56.Pp
57To enter an
58.Xr nfsd 8
59daemon into the kernel,
60.Fn nfssvc
61is called with the flag
62.Dv NFSSVC_NFSD
63and a pointer to a structure:
64.Bd -literal
65struct nfsd_srvargs {
66        struct nfsd     *nsd_nfsd;   /* Pointer to in kernel nfsd struct */
67        uid_t           nsd_uid;        /* Effective uid mapped to cred */
68        u_int32_t       nsd_haddr;      /* IP address of client */
69        struct xucred   nsd_cr;         /* Cred. uid maps to */
70        int             nsd_authlen;    /* Length of auth string (ret) */
71        u_char          *nsd_authstr;   /* Auth string (ret) */
72        int             nsd_verflen;    /* and the verifier */
73        u_char          *nsd_verfstr;
74        struct timeval  nsd_timestamp;  /* timestamp from verifier */
75        u_int32_t       nsd_ttl;        /* credential ttl (sec) */
76};
77.Ed
78.Pp
79To add further sockets for processing by the
80.Xr nfsd 8
81server daemons the master
82.Xr nfsd 8
83daemon  calls
84.Fn nfssvc
85with the flag
86.Dv NFSSVC_ADDSOCK
87and a pointer to a structure:
88.Bd -literal
89struct nfsd_args {
90        int     sock;     /* Socket to serve */
91        caddr_t name;     /* Client address for connection based sockets */
92        int     namelen;  /* Length of name */
93};
94.Ed
95.Sh RETURN VALUES
96Normally
97.Nm nfssvc
98does not return unless the server
99is terminated by a signal when a value of 0 is returned.
100Otherwise, \-1 is returned and the global variable
101.Va errno
102is set to specify the error.
103.Sh ERRORS
104.Bl -tag -width Er
105.It Bq Er EPERM
106The caller is not the superuser.
107.It Bq Er EINVAL
108The flag argument consisted of incompatible or otherwise
109unsupported bits.
110.El
111.Sh SEE ALSO
112.Xr mount_nfs 8 ,
113.Xr nfsd 8 ,
114.Xr sysctl 8
115.Sh HISTORY
116The
117.Nm nfssvc
118function first appeared in
119.Bx 4.4 .
120.Sh BUGS
121The
122.Nm nfssvc
123system call is designed specifically for the
124.Tn NFS
125support daemons and as such is specific to their requirements.
126Several fields of the argument structures are assumed to be valid and
127sometimes to be unchanged from a previous call, such that
128.Fn nfssvc
129must be used with extreme care.
130