xref: /openbsd-src/lib/libc/sys/nfssvc.2 (revision d13be5d47e4149db2549a9828e244d59dbc43f15)
1.\"	$OpenBSD: nfssvc.2,v 1.20 2007/05/31 19:19:33 jmc 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: May 31 2007 $
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 ucred    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        NFSKERBKEY_T    nsd_key;        /* Session key */
77};
78.Ed
79.Pp
80To add further sockets for processing by the
81.Xr nfsd 8
82server daemons the master
83.Xr nfsd 8
84daemon  calls
85.Fn nfssvc
86with the flag
87.Dv NFSSVC_ADDSOCK
88and a pointer to a structure:
89.Bd -literal
90struct nfsd_args {
91        int     sock;     /* Socket to serve */
92        caddr_t name;     /* Client address for connection based sockets */
93        int     namelen;  /* Length of name */
94};
95.Ed
96.Sh RETURN VALUES
97Normally
98.Nm nfssvc
99does not return unless the server
100is terminated by a signal when a value of 0 is returned.
101Otherwise, \-1 is returned and the global variable
102.Va errno
103is set to specify the error.
104.Sh ERRORS
105.Bl -tag -width Er
106.It Bq Er EPERM
107The caller is not the superuser.
108.It Bq Er EINVAL
109The flag argument consisted of incompatible or otherwise
110unsupported bits.
111.El
112.Sh SEE ALSO
113.Xr mount_nfs 8 ,
114.Xr nfsd 8 ,
115.Xr sysctl 8
116.Sh HISTORY
117The
118.Nm nfssvc
119function first appeared in
120.Bx 4.4 .
121.Sh BUGS
122The
123.Nm nfssvc
124system call is designed specifically for the
125.Tn NFS
126support daemons and as such is specific to their requirements.
127Several fields of the argument structures are assumed to be valid and
128sometimes to be unchanged from a previous call, such that
129.Fn nfssvc
130must be used with extreme care.
131