summaryrefslogtreecommitdiff
path: root/lib/libc/sys/nfssvc.2
blob: 263a377c7115156e1896393482df31b5a399975b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
.\"	$OpenBSD: nfssvc.2,v 1.21 2014/03/24 01:54:58 guenther Exp $
.\"	$NetBSD: nfssvc.2,v 1.6 1995/02/27 12:35:08 cgd 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.
.\"
.\"	@(#)nfssvc.2	8.1 (Berkeley) 6/9/93
.\"
.Dd $Mdocdate: March 24 2014 $
.Dt NFSSVC 2
.Os
.Sh NAME
.Nm nfssvc
.Nd NFS services
.Sh SYNOPSIS
.Fd #include <unistd.h>
.Fd #include <nfs/nfs.h>
.Ft int
.Fn nfssvc "int flags" "void *argstructp"
.Sh DESCRIPTION
The
.Fn nfssvc
function is used by NFS daemons to pass information into the kernel
and also to enter the kernel as a server daemon.
The
.Fa flags
argument consists of several bits that show what action is to be taken
once in the kernel and the
.Fa argstructp
points to one of two structures depending on which bits are set in
flags.
.Pp
To enter an
.Xr nfsd 8
daemon into the kernel,
.Fn nfssvc
is called with the flag
.Dv NFSSVC_NFSD
and a pointer to a structure:
.Bd -literal
struct nfsd_srvargs {
        struct nfsd     *nsd_nfsd;   /* Pointer to in kernel nfsd struct */
        uid_t           nsd_uid;        /* Effective uid mapped to cred */
        u_int32_t       nsd_haddr;      /* IP address of client */
        struct xucred   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 */
        u_int32_t       nsd_ttl;        /* credential ttl (sec) */
};
.Ed
.Pp
To add further sockets for processing by the
.Xr nfsd 8
server daemons the master
.Xr nfsd 8
daemon  calls
.Fn nfssvc
with the flag
.Dv NFSSVC_ADDSOCK
and a pointer to a structure:
.Bd -literal
struct nfsd_args {
        int     sock;     /* Socket to serve */
        caddr_t name;     /* Client address for connection based sockets */
        int     namelen;  /* Length of name */
};
.Ed
.Sh RETURN VALUES
Normally
.Nm nfssvc
does not return unless the server
is terminated by a signal when a value of 0 is returned.
Otherwise, \-1 is returned and the global variable
.Va errno
is set to specify the error.
.Sh ERRORS
.Bl -tag -width Er
.It Bq Er EPERM
The caller is not the superuser.
.It Bq Er EINVAL
The flag argument consisted of incompatible or otherwise
unsupported bits.
.El
.Sh SEE ALSO
.Xr mount_nfs 8 ,
.Xr nfsd 8 ,
.Xr sysctl 8
.Sh HISTORY
The
.Nm nfssvc
function first appeared in
.Bx 4.4 .
.Sh BUGS
The
.Nm nfssvc
system call is designed specifically for the
.Tn NFS
support daemons and as such is specific to their requirements.
Several fields of the argument structures are assumed to be valid and
sometimes to be unchanged from a previous call, such that
.Fn nfssvc
must be used with extreme care.