Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Syscall interface to knfsd. |
| 3 | * |
| 4 | * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> |
| 5 | */ |
| 6 | |
Al Viro | 3f8206d | 2008-07-26 03:46:43 -0400 | [diff] [blame] | 7 | #include <linux/namei.h> |
NeilBrown | b41b66d | 2006-10-02 02:17:48 -0700 | [diff] [blame] | 8 | #include <linux/ctype.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/nfsd_idmap.h> |
NeilBrown | 80212d5 | 2006-10-02 02:17:47 -0700 | [diff] [blame] | 11 | #include <linux/sunrpc/svcsock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/nfsd/syscall.h> |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 13 | #include <linux/lockd/lockd.h> |
Chuck Lever | 4116092 | 2009-08-09 15:09:40 -0400 | [diff] [blame] | 14 | #include <linux/sunrpc/clnt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
Boaz Harrosh | 9a74af2 | 2009-12-03 20:30:56 +0200 | [diff] [blame] | 16 | #include "nfsd.h" |
| 17 | #include "cache.h" |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | /* |
| 20 | * We have a single directory with 9 nodes in it. |
| 21 | */ |
| 22 | enum { |
| 23 | NFSD_Root = 1, |
| 24 | NFSD_Svc, |
| 25 | NFSD_Add, |
| 26 | NFSD_Del, |
| 27 | NFSD_Export, |
| 28 | NFSD_Unexport, |
| 29 | NFSD_Getfd, |
| 30 | NFSD_Getfs, |
| 31 | NFSD_List, |
J. Bruce Fields | e8e8753 | 2009-12-14 12:53:32 -0500 | [diff] [blame] | 32 | NFSD_Export_features, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | NFSD_Fh, |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 34 | NFSD_FO_UnlockIP, |
Wendy Cheng | 17efa37 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 35 | NFSD_FO_UnlockFS, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | NFSD_Threads, |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 37 | NFSD_Pool_Threads, |
Greg Banks | 03cf6c9 | 2009-01-13 21:26:36 +1100 | [diff] [blame] | 38 | NFSD_Pool_Stats, |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 39 | NFSD_Versions, |
NeilBrown | 80212d5 | 2006-10-02 02:17:47 -0700 | [diff] [blame] | 40 | NFSD_Ports, |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 41 | NFSD_MaxBlkSize, |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 42 | /* |
| 43 | * The below MUST come last. Otherwise we leave a hole in nfsd_files[] |
| 44 | * with !CONFIG_NFSD_V4 and simple_fill_super() goes oops |
| 45 | */ |
| 46 | #ifdef CONFIG_NFSD_V4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | NFSD_Leasetime, |
J. Bruce Fields | efc4bb4f | 2010-03-02 11:04:06 -0500 | [diff] [blame] | 48 | NFSD_Gracetime, |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 49 | NFSD_RecoveryDir, |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 50 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | /* |
| 54 | * write() for these nodes. |
| 55 | */ |
| 56 | static ssize_t write_svc(struct file *file, char *buf, size_t size); |
| 57 | static ssize_t write_add(struct file *file, char *buf, size_t size); |
| 58 | static ssize_t write_del(struct file *file, char *buf, size_t size); |
| 59 | static ssize_t write_export(struct file *file, char *buf, size_t size); |
| 60 | static ssize_t write_unexport(struct file *file, char *buf, size_t size); |
| 61 | static ssize_t write_getfd(struct file *file, char *buf, size_t size); |
| 62 | static ssize_t write_getfs(struct file *file, char *buf, size_t size); |
| 63 | static ssize_t write_filehandle(struct file *file, char *buf, size_t size); |
Chuck Lever | b046ccd | 2008-12-12 16:57:13 -0500 | [diff] [blame] | 64 | static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size); |
| 65 | static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | static ssize_t write_threads(struct file *file, char *buf, size_t size); |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 67 | static ssize_t write_pool_threads(struct file *file, char *buf, size_t size); |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 68 | static ssize_t write_versions(struct file *file, char *buf, size_t size); |
NeilBrown | 80212d5 | 2006-10-02 02:17:47 -0700 | [diff] [blame] | 69 | static ssize_t write_ports(struct file *file, char *buf, size_t size); |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 70 | static ssize_t write_maxblksize(struct file *file, char *buf, size_t size); |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 71 | #ifdef CONFIG_NFSD_V4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size); |
J. Bruce Fields | efc4bb4f | 2010-03-02 11:04:06 -0500 | [diff] [blame] | 73 | static ssize_t write_gracetime(struct file *file, char *buf, size_t size); |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 74 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 75 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
| 77 | static ssize_t (*write_op[])(struct file *, char *, size_t) = { |
| 78 | [NFSD_Svc] = write_svc, |
| 79 | [NFSD_Add] = write_add, |
| 80 | [NFSD_Del] = write_del, |
| 81 | [NFSD_Export] = write_export, |
| 82 | [NFSD_Unexport] = write_unexport, |
| 83 | [NFSD_Getfd] = write_getfd, |
| 84 | [NFSD_Getfs] = write_getfs, |
| 85 | [NFSD_Fh] = write_filehandle, |
Chuck Lever | b046ccd | 2008-12-12 16:57:13 -0500 | [diff] [blame] | 86 | [NFSD_FO_UnlockIP] = write_unlock_ip, |
| 87 | [NFSD_FO_UnlockFS] = write_unlock_fs, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | [NFSD_Threads] = write_threads, |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 89 | [NFSD_Pool_Threads] = write_pool_threads, |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 90 | [NFSD_Versions] = write_versions, |
NeilBrown | 80212d5 | 2006-10-02 02:17:47 -0700 | [diff] [blame] | 91 | [NFSD_Ports] = write_ports, |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 92 | [NFSD_MaxBlkSize] = write_maxblksize, |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 93 | #ifdef CONFIG_NFSD_V4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | [NFSD_Leasetime] = write_leasetime, |
J. Bruce Fields | efc4bb4f | 2010-03-02 11:04:06 -0500 | [diff] [blame] | 95 | [NFSD_Gracetime] = write_gracetime, |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 96 | [NFSD_RecoveryDir] = write_recoverydir, |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 97 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | static ssize_t nfsctl_transaction_write(struct file *file, const char __user *buf, size_t size, loff_t *pos) |
| 101 | { |
Josef "Jeff" Sipek | 7eaa36e | 2006-12-08 02:36:41 -0800 | [diff] [blame] | 102 | ino_t ino = file->f_path.dentry->d_inode->i_ino; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | char *data; |
| 104 | ssize_t rv; |
| 105 | |
Tobias Klauser | e8c96f8 | 2006-03-24 03:15:34 -0800 | [diff] [blame] | 106 | if (ino >= ARRAY_SIZE(write_op) || !write_op[ino]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | return -EINVAL; |
| 108 | |
| 109 | data = simple_transaction_get(file, buf, size); |
| 110 | if (IS_ERR(data)) |
| 111 | return PTR_ERR(data); |
| 112 | |
| 113 | rv = write_op[ino](file, data, size); |
NeilBrown | 8971a10 | 2007-02-14 00:33:11 -0800 | [diff] [blame] | 114 | if (rv >= 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | simple_transaction_set(file, rv); |
| 116 | rv = size; |
| 117 | } |
| 118 | return rv; |
| 119 | } |
| 120 | |
NeilBrown | 7390022 | 2005-11-07 01:00:24 -0800 | [diff] [blame] | 121 | static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size_t size, loff_t *pos) |
| 122 | { |
| 123 | if (! file->private_data) { |
| 124 | /* An attempt to read a transaction file without writing |
| 125 | * causes a 0-byte write so that the file can return |
| 126 | * state information |
| 127 | */ |
| 128 | ssize_t rv = nfsctl_transaction_write(file, buf, 0, pos); |
| 129 | if (rv < 0) |
| 130 | return rv; |
| 131 | } |
| 132 | return simple_transaction_read(file, buf, size, pos); |
| 133 | } |
| 134 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 135 | static const struct file_operations transaction_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | .write = nfsctl_transaction_write, |
NeilBrown | 7390022 | 2005-11-07 01:00:24 -0800 | [diff] [blame] | 137 | .read = nfsctl_transaction_read, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | .release = simple_transaction_release, |
| 139 | }; |
| 140 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | static int exports_open(struct inode *inode, struct file *file) |
| 142 | { |
| 143 | return seq_open(file, &nfs_exports_op); |
| 144 | } |
| 145 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 146 | static const struct file_operations exports_operations = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | .open = exports_open, |
| 148 | .read = seq_read, |
| 149 | .llseek = seq_lseek, |
| 150 | .release = seq_release, |
Denis V. Lunev | 9ef2db2 | 2008-04-29 01:02:04 -0700 | [diff] [blame] | 151 | .owner = THIS_MODULE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | }; |
| 153 | |
J. Bruce Fields | e8e8753 | 2009-12-14 12:53:32 -0500 | [diff] [blame] | 154 | static int export_features_show(struct seq_file *m, void *v) |
| 155 | { |
| 156 | seq_printf(m, "0x%x 0x%x\n", NFSEXP_ALLFLAGS, NFSEXP_SECINFO_FLAGS); |
| 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | static int export_features_open(struct inode *inode, struct file *file) |
| 161 | { |
| 162 | return single_open(file, export_features_show, NULL); |
| 163 | } |
| 164 | |
| 165 | static struct file_operations export_features_operations = { |
| 166 | .open = export_features_open, |
| 167 | .read = seq_read, |
| 168 | .llseek = seq_lseek, |
| 169 | .release = single_release, |
| 170 | }; |
| 171 | |
Greg Banks | 03cf6c9 | 2009-01-13 21:26:36 +1100 | [diff] [blame] | 172 | extern int nfsd_pool_stats_open(struct inode *inode, struct file *file); |
Ryusei Yamaguchi | ed2d8ae | 2009-08-16 00:54:41 +0900 | [diff] [blame] | 173 | extern int nfsd_pool_stats_release(struct inode *inode, struct file *file); |
Greg Banks | 03cf6c9 | 2009-01-13 21:26:36 +1100 | [diff] [blame] | 174 | |
Alexey Dobriyan | 828c095 | 2009-10-01 15:43:56 -0700 | [diff] [blame] | 175 | static const struct file_operations pool_stats_operations = { |
Greg Banks | 03cf6c9 | 2009-01-13 21:26:36 +1100 | [diff] [blame] | 176 | .open = nfsd_pool_stats_open, |
| 177 | .read = seq_read, |
| 178 | .llseek = seq_lseek, |
Ryusei Yamaguchi | ed2d8ae | 2009-08-16 00:54:41 +0900 | [diff] [blame] | 179 | .release = nfsd_pool_stats_release, |
Greg Banks | 03cf6c9 | 2009-01-13 21:26:36 +1100 | [diff] [blame] | 180 | .owner = THIS_MODULE, |
| 181 | }; |
| 182 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | /*----------------------------------------------------------------------------*/ |
| 184 | /* |
| 185 | * payload - write methods |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | */ |
| 187 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 188 | /** |
| 189 | * write_svc - Start kernel's NFSD server |
| 190 | * |
| 191 | * Deprecated. /proc/fs/nfsd/threads is preferred. |
| 192 | * Function remains to support old versions of nfs-utils. |
| 193 | * |
| 194 | * Input: |
| 195 | * buf: struct nfsctl_svc |
| 196 | * svc_port: port number of this |
| 197 | * server's listener |
| 198 | * svc_nthreads: number of threads to start |
| 199 | * size: size in bytes of passed in nfsctl_svc |
| 200 | * Output: |
| 201 | * On success: returns zero |
| 202 | * On error: return code is negative errno value |
| 203 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | static ssize_t write_svc(struct file *file, char *buf, size_t size) |
| 205 | { |
| 206 | struct nfsctl_svc *data; |
NeilBrown | 82e12fe | 2009-06-16 11:03:07 +1000 | [diff] [blame] | 207 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | if (size < sizeof(*data)) |
| 209 | return -EINVAL; |
| 210 | data = (struct nfsctl_svc*) buf; |
NeilBrown | 82e12fe | 2009-06-16 11:03:07 +1000 | [diff] [blame] | 211 | err = nfsd_svc(data->svc_port, data->svc_nthreads); |
| 212 | if (err < 0) |
| 213 | return err; |
| 214 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | } |
| 216 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 217 | /** |
| 218 | * write_add - Add or modify client entry in auth unix cache |
| 219 | * |
| 220 | * Deprecated. /proc/net/rpc/auth.unix.ip is preferred. |
| 221 | * Function remains to support old versions of nfs-utils. |
| 222 | * |
| 223 | * Input: |
| 224 | * buf: struct nfsctl_client |
| 225 | * cl_ident: '\0'-terminated C string |
| 226 | * containing domain name |
| 227 | * of client |
| 228 | * cl_naddr: no. of items in cl_addrlist |
| 229 | * cl_addrlist: array of client addresses |
| 230 | * cl_fhkeytype: ignored |
| 231 | * cl_fhkeylen: ignored |
| 232 | * cl_fhkey: ignored |
| 233 | * size: size in bytes of passed in nfsctl_client |
| 234 | * Output: |
| 235 | * On success: returns zero |
| 236 | * On error: return code is negative errno value |
| 237 | * |
| 238 | * Note: Only AF_INET client addresses are passed in, since |
| 239 | * nfsctl_client.cl_addrlist contains only in_addr fields for addresses. |
| 240 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | static ssize_t write_add(struct file *file, char *buf, size_t size) |
| 242 | { |
| 243 | struct nfsctl_client *data; |
| 244 | if (size < sizeof(*data)) |
| 245 | return -EINVAL; |
| 246 | data = (struct nfsctl_client *)buf; |
| 247 | return exp_addclient(data); |
| 248 | } |
| 249 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 250 | /** |
| 251 | * write_del - Remove client from auth unix cache |
| 252 | * |
| 253 | * Deprecated. /proc/net/rpc/auth.unix.ip is preferred. |
| 254 | * Function remains to support old versions of nfs-utils. |
| 255 | * |
| 256 | * Input: |
| 257 | * buf: struct nfsctl_client |
| 258 | * cl_ident: '\0'-terminated C string |
| 259 | * containing domain name |
| 260 | * of client |
| 261 | * cl_naddr: ignored |
| 262 | * cl_addrlist: ignored |
| 263 | * cl_fhkeytype: ignored |
| 264 | * cl_fhkeylen: ignored |
| 265 | * cl_fhkey: ignored |
| 266 | * size: size in bytes of passed in nfsctl_client |
| 267 | * Output: |
| 268 | * On success: returns zero |
| 269 | * On error: return code is negative errno value |
| 270 | * |
| 271 | * Note: Only AF_INET client addresses are passed in, since |
| 272 | * nfsctl_client.cl_addrlist contains only in_addr fields for addresses. |
| 273 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | static ssize_t write_del(struct file *file, char *buf, size_t size) |
| 275 | { |
| 276 | struct nfsctl_client *data; |
| 277 | if (size < sizeof(*data)) |
| 278 | return -EINVAL; |
| 279 | data = (struct nfsctl_client *)buf; |
| 280 | return exp_delclient(data); |
| 281 | } |
| 282 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 283 | /** |
| 284 | * write_export - Export part or all of a local file system |
| 285 | * |
| 286 | * Deprecated. /proc/net/rpc/{nfsd.export,nfsd.fh} are preferred. |
| 287 | * Function remains to support old versions of nfs-utils. |
| 288 | * |
| 289 | * Input: |
| 290 | * buf: struct nfsctl_export |
| 291 | * ex_client: '\0'-terminated C string |
| 292 | * containing domain name |
| 293 | * of client allowed to access |
| 294 | * this export |
| 295 | * ex_path: '\0'-terminated C string |
| 296 | * containing pathname of |
| 297 | * directory in local file system |
| 298 | * ex_dev: fsid to use for this export |
| 299 | * ex_ino: ignored |
| 300 | * ex_flags: export flags for this export |
| 301 | * ex_anon_uid: UID to use for anonymous |
| 302 | * requests |
| 303 | * ex_anon_gid: GID to use for anonymous |
| 304 | * requests |
| 305 | * size: size in bytes of passed in nfsctl_export |
| 306 | * Output: |
| 307 | * On success: returns zero |
| 308 | * On error: return code is negative errno value |
| 309 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | static ssize_t write_export(struct file *file, char *buf, size_t size) |
| 311 | { |
| 312 | struct nfsctl_export *data; |
| 313 | if (size < sizeof(*data)) |
| 314 | return -EINVAL; |
| 315 | data = (struct nfsctl_export*)buf; |
| 316 | return exp_export(data); |
| 317 | } |
| 318 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 319 | /** |
| 320 | * write_unexport - Unexport a previously exported file system |
| 321 | * |
| 322 | * Deprecated. /proc/net/rpc/{nfsd.export,nfsd.fh} are preferred. |
| 323 | * Function remains to support old versions of nfs-utils. |
| 324 | * |
| 325 | * Input: |
| 326 | * buf: struct nfsctl_export |
| 327 | * ex_client: '\0'-terminated C string |
| 328 | * containing domain name |
| 329 | * of client no longer allowed |
| 330 | * to access this export |
| 331 | * ex_path: '\0'-terminated C string |
| 332 | * containing pathname of |
| 333 | * directory in local file system |
| 334 | * ex_dev: ignored |
| 335 | * ex_ino: ignored |
| 336 | * ex_flags: ignored |
| 337 | * ex_anon_uid: ignored |
| 338 | * ex_anon_gid: ignored |
| 339 | * size: size in bytes of passed in nfsctl_export |
| 340 | * Output: |
| 341 | * On success: returns zero |
| 342 | * On error: return code is negative errno value |
| 343 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | static ssize_t write_unexport(struct file *file, char *buf, size_t size) |
| 345 | { |
| 346 | struct nfsctl_export *data; |
| 347 | |
| 348 | if (size < sizeof(*data)) |
| 349 | return -EINVAL; |
| 350 | data = (struct nfsctl_export*)buf; |
| 351 | return exp_unexport(data); |
| 352 | } |
| 353 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 354 | /** |
| 355 | * write_getfs - Get a variable-length NFS file handle by path |
| 356 | * |
| 357 | * Deprecated. /proc/fs/nfsd/filehandle is preferred. |
| 358 | * Function remains to support old versions of nfs-utils. |
| 359 | * |
| 360 | * Input: |
| 361 | * buf: struct nfsctl_fsparm |
| 362 | * gd_addr: socket address of client |
| 363 | * gd_path: '\0'-terminated C string |
| 364 | * containing pathname of |
| 365 | * directory in local file system |
| 366 | * gd_maxlen: maximum size of returned file |
| 367 | * handle |
| 368 | * size: size in bytes of passed in nfsctl_fsparm |
| 369 | * Output: |
| 370 | * On success: passed-in buffer filled with a knfsd_fh structure |
| 371 | * (a variable-length raw NFS file handle); |
| 372 | * return code is the size in bytes of the file handle |
| 373 | * On error: return code is negative errno value |
| 374 | * |
| 375 | * Note: Only AF_INET client addresses are passed in, since gd_addr |
| 376 | * is the same size as a struct sockaddr_in. |
| 377 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | static ssize_t write_getfs(struct file *file, char *buf, size_t size) |
| 379 | { |
| 380 | struct nfsctl_fsparm *data; |
| 381 | struct sockaddr_in *sin; |
| 382 | struct auth_domain *clp; |
| 383 | int err = 0; |
| 384 | struct knfsd_fh *res; |
Aurélien Charbon | f15364b | 2008-01-18 15:50:56 +0100 | [diff] [blame] | 385 | struct in6_addr in6; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
| 387 | if (size < sizeof(*data)) |
| 388 | return -EINVAL; |
| 389 | data = (struct nfsctl_fsparm*)buf; |
| 390 | err = -EPROTONOSUPPORT; |
| 391 | if (data->gd_addr.sa_family != AF_INET) |
| 392 | goto out; |
| 393 | sin = (struct sockaddr_in *)&data->gd_addr; |
| 394 | if (data->gd_maxlen > NFS3_FHSIZE) |
| 395 | data->gd_maxlen = NFS3_FHSIZE; |
| 396 | |
| 397 | res = (struct knfsd_fh*)buf; |
| 398 | |
| 399 | exp_readlock(); |
Aurélien Charbon | f15364b | 2008-01-18 15:50:56 +0100 | [diff] [blame] | 400 | |
| 401 | ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &in6); |
| 402 | |
| 403 | clp = auth_unix_lookup(&in6); |
| 404 | if (!clp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | err = -EPERM; |
| 406 | else { |
| 407 | err = exp_rootfh(clp, data->gd_path, res, data->gd_maxlen); |
| 408 | auth_domain_put(clp); |
| 409 | } |
| 410 | exp_readunlock(); |
| 411 | if (err == 0) |
Andrew Morton | 1212749 | 2007-07-17 04:04:34 -0700 | [diff] [blame] | 412 | err = res->fh_size + offsetof(struct knfsd_fh, fh_base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | out: |
| 414 | return err; |
| 415 | } |
| 416 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 417 | /** |
| 418 | * write_getfd - Get a fixed-length NFS file handle by path (used by mountd) |
| 419 | * |
| 420 | * Deprecated. /proc/fs/nfsd/filehandle is preferred. |
| 421 | * Function remains to support old versions of nfs-utils. |
| 422 | * |
| 423 | * Input: |
| 424 | * buf: struct nfsctl_fdparm |
| 425 | * gd_addr: socket address of client |
| 426 | * gd_path: '\0'-terminated C string |
| 427 | * containing pathname of |
| 428 | * directory in local file system |
| 429 | * gd_version: fdparm structure version |
| 430 | * size: size in bytes of passed in nfsctl_fdparm |
| 431 | * Output: |
| 432 | * On success: passed-in buffer filled with nfsctl_res |
| 433 | * (a fixed-length raw NFS file handle); |
| 434 | * return code is the size in bytes of the file handle |
| 435 | * On error: return code is negative errno value |
| 436 | * |
| 437 | * Note: Only AF_INET client addresses are passed in, since gd_addr |
| 438 | * is the same size as a struct sockaddr_in. |
| 439 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | static ssize_t write_getfd(struct file *file, char *buf, size_t size) |
| 441 | { |
| 442 | struct nfsctl_fdparm *data; |
| 443 | struct sockaddr_in *sin; |
| 444 | struct auth_domain *clp; |
| 445 | int err = 0; |
| 446 | struct knfsd_fh fh; |
| 447 | char *res; |
Aurélien Charbon | f15364b | 2008-01-18 15:50:56 +0100 | [diff] [blame] | 448 | struct in6_addr in6; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | |
| 450 | if (size < sizeof(*data)) |
| 451 | return -EINVAL; |
| 452 | data = (struct nfsctl_fdparm*)buf; |
| 453 | err = -EPROTONOSUPPORT; |
| 454 | if (data->gd_addr.sa_family != AF_INET) |
| 455 | goto out; |
| 456 | err = -EINVAL; |
| 457 | if (data->gd_version < 2 || data->gd_version > NFSSVC_MAXVERS) |
| 458 | goto out; |
| 459 | |
| 460 | res = buf; |
| 461 | sin = (struct sockaddr_in *)&data->gd_addr; |
| 462 | exp_readlock(); |
Aurélien Charbon | f15364b | 2008-01-18 15:50:56 +0100 | [diff] [blame] | 463 | |
| 464 | ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &in6); |
| 465 | |
| 466 | clp = auth_unix_lookup(&in6); |
| 467 | if (!clp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | err = -EPERM; |
| 469 | else { |
| 470 | err = exp_rootfh(clp, data->gd_path, &fh, NFS_FHSIZE); |
| 471 | auth_domain_put(clp); |
| 472 | } |
| 473 | exp_readunlock(); |
| 474 | |
| 475 | if (err == 0) { |
| 476 | memset(res,0, NFS_FHSIZE); |
| 477 | memcpy(res, &fh.fh_base, fh.fh_size); |
| 478 | err = NFS_FHSIZE; |
| 479 | } |
| 480 | out: |
| 481 | return err; |
| 482 | } |
| 483 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 484 | /** |
| 485 | * write_unlock_ip - Release all locks used by a client |
| 486 | * |
| 487 | * Experimental. |
| 488 | * |
| 489 | * Input: |
| 490 | * buf: '\n'-terminated C string containing a |
Chuck Lever | 4116092 | 2009-08-09 15:09:40 -0400 | [diff] [blame] | 491 | * presentation format IP address |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 492 | * size: length of C string in @buf |
| 493 | * Output: |
| 494 | * On success: returns zero if all specified locks were released; |
| 495 | * returns one if one or more locks were not released |
| 496 | * On error: return code is negative errno value |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 497 | */ |
Chuck Lever | b046ccd | 2008-12-12 16:57:13 -0500 | [diff] [blame] | 498 | static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size) |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 499 | { |
Chuck Lever | 4116092 | 2009-08-09 15:09:40 -0400 | [diff] [blame] | 500 | struct sockaddr_storage address; |
| 501 | struct sockaddr *sap = (struct sockaddr *)&address; |
| 502 | size_t salen = sizeof(address); |
Chuck Lever | 367c8c7 | 2008-06-30 18:58:14 -0400 | [diff] [blame] | 503 | char *fo_path; |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 504 | |
| 505 | /* sanity check */ |
| 506 | if (size == 0) |
| 507 | return -EINVAL; |
| 508 | |
| 509 | if (buf[size-1] != '\n') |
| 510 | return -EINVAL; |
| 511 | |
| 512 | fo_path = buf; |
| 513 | if (qword_get(&buf, fo_path, size) < 0) |
| 514 | return -EINVAL; |
| 515 | |
Chuck Lever | 4116092 | 2009-08-09 15:09:40 -0400 | [diff] [blame] | 516 | if (rpc_pton(fo_path, size, sap, salen) == 0) |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 517 | return -EINVAL; |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 518 | |
Chuck Lever | 4116092 | 2009-08-09 15:09:40 -0400 | [diff] [blame] | 519 | return nlmsvc_unlock_all_by_ip(sap); |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 520 | } |
| 521 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 522 | /** |
| 523 | * write_unlock_fs - Release all locks on a local file system |
| 524 | * |
| 525 | * Experimental. |
| 526 | * |
| 527 | * Input: |
| 528 | * buf: '\n'-terminated C string containing the |
| 529 | * absolute pathname of a local file system |
| 530 | * size: length of C string in @buf |
| 531 | * Output: |
| 532 | * On success: returns zero if all specified locks were released; |
| 533 | * returns one if one or more locks were not released |
| 534 | * On error: return code is negative errno value |
| 535 | */ |
Chuck Lever | b046ccd | 2008-12-12 16:57:13 -0500 | [diff] [blame] | 536 | static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size) |
Wendy Cheng | 17efa37 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 537 | { |
Al Viro | a63bb99 | 2008-08-02 01:03:36 -0400 | [diff] [blame] | 538 | struct path path; |
Wendy Cheng | 17efa37 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 539 | char *fo_path; |
| 540 | int error; |
| 541 | |
| 542 | /* sanity check */ |
| 543 | if (size == 0) |
| 544 | return -EINVAL; |
| 545 | |
| 546 | if (buf[size-1] != '\n') |
| 547 | return -EINVAL; |
| 548 | |
| 549 | fo_path = buf; |
| 550 | if (qword_get(&buf, fo_path, size) < 0) |
| 551 | return -EINVAL; |
| 552 | |
Al Viro | a63bb99 | 2008-08-02 01:03:36 -0400 | [diff] [blame] | 553 | error = kern_path(fo_path, 0, &path); |
Wendy Cheng | 17efa37 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 554 | if (error) |
| 555 | return error; |
| 556 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 557 | /* |
| 558 | * XXX: Needs better sanity checking. Otherwise we could end up |
| 559 | * releasing locks on the wrong file system. |
| 560 | * |
| 561 | * For example: |
| 562 | * 1. Does the path refer to a directory? |
| 563 | * 2. Is that directory a mount point, or |
| 564 | * 3. Is that directory the root of an exported file system? |
| 565 | */ |
Al Viro | a63bb99 | 2008-08-02 01:03:36 -0400 | [diff] [blame] | 566 | error = nlmsvc_unlock_all_by_sb(path.mnt->mnt_sb); |
Wendy Cheng | 17efa37 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 567 | |
Al Viro | a63bb99 | 2008-08-02 01:03:36 -0400 | [diff] [blame] | 568 | path_put(&path); |
Wendy Cheng | 17efa37 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 569 | return error; |
| 570 | } |
| 571 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 572 | /** |
| 573 | * write_filehandle - Get a variable-length NFS file handle by path |
| 574 | * |
| 575 | * On input, the buffer contains a '\n'-terminated C string comprised of |
| 576 | * three alphanumeric words separated by whitespace. The string may |
| 577 | * contain escape sequences. |
| 578 | * |
| 579 | * Input: |
| 580 | * buf: |
| 581 | * domain: client domain name |
| 582 | * path: export pathname |
| 583 | * maxsize: numeric maximum size of |
| 584 | * @buf |
| 585 | * size: length of C string in @buf |
| 586 | * Output: |
| 587 | * On success: passed-in buffer filled with '\n'-terminated C |
| 588 | * string containing a ASCII hex text version |
| 589 | * of the NFS file handle; |
| 590 | * return code is the size in bytes of the string |
| 591 | * On error: return code is negative errno value |
| 592 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | static ssize_t write_filehandle(struct file *file, char *buf, size_t size) |
| 594 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | char *dname, *path; |
Andrew Morton | 246d95b | 2007-08-09 00:53:50 -0700 | [diff] [blame] | 596 | int uninitialized_var(maxsize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | char *mesg = buf; |
| 598 | int len; |
| 599 | struct auth_domain *dom; |
| 600 | struct knfsd_fh fh; |
| 601 | |
J. Bruce Fields | 87d26ea | 2008-01-22 17:40:42 -0500 | [diff] [blame] | 602 | if (size == 0) |
| 603 | return -EINVAL; |
| 604 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | if (buf[size-1] != '\n') |
| 606 | return -EINVAL; |
| 607 | buf[size-1] = 0; |
| 608 | |
| 609 | dname = mesg; |
| 610 | len = qword_get(&mesg, dname, size); |
Chuck Lever | 54224f0 | 2008-12-12 16:57:20 -0500 | [diff] [blame] | 611 | if (len <= 0) |
| 612 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | |
| 614 | path = dname+len+1; |
| 615 | len = qword_get(&mesg, path, size); |
Chuck Lever | 54224f0 | 2008-12-12 16:57:20 -0500 | [diff] [blame] | 616 | if (len <= 0) |
| 617 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | |
| 619 | len = get_int(&mesg, &maxsize); |
| 620 | if (len) |
| 621 | return len; |
| 622 | |
| 623 | if (maxsize < NFS_FHSIZE) |
| 624 | return -EINVAL; |
| 625 | if (maxsize > NFS3_FHSIZE) |
| 626 | maxsize = NFS3_FHSIZE; |
| 627 | |
| 628 | if (qword_get(&mesg, mesg, size)>0) |
| 629 | return -EINVAL; |
| 630 | |
| 631 | /* we have all the words, they are in buf.. */ |
| 632 | dom = unix_domain_find(dname); |
| 633 | if (!dom) |
| 634 | return -ENOMEM; |
| 635 | |
| 636 | len = exp_rootfh(dom, path, &fh, maxsize); |
| 637 | auth_domain_put(dom); |
| 638 | if (len) |
| 639 | return len; |
| 640 | |
Chuck Lever | 54224f0 | 2008-12-12 16:57:20 -0500 | [diff] [blame] | 641 | mesg = buf; |
| 642 | len = SIMPLE_TRANSACTION_LIMIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | qword_addhex(&mesg, &len, (char*)&fh.fh_base, fh.fh_size); |
| 644 | mesg[-1] = '\n'; |
| 645 | return mesg - buf; |
| 646 | } |
| 647 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 648 | /** |
| 649 | * write_threads - Start NFSD, or report the current number of running threads |
| 650 | * |
| 651 | * Input: |
| 652 | * buf: ignored |
| 653 | * size: zero |
| 654 | * Output: |
| 655 | * On success: passed-in buffer filled with '\n'-terminated C |
| 656 | * string numeric value representing the number of |
| 657 | * running NFSD threads; |
| 658 | * return code is the size in bytes of the string |
| 659 | * On error: return code is zero |
| 660 | * |
| 661 | * OR |
| 662 | * |
| 663 | * Input: |
| 664 | * buf: C string containing an unsigned |
| 665 | * integer value representing the |
| 666 | * number of NFSD threads to start |
| 667 | * size: non-zero length of C string in @buf |
| 668 | * Output: |
| 669 | * On success: NFS service is started; |
| 670 | * passed-in buffer filled with '\n'-terminated C |
| 671 | * string numeric value representing the number of |
| 672 | * running NFSD threads; |
| 673 | * return code is the size in bytes of the string |
| 674 | * On error: return code is zero or a negative errno value |
| 675 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | static ssize_t write_threads(struct file *file, char *buf, size_t size) |
| 677 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | char *mesg = buf; |
| 679 | int rv; |
| 680 | if (size > 0) { |
| 681 | int newthreads; |
| 682 | rv = get_int(&mesg, &newthreads); |
| 683 | if (rv) |
| 684 | return rv; |
Chuck Lever | 9e07485 | 2008-12-12 16:57:27 -0500 | [diff] [blame] | 685 | if (newthreads < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | return -EINVAL; |
Chuck Lever | 9e07485 | 2008-12-12 16:57:27 -0500 | [diff] [blame] | 687 | rv = nfsd_svc(NFS_PORT, newthreads); |
NeilBrown | 82e12fe | 2009-06-16 11:03:07 +1000 | [diff] [blame] | 688 | if (rv < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | return rv; |
NeilBrown | 82e12fe | 2009-06-16 11:03:07 +1000 | [diff] [blame] | 690 | } else |
| 691 | rv = nfsd_nrthreads(); |
Chuck Lever | e06b640 | 2009-04-23 19:33:25 -0400 | [diff] [blame] | 692 | |
NeilBrown | 82e12fe | 2009-06-16 11:03:07 +1000 | [diff] [blame] | 693 | return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%d\n", rv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | } |
| 695 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 696 | /** |
| 697 | * write_pool_threads - Set or report the current number of threads per pool |
| 698 | * |
| 699 | * Input: |
| 700 | * buf: ignored |
| 701 | * size: zero |
| 702 | * |
| 703 | * OR |
| 704 | * |
| 705 | * Input: |
| 706 | * buf: C string containing whitespace- |
| 707 | * separated unsigned integer values |
| 708 | * representing the number of NFSD |
| 709 | * threads to start in each pool |
| 710 | * size: non-zero length of C string in @buf |
| 711 | * Output: |
| 712 | * On success: passed-in buffer filled with '\n'-terminated C |
| 713 | * string containing integer values representing the |
| 714 | * number of NFSD threads in each pool; |
| 715 | * return code is the size in bytes of the string |
| 716 | * On error: return code is zero or a negative errno value |
| 717 | */ |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 718 | static ssize_t write_pool_threads(struct file *file, char *buf, size_t size) |
| 719 | { |
| 720 | /* if size > 0, look for an array of number of threads per node |
| 721 | * and apply them then write out number of threads per node as reply |
| 722 | */ |
| 723 | char *mesg = buf; |
| 724 | int i; |
| 725 | int rv; |
| 726 | int len; |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 727 | int npools; |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 728 | int *nthreads; |
| 729 | |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 730 | mutex_lock(&nfsd_mutex); |
| 731 | npools = nfsd_nrpools(); |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 732 | if (npools == 0) { |
| 733 | /* |
| 734 | * NFS is shut down. The admin can start it by |
| 735 | * writing to the threads file but NOT the pool_threads |
| 736 | * file, sorry. Report zero threads. |
| 737 | */ |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 738 | mutex_unlock(&nfsd_mutex); |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 739 | strcpy(buf, "0\n"); |
| 740 | return strlen(buf); |
| 741 | } |
| 742 | |
| 743 | nthreads = kcalloc(npools, sizeof(int), GFP_KERNEL); |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 744 | rv = -ENOMEM; |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 745 | if (nthreads == NULL) |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 746 | goto out_free; |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 747 | |
| 748 | if (size > 0) { |
| 749 | for (i = 0; i < npools; i++) { |
| 750 | rv = get_int(&mesg, &nthreads[i]); |
| 751 | if (rv == -ENOENT) |
| 752 | break; /* fewer numbers than pools */ |
| 753 | if (rv) |
| 754 | goto out_free; /* syntax error */ |
| 755 | rv = -EINVAL; |
| 756 | if (nthreads[i] < 0) |
| 757 | goto out_free; |
| 758 | } |
| 759 | rv = nfsd_set_nrthreads(i, nthreads); |
| 760 | if (rv) |
| 761 | goto out_free; |
| 762 | } |
| 763 | |
| 764 | rv = nfsd_get_nrthreads(npools, nthreads); |
| 765 | if (rv) |
| 766 | goto out_free; |
| 767 | |
| 768 | mesg = buf; |
| 769 | size = SIMPLE_TRANSACTION_LIMIT; |
| 770 | for (i = 0; i < npools && size > 0; i++) { |
| 771 | snprintf(mesg, size, "%d%c", nthreads[i], (i == npools-1 ? '\n' : ' ')); |
| 772 | len = strlen(mesg); |
| 773 | size -= len; |
| 774 | mesg += len; |
| 775 | } |
J. Bruce Fields | 413d63d710 | 2009-07-28 11:37:25 -0400 | [diff] [blame] | 776 | rv = mesg - buf; |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 777 | out_free: |
| 778 | kfree(nthreads); |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 779 | mutex_unlock(&nfsd_mutex); |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 780 | return rv; |
| 781 | } |
| 782 | |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 783 | static ssize_t __write_versions(struct file *file, char *buf, size_t size) |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 784 | { |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 785 | char *mesg = buf; |
Benny Halevy | 8daf220 | 2009-04-03 08:28:59 +0300 | [diff] [blame] | 786 | char *vers, *minorp, sign; |
Chuck Lever | 261758b | 2009-04-23 19:33:18 -0400 | [diff] [blame] | 787 | int len, num, remaining; |
Benny Halevy | 8daf220 | 2009-04-03 08:28:59 +0300 | [diff] [blame] | 788 | unsigned minor; |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 789 | ssize_t tlen = 0; |
| 790 | char *sep; |
| 791 | |
| 792 | if (size>0) { |
| 793 | if (nfsd_serv) |
NeilBrown | 6658d3a | 2006-10-02 02:17:46 -0700 | [diff] [blame] | 794 | /* Cannot change versions without updating |
| 795 | * nfsd_serv->sv_xdrsize, and reallocing |
| 796 | * rq_argp and rq_resp |
| 797 | */ |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 798 | return -EBUSY; |
| 799 | if (buf[size-1] != '\n') |
| 800 | return -EINVAL; |
| 801 | buf[size-1] = 0; |
| 802 | |
| 803 | vers = mesg; |
| 804 | len = qword_get(&mesg, vers, size); |
| 805 | if (len <= 0) return -EINVAL; |
| 806 | do { |
| 807 | sign = *vers; |
| 808 | if (sign == '+' || sign == '-') |
Benny Halevy | 8daf220 | 2009-04-03 08:28:59 +0300 | [diff] [blame] | 809 | num = simple_strtol((vers+1), &minorp, 0); |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 810 | else |
Benny Halevy | 8daf220 | 2009-04-03 08:28:59 +0300 | [diff] [blame] | 811 | num = simple_strtol(vers, &minorp, 0); |
| 812 | if (*minorp == '.') { |
| 813 | if (num < 4) |
| 814 | return -EINVAL; |
| 815 | minor = simple_strtoul(minorp+1, NULL, 0); |
| 816 | if (minor == 0) |
| 817 | return -EINVAL; |
| 818 | if (nfsd_minorversion(minor, sign == '-' ? |
| 819 | NFSD_CLEAR : NFSD_SET) < 0) |
| 820 | return -EINVAL; |
| 821 | goto next; |
| 822 | } |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 823 | switch(num) { |
| 824 | case 2: |
| 825 | case 3: |
| 826 | case 4: |
NeilBrown | 6658d3a | 2006-10-02 02:17:46 -0700 | [diff] [blame] | 827 | nfsd_vers(num, sign == '-' ? NFSD_CLEAR : NFSD_SET); |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 828 | break; |
| 829 | default: |
| 830 | return -EINVAL; |
| 831 | } |
Benny Halevy | 8daf220 | 2009-04-03 08:28:59 +0300 | [diff] [blame] | 832 | next: |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 833 | vers += len + 1; |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 834 | } while ((len = qword_get(&mesg, vers, size)) > 0); |
| 835 | /* If all get turned off, turn them back on, as |
| 836 | * having no versions is BAD |
| 837 | */ |
NeilBrown | 6658d3a | 2006-10-02 02:17:46 -0700 | [diff] [blame] | 838 | nfsd_reset_versions(); |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 839 | } |
Chuck Lever | 261758b | 2009-04-23 19:33:18 -0400 | [diff] [blame] | 840 | |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 841 | /* Now write current state into reply buffer */ |
| 842 | len = 0; |
| 843 | sep = ""; |
Chuck Lever | 261758b | 2009-04-23 19:33:18 -0400 | [diff] [blame] | 844 | remaining = SIMPLE_TRANSACTION_LIMIT; |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 845 | for (num=2 ; num <= 4 ; num++) |
NeilBrown | 6658d3a | 2006-10-02 02:17:46 -0700 | [diff] [blame] | 846 | if (nfsd_vers(num, NFSD_AVAIL)) { |
Chuck Lever | 261758b | 2009-04-23 19:33:18 -0400 | [diff] [blame] | 847 | len = snprintf(buf, remaining, "%s%c%d", sep, |
NeilBrown | 6658d3a | 2006-10-02 02:17:46 -0700 | [diff] [blame] | 848 | nfsd_vers(num, NFSD_TEST)?'+':'-', |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 849 | num); |
| 850 | sep = " "; |
Chuck Lever | 261758b | 2009-04-23 19:33:18 -0400 | [diff] [blame] | 851 | |
| 852 | if (len > remaining) |
| 853 | break; |
| 854 | remaining -= len; |
| 855 | buf += len; |
| 856 | tlen += len; |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 857 | } |
Benny Halevy | 8daf220 | 2009-04-03 08:28:59 +0300 | [diff] [blame] | 858 | if (nfsd_vers(4, NFSD_AVAIL)) |
Chuck Lever | 261758b | 2009-04-23 19:33:18 -0400 | [diff] [blame] | 859 | for (minor = 1; minor <= NFSD_SUPPORTED_MINOR_VERSION; |
| 860 | minor++) { |
| 861 | len = snprintf(buf, remaining, " %c4.%u", |
Benny Halevy | 8daf220 | 2009-04-03 08:28:59 +0300 | [diff] [blame] | 862 | (nfsd_vers(4, NFSD_TEST) && |
| 863 | nfsd_minorversion(minor, NFSD_TEST)) ? |
| 864 | '+' : '-', |
| 865 | minor); |
Chuck Lever | 261758b | 2009-04-23 19:33:18 -0400 | [diff] [blame] | 866 | |
| 867 | if (len > remaining) |
| 868 | break; |
| 869 | remaining -= len; |
| 870 | buf += len; |
| 871 | tlen += len; |
| 872 | } |
| 873 | |
| 874 | len = snprintf(buf, remaining, "\n"); |
| 875 | if (len > remaining) |
| 876 | return -EINVAL; |
| 877 | return tlen + len; |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 878 | } |
| 879 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 880 | /** |
| 881 | * write_versions - Set or report the available NFS protocol versions |
| 882 | * |
| 883 | * Input: |
| 884 | * buf: ignored |
| 885 | * size: zero |
| 886 | * Output: |
| 887 | * On success: passed-in buffer filled with '\n'-terminated C |
| 888 | * string containing positive or negative integer |
| 889 | * values representing the current status of each |
| 890 | * protocol version; |
| 891 | * return code is the size in bytes of the string |
| 892 | * On error: return code is zero or a negative errno value |
| 893 | * |
| 894 | * OR |
| 895 | * |
| 896 | * Input: |
| 897 | * buf: C string containing whitespace- |
| 898 | * separated positive or negative |
| 899 | * integer values representing NFS |
| 900 | * protocol versions to enable ("+n") |
| 901 | * or disable ("-n") |
| 902 | * size: non-zero length of C string in @buf |
| 903 | * Output: |
| 904 | * On success: status of zero or more protocol versions has |
| 905 | * been updated; passed-in buffer filled with |
| 906 | * '\n'-terminated C string containing positive |
| 907 | * or negative integer values representing the |
| 908 | * current status of each protocol version; |
| 909 | * return code is the size in bytes of the string |
| 910 | * On error: return code is zero or a negative errno value |
| 911 | */ |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 912 | static ssize_t write_versions(struct file *file, char *buf, size_t size) |
| 913 | { |
| 914 | ssize_t rv; |
| 915 | |
| 916 | mutex_lock(&nfsd_mutex); |
| 917 | rv = __write_versions(file, buf, size); |
| 918 | mutex_unlock(&nfsd_mutex); |
| 919 | return rv; |
| 920 | } |
| 921 | |
Chuck Lever | 4cd5dc7 | 2009-04-23 19:31:32 -0400 | [diff] [blame] | 922 | /* |
Chuck Lever | 0a5372d | 2009-04-23 19:32:10 -0400 | [diff] [blame] | 923 | * Zero-length write. Return a list of NFSD's current listener |
| 924 | * transports. |
| 925 | */ |
| 926 | static ssize_t __write_ports_names(char *buf) |
| 927 | { |
| 928 | if (nfsd_serv == NULL) |
| 929 | return 0; |
Chuck Lever | 335c54b | 2009-04-23 19:32:25 -0400 | [diff] [blame] | 930 | return svc_xprt_names(nfsd_serv, buf, SIMPLE_TRANSACTION_LIMIT); |
Chuck Lever | 0a5372d | 2009-04-23 19:32:10 -0400 | [diff] [blame] | 931 | } |
| 932 | |
| 933 | /* |
Chuck Lever | 0b7c2f6 | 2009-04-23 19:31:55 -0400 | [diff] [blame] | 934 | * A single 'fd' number was written, in which case it must be for |
| 935 | * a socket of a supported family/protocol, and we use it as an |
| 936 | * nfsd listener. |
| 937 | */ |
| 938 | static ssize_t __write_ports_addfd(char *buf) |
| 939 | { |
| 940 | char *mesg = buf; |
| 941 | int fd, err; |
| 942 | |
| 943 | err = get_int(&mesg, &fd); |
| 944 | if (err != 0 || fd < 0) |
| 945 | return -EINVAL; |
| 946 | |
| 947 | err = nfsd_create_serv(); |
| 948 | if (err != 0) |
| 949 | return err; |
| 950 | |
Chuck Lever | ea068ba | 2009-04-23 19:32:18 -0400 | [diff] [blame] | 951 | err = lockd_up(); |
| 952 | if (err != 0) |
| 953 | goto out; |
| 954 | |
Chuck Lever | bfba9ab | 2009-04-23 19:32:33 -0400 | [diff] [blame] | 955 | err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT); |
Chuck Lever | ea068ba | 2009-04-23 19:32:18 -0400 | [diff] [blame] | 956 | if (err < 0) |
| 957 | lockd_down(); |
Chuck Lever | 0b7c2f6 | 2009-04-23 19:31:55 -0400 | [diff] [blame] | 958 | |
Chuck Lever | ea068ba | 2009-04-23 19:32:18 -0400 | [diff] [blame] | 959 | out: |
| 960 | /* Decrease the count, but don't shut down the service */ |
| 961 | nfsd_serv->sv_nrthreads--; |
| 962 | return err; |
Chuck Lever | 0b7c2f6 | 2009-04-23 19:31:55 -0400 | [diff] [blame] | 963 | } |
| 964 | |
| 965 | /* |
Chuck Lever | 82d5659 | 2009-04-23 19:31:48 -0400 | [diff] [blame] | 966 | * A '-' followed by the 'name' of a socket means we close the socket. |
| 967 | */ |
| 968 | static ssize_t __write_ports_delfd(char *buf) |
| 969 | { |
| 970 | char *toclose; |
| 971 | int len = 0; |
| 972 | |
| 973 | toclose = kstrdup(buf + 1, GFP_KERNEL); |
| 974 | if (toclose == NULL) |
| 975 | return -ENOMEM; |
| 976 | |
| 977 | if (nfsd_serv != NULL) |
Chuck Lever | 8435d34 | 2009-04-23 19:32:40 -0400 | [diff] [blame] | 978 | len = svc_sock_names(nfsd_serv, buf, |
| 979 | SIMPLE_TRANSACTION_LIMIT, toclose); |
Chuck Lever | 82d5659 | 2009-04-23 19:31:48 -0400 | [diff] [blame] | 980 | if (len >= 0) |
| 981 | lockd_down(); |
| 982 | |
| 983 | kfree(toclose); |
| 984 | return len; |
| 985 | } |
| 986 | |
| 987 | /* |
Chuck Lever | 4eb68c2 | 2009-04-23 19:31:40 -0400 | [diff] [blame] | 988 | * A transport listener is added by writing it's transport name and |
| 989 | * a port number. |
| 990 | */ |
| 991 | static ssize_t __write_ports_addxprt(char *buf) |
| 992 | { |
| 993 | char transport[16]; |
Chuck Lever | 3749829 | 2010-01-26 14:04:22 -0500 | [diff] [blame] | 994 | struct svc_xprt *xprt; |
Chuck Lever | 4eb68c2 | 2009-04-23 19:31:40 -0400 | [diff] [blame] | 995 | int port, err; |
| 996 | |
| 997 | if (sscanf(buf, "%15s %4u", transport, &port) != 2) |
| 998 | return -EINVAL; |
| 999 | |
| 1000 | if (port < 1 || port > USHORT_MAX) |
| 1001 | return -EINVAL; |
| 1002 | |
| 1003 | err = nfsd_create_serv(); |
| 1004 | if (err != 0) |
| 1005 | return err; |
| 1006 | |
| 1007 | err = svc_create_xprt(nfsd_serv, transport, |
| 1008 | PF_INET, port, SVC_SOCK_ANONYMOUS); |
Chuck Lever | 6871790 | 2010-01-26 14:04:13 -0500 | [diff] [blame] | 1009 | if (err < 0) |
Chuck Lever | 3749829 | 2010-01-26 14:04:22 -0500 | [diff] [blame] | 1010 | goto out_err; |
| 1011 | |
| 1012 | err = svc_create_xprt(nfsd_serv, transport, |
| 1013 | PF_INET6, port, SVC_SOCK_ANONYMOUS); |
| 1014 | if (err < 0 && err != -EAFNOSUPPORT) |
| 1015 | goto out_close; |
Chuck Lever | 4eb68c2 | 2009-04-23 19:31:40 -0400 | [diff] [blame] | 1016 | return 0; |
Chuck Lever | 3749829 | 2010-01-26 14:04:22 -0500 | [diff] [blame] | 1017 | out_close: |
| 1018 | xprt = svc_find_xprt(nfsd_serv, transport, PF_INET, port); |
| 1019 | if (xprt != NULL) { |
| 1020 | svc_close_xprt(xprt); |
| 1021 | svc_xprt_put(xprt); |
| 1022 | } |
| 1023 | out_err: |
| 1024 | /* Decrease the count, but don't shut down the service */ |
| 1025 | nfsd_serv->sv_nrthreads--; |
| 1026 | return err; |
Chuck Lever | 4eb68c2 | 2009-04-23 19:31:40 -0400 | [diff] [blame] | 1027 | } |
| 1028 | |
| 1029 | /* |
Chuck Lever | 4cd5dc7 | 2009-04-23 19:31:32 -0400 | [diff] [blame] | 1030 | * A transport listener is removed by writing a "-", it's transport |
| 1031 | * name, and it's port number. |
| 1032 | */ |
| 1033 | static ssize_t __write_ports_delxprt(char *buf) |
| 1034 | { |
| 1035 | struct svc_xprt *xprt; |
| 1036 | char transport[16]; |
| 1037 | int port; |
| 1038 | |
| 1039 | if (sscanf(&buf[1], "%15s %4u", transport, &port) != 2) |
| 1040 | return -EINVAL; |
| 1041 | |
| 1042 | if (port < 1 || port > USHORT_MAX || nfsd_serv == NULL) |
| 1043 | return -EINVAL; |
| 1044 | |
| 1045 | xprt = svc_find_xprt(nfsd_serv, transport, AF_UNSPEC, port); |
| 1046 | if (xprt == NULL) |
| 1047 | return -ENOTCONN; |
| 1048 | |
| 1049 | svc_close_xprt(xprt); |
| 1050 | svc_xprt_put(xprt); |
| 1051 | return 0; |
| 1052 | } |
| 1053 | |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 1054 | static ssize_t __write_ports(struct file *file, char *buf, size_t size) |
NeilBrown | 80212d5 | 2006-10-02 02:17:47 -0700 | [diff] [blame] | 1055 | { |
Chuck Lever | 0a5372d | 2009-04-23 19:32:10 -0400 | [diff] [blame] | 1056 | if (size == 0) |
| 1057 | return __write_ports_names(buf); |
Chuck Lever | 0b7c2f6 | 2009-04-23 19:31:55 -0400 | [diff] [blame] | 1058 | |
| 1059 | if (isdigit(buf[0])) |
| 1060 | return __write_ports_addfd(buf); |
Chuck Lever | 82d5659 | 2009-04-23 19:31:48 -0400 | [diff] [blame] | 1061 | |
| 1062 | if (buf[0] == '-' && isdigit(buf[1])) |
| 1063 | return __write_ports_delfd(buf); |
Chuck Lever | 4eb68c2 | 2009-04-23 19:31:40 -0400 | [diff] [blame] | 1064 | |
| 1065 | if (isalpha(buf[0])) |
| 1066 | return __write_ports_addxprt(buf); |
Chuck Lever | 4cd5dc7 | 2009-04-23 19:31:32 -0400 | [diff] [blame] | 1067 | |
| 1068 | if (buf[0] == '-' && isalpha(buf[1])) |
| 1069 | return __write_ports_delxprt(buf); |
| 1070 | |
NeilBrown | b41b66d | 2006-10-02 02:17:48 -0700 | [diff] [blame] | 1071 | return -EINVAL; |
NeilBrown | 80212d5 | 2006-10-02 02:17:47 -0700 | [diff] [blame] | 1072 | } |
| 1073 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 1074 | /** |
| 1075 | * write_ports - Pass a socket file descriptor or transport name to listen on |
| 1076 | * |
| 1077 | * Input: |
| 1078 | * buf: ignored |
| 1079 | * size: zero |
| 1080 | * Output: |
| 1081 | * On success: passed-in buffer filled with a '\n'-terminated C |
| 1082 | * string containing a whitespace-separated list of |
| 1083 | * named NFSD listeners; |
| 1084 | * return code is the size in bytes of the string |
| 1085 | * On error: return code is zero or a negative errno value |
| 1086 | * |
| 1087 | * OR |
| 1088 | * |
| 1089 | * Input: |
| 1090 | * buf: C string containing an unsigned |
| 1091 | * integer value representing a bound |
| 1092 | * but unconnected socket that is to be |
Chuck Lever | c71206a | 2009-04-23 19:32:03 -0400 | [diff] [blame] | 1093 | * used as an NFSD listener; listen(3) |
| 1094 | * must be called for a SOCK_STREAM |
| 1095 | * socket, otherwise it is ignored |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 1096 | * size: non-zero length of C string in @buf |
| 1097 | * Output: |
| 1098 | * On success: NFS service is started; |
| 1099 | * passed-in buffer filled with a '\n'-terminated C |
| 1100 | * string containing a unique alphanumeric name of |
| 1101 | * the listener; |
| 1102 | * return code is the size in bytes of the string |
| 1103 | * On error: return code is a negative errno value |
| 1104 | * |
| 1105 | * OR |
| 1106 | * |
| 1107 | * Input: |
| 1108 | * buf: C string containing a "-" followed |
| 1109 | * by an integer value representing a |
| 1110 | * previously passed in socket file |
| 1111 | * descriptor |
| 1112 | * size: non-zero length of C string in @buf |
| 1113 | * Output: |
| 1114 | * On success: NFS service no longer listens on that socket; |
| 1115 | * passed-in buffer filled with a '\n'-terminated C |
| 1116 | * string containing a unique name of the listener; |
| 1117 | * return code is the size in bytes of the string |
| 1118 | * On error: return code is a negative errno value |
| 1119 | * |
| 1120 | * OR |
| 1121 | * |
| 1122 | * Input: |
| 1123 | * buf: C string containing a transport |
| 1124 | * name and an unsigned integer value |
| 1125 | * representing the port to listen on, |
| 1126 | * separated by whitespace |
| 1127 | * size: non-zero length of C string in @buf |
| 1128 | * Output: |
| 1129 | * On success: returns zero; NFS service is started |
| 1130 | * On error: return code is a negative errno value |
| 1131 | * |
| 1132 | * OR |
| 1133 | * |
| 1134 | * Input: |
| 1135 | * buf: C string containing a "-" followed |
| 1136 | * by a transport name and an unsigned |
| 1137 | * integer value representing the port |
| 1138 | * to listen on, separated by whitespace |
| 1139 | * size: non-zero length of C string in @buf |
| 1140 | * Output: |
| 1141 | * On success: returns zero; NFS service no longer listens |
| 1142 | * on that transport |
| 1143 | * On error: return code is a negative errno value |
| 1144 | */ |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 1145 | static ssize_t write_ports(struct file *file, char *buf, size_t size) |
| 1146 | { |
| 1147 | ssize_t rv; |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1148 | |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 1149 | mutex_lock(&nfsd_mutex); |
| 1150 | rv = __write_ports(file, buf, size); |
| 1151 | mutex_unlock(&nfsd_mutex); |
| 1152 | return rv; |
| 1153 | } |
| 1154 | |
| 1155 | |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 1156 | int nfsd_max_blksize; |
| 1157 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 1158 | /** |
| 1159 | * write_maxblksize - Set or report the current NFS blksize |
| 1160 | * |
| 1161 | * Input: |
| 1162 | * buf: ignored |
| 1163 | * size: zero |
| 1164 | * |
| 1165 | * OR |
| 1166 | * |
| 1167 | * Input: |
| 1168 | * buf: C string containing an unsigned |
| 1169 | * integer value representing the new |
| 1170 | * NFS blksize |
| 1171 | * size: non-zero length of C string in @buf |
| 1172 | * Output: |
| 1173 | * On success: passed-in buffer filled with '\n'-terminated C string |
| 1174 | * containing numeric value of the current NFS blksize |
| 1175 | * setting; |
| 1176 | * return code is the size in bytes of the string |
| 1177 | * On error: return code is zero or a negative errno value |
| 1178 | */ |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 1179 | static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) |
| 1180 | { |
| 1181 | char *mesg = buf; |
| 1182 | if (size > 0) { |
| 1183 | int bsize; |
| 1184 | int rv = get_int(&mesg, &bsize); |
| 1185 | if (rv) |
| 1186 | return rv; |
| 1187 | /* force bsize into allowed range and |
| 1188 | * required alignment. |
| 1189 | */ |
| 1190 | if (bsize < 1024) |
| 1191 | bsize = 1024; |
| 1192 | if (bsize > NFSSVC_MAXBLKSIZE) |
| 1193 | bsize = NFSSVC_MAXBLKSIZE; |
| 1194 | bsize &= ~(1024-1); |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 1195 | mutex_lock(&nfsd_mutex); |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 1196 | if (nfsd_serv && nfsd_serv->sv_nrthreads) { |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 1197 | mutex_unlock(&nfsd_mutex); |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 1198 | return -EBUSY; |
| 1199 | } |
| 1200 | nfsd_max_blksize = bsize; |
Neil Brown | bedbdd8 | 2008-06-10 08:40:35 -0400 | [diff] [blame] | 1201 | mutex_unlock(&nfsd_mutex); |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 1202 | } |
Chuck Lever | e06b640 | 2009-04-23 19:33:25 -0400 | [diff] [blame] | 1203 | |
| 1204 | return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%d\n", |
| 1205 | nfsd_max_blksize); |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 1206 | } |
| 1207 | |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 1208 | #ifdef CONFIG_NFSD_V4 |
J. Bruce Fields | f013574 | 2010-03-01 19:32:36 -0500 | [diff] [blame] | 1209 | static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size, time_t *time) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1210 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1211 | char *mesg = buf; |
J. Bruce Fields | f013574 | 2010-03-01 19:32:36 -0500 | [diff] [blame] | 1212 | int rv, i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1213 | |
| 1214 | if (size > 0) { |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1215 | if (nfsd_serv) |
| 1216 | return -EBUSY; |
J. Bruce Fields | f013574 | 2010-03-01 19:32:36 -0500 | [diff] [blame] | 1217 | rv = get_int(&mesg, &i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1218 | if (rv) |
| 1219 | return rv; |
J. Bruce Fields | e7b184f | 2010-03-02 11:18:40 -0500 | [diff] [blame^] | 1220 | /* |
| 1221 | * Some sanity checking. We don't have a reason for |
| 1222 | * these particular numbers, but problems with the |
| 1223 | * extremes are: |
| 1224 | * - Too short: the briefest network outage may |
| 1225 | * cause clients to lose all their locks. Also, |
| 1226 | * the frequent polling may be wasteful. |
| 1227 | * - Too long: do you really want reboot recovery |
| 1228 | * to take more than an hour? Or to make other |
| 1229 | * clients wait an hour before being able to |
| 1230 | * revoke a dead client's locks? |
| 1231 | */ |
J. Bruce Fields | f013574 | 2010-03-01 19:32:36 -0500 | [diff] [blame] | 1232 | if (i < 10 || i > 3600) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1233 | return -EINVAL; |
J. Bruce Fields | f013574 | 2010-03-01 19:32:36 -0500 | [diff] [blame] | 1234 | *time = i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1235 | } |
Chuck Lever | e06b640 | 2009-04-23 19:33:25 -0400 | [diff] [blame] | 1236 | |
J. Bruce Fields | f013574 | 2010-03-01 19:32:36 -0500 | [diff] [blame] | 1237 | return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%ld\n", *time); |
| 1238 | } |
| 1239 | |
| 1240 | static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size, time_t *time) |
| 1241 | { |
| 1242 | ssize_t rv; |
| 1243 | |
| 1244 | mutex_lock(&nfsd_mutex); |
| 1245 | rv = __nfsd4_write_time(file, buf, size, time); |
| 1246 | mutex_unlock(&nfsd_mutex); |
| 1247 | return rv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1248 | } |
| 1249 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 1250 | /** |
| 1251 | * write_leasetime - Set or report the current NFSv4 lease time |
| 1252 | * |
| 1253 | * Input: |
| 1254 | * buf: ignored |
| 1255 | * size: zero |
| 1256 | * |
| 1257 | * OR |
| 1258 | * |
| 1259 | * Input: |
| 1260 | * buf: C string containing an unsigned |
| 1261 | * integer value representing the new |
| 1262 | * NFSv4 lease expiry time |
| 1263 | * size: non-zero length of C string in @buf |
| 1264 | * Output: |
| 1265 | * On success: passed-in buffer filled with '\n'-terminated C |
| 1266 | * string containing unsigned integer value of the |
| 1267 | * current lease expiry time; |
| 1268 | * return code is the size in bytes of the string |
| 1269 | * On error: return code is zero or a negative errno value |
| 1270 | */ |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1271 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size) |
| 1272 | { |
J. Bruce Fields | f013574 | 2010-03-01 19:32:36 -0500 | [diff] [blame] | 1273 | return nfsd4_write_time(file, buf, size, &nfsd4_lease); |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1274 | } |
| 1275 | |
J. Bruce Fields | efc4bb4f | 2010-03-02 11:04:06 -0500 | [diff] [blame] | 1276 | /** |
| 1277 | * write_gracetime - Set or report current NFSv4 grace period time |
| 1278 | * |
| 1279 | * As above, but sets the time of the NFSv4 grace period. |
| 1280 | * |
| 1281 | * Note this should never be set to less than the *previous* |
| 1282 | * lease-period time, but we don't try to enforce this. (In the common |
| 1283 | * case (a new boot), we don't know what the previous lease time was |
| 1284 | * anyway.) |
| 1285 | */ |
| 1286 | static ssize_t write_gracetime(struct file *file, char *buf, size_t size) |
| 1287 | { |
| 1288 | return nfsd4_write_time(file, buf, size, &nfsd4_grace); |
| 1289 | } |
| 1290 | |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1291 | extern char *nfs4_recoverydir(void); |
| 1292 | |
| 1293 | static ssize_t __write_recoverydir(struct file *file, char *buf, size_t size) |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 1294 | { |
| 1295 | char *mesg = buf; |
| 1296 | char *recdir; |
| 1297 | int len, status; |
| 1298 | |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1299 | if (size > 0) { |
| 1300 | if (nfsd_serv) |
| 1301 | return -EBUSY; |
| 1302 | if (size > PATH_MAX || buf[size-1] != '\n') |
| 1303 | return -EINVAL; |
| 1304 | buf[size-1] = 0; |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 1305 | |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1306 | recdir = mesg; |
| 1307 | len = qword_get(&mesg, recdir, size); |
| 1308 | if (len <= 0) |
| 1309 | return -EINVAL; |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 1310 | |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1311 | status = nfs4_reset_recoverydir(recdir); |
| 1312 | } |
Chuck Lever | 3d72ab8 | 2009-04-23 19:33:10 -0400 | [diff] [blame] | 1313 | |
| 1314 | return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%s\n", |
| 1315 | nfs4_recoverydir()); |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 1316 | } |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1317 | |
Chuck Lever | 262a098 | 2008-12-12 16:57:35 -0500 | [diff] [blame] | 1318 | /** |
| 1319 | * write_recoverydir - Set or report the pathname of the recovery directory |
| 1320 | * |
| 1321 | * Input: |
| 1322 | * buf: ignored |
| 1323 | * size: zero |
| 1324 | * |
| 1325 | * OR |
| 1326 | * |
| 1327 | * Input: |
| 1328 | * buf: C string containing the pathname |
| 1329 | * of the directory on a local file |
| 1330 | * system containing permanent NFSv4 |
| 1331 | * recovery data |
| 1332 | * size: non-zero length of C string in @buf |
| 1333 | * Output: |
| 1334 | * On success: passed-in buffer filled with '\n'-terminated C string |
| 1335 | * containing the current recovery pathname setting; |
| 1336 | * return code is the size in bytes of the string |
| 1337 | * On error: return code is zero or a negative errno value |
| 1338 | */ |
Jeff Layton | 3dd98a3 | 2008-06-10 08:40:36 -0400 | [diff] [blame] | 1339 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size) |
| 1340 | { |
| 1341 | ssize_t rv; |
| 1342 | |
| 1343 | mutex_lock(&nfsd_mutex); |
| 1344 | rv = __write_recoverydir(file, buf, size); |
| 1345 | mutex_unlock(&nfsd_mutex); |
| 1346 | return rv; |
| 1347 | } |
| 1348 | |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 1349 | #endif |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 1350 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1351 | /*----------------------------------------------------------------------------*/ |
| 1352 | /* |
| 1353 | * populating the filesystem. |
| 1354 | */ |
| 1355 | |
| 1356 | static int nfsd_fill_super(struct super_block * sb, void * data, int silent) |
| 1357 | { |
| 1358 | static struct tree_descr nfsd_files[] = { |
| 1359 | [NFSD_Svc] = {".svc", &transaction_ops, S_IWUSR}, |
| 1360 | [NFSD_Add] = {".add", &transaction_ops, S_IWUSR}, |
| 1361 | [NFSD_Del] = {".del", &transaction_ops, S_IWUSR}, |
| 1362 | [NFSD_Export] = {".export", &transaction_ops, S_IWUSR}, |
| 1363 | [NFSD_Unexport] = {".unexport", &transaction_ops, S_IWUSR}, |
| 1364 | [NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR}, |
| 1365 | [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR}, |
| 1366 | [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, |
J. Bruce Fields | e8e8753 | 2009-12-14 12:53:32 -0500 | [diff] [blame] | 1367 | [NFSD_Export_features] = {"export_features", |
| 1368 | &export_features_operations, S_IRUGO}, |
Wendy Cheng | 4373ea8 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 1369 | [NFSD_FO_UnlockIP] = {"unlock_ip", |
| 1370 | &transaction_ops, S_IWUSR|S_IRUSR}, |
Wendy Cheng | 17efa37 | 2008-01-17 11:10:12 -0500 | [diff] [blame] | 1371 | [NFSD_FO_UnlockFS] = {"unlock_filesystem", |
| 1372 | &transaction_ops, S_IWUSR|S_IRUSR}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1373 | [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, |
| 1374 | [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, |
Greg Banks | eed2965 | 2006-10-02 02:18:02 -0700 | [diff] [blame] | 1375 | [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR}, |
Greg Banks | 03cf6c9 | 2009-01-13 21:26:36 +1100 | [diff] [blame] | 1376 | [NFSD_Pool_Stats] = {"pool_stats", &pool_stats_operations, S_IRUGO}, |
NeilBrown | 70c3b76 | 2005-11-07 01:00:25 -0800 | [diff] [blame] | 1377 | [NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR}, |
NeilBrown | 80212d5 | 2006-10-02 02:17:47 -0700 | [diff] [blame] | 1378 | [NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO}, |
NeilBrown | 596bbe5 | 2006-10-04 02:15:48 -0700 | [diff] [blame] | 1379 | [NFSD_MaxBlkSize] = {"max_block_size", &transaction_ops, S_IWUSR|S_IRUGO}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1380 | #ifdef CONFIG_NFSD_V4 |
| 1381 | [NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR}, |
J. Bruce Fields | efc4bb4f | 2010-03-02 11:04:06 -0500 | [diff] [blame] | 1382 | [NFSD_Gracetime] = {"nfsv4gracetime", &transaction_ops, S_IWUSR|S_IRUSR}, |
NeilBrown | 0964a3d | 2005-06-23 22:04:32 -0700 | [diff] [blame] | 1383 | [NFSD_RecoveryDir] = {"nfsv4recoverydir", &transaction_ops, S_IWUSR|S_IRUSR}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1384 | #endif |
| 1385 | /* last one */ {""} |
| 1386 | }; |
| 1387 | return simple_fill_super(sb, 0x6e667364, nfsd_files); |
| 1388 | } |
| 1389 | |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1390 | static int nfsd_get_sb(struct file_system_type *fs_type, |
| 1391 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1392 | { |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1393 | return get_sb_single(fs_type, flags, data, nfsd_fill_super, mnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1394 | } |
| 1395 | |
| 1396 | static struct file_system_type nfsd_fs_type = { |
| 1397 | .owner = THIS_MODULE, |
| 1398 | .name = "nfsd", |
| 1399 | .get_sb = nfsd_get_sb, |
| 1400 | .kill_sb = kill_litter_super, |
| 1401 | }; |
| 1402 | |
J. Bruce Fields | e331f60 | 2007-11-12 17:32:21 -0500 | [diff] [blame] | 1403 | #ifdef CONFIG_PROC_FS |
| 1404 | static int create_proc_exports_entry(void) |
| 1405 | { |
| 1406 | struct proc_dir_entry *entry; |
| 1407 | |
| 1408 | entry = proc_mkdir("fs/nfs", NULL); |
| 1409 | if (!entry) |
| 1410 | return -ENOMEM; |
Denis V. Lunev | 9ef2db2 | 2008-04-29 01:02:04 -0700 | [diff] [blame] | 1411 | entry = proc_create("exports", 0, entry, &exports_operations); |
J. Bruce Fields | e331f60 | 2007-11-12 17:32:21 -0500 | [diff] [blame] | 1412 | if (!entry) |
| 1413 | return -ENOMEM; |
J. Bruce Fields | e331f60 | 2007-11-12 17:32:21 -0500 | [diff] [blame] | 1414 | return 0; |
| 1415 | } |
| 1416 | #else /* CONFIG_PROC_FS */ |
| 1417 | static int create_proc_exports_entry(void) |
| 1418 | { |
| 1419 | return 0; |
| 1420 | } |
| 1421 | #endif |
| 1422 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | static int __init init_nfsd(void) |
| 1424 | { |
| 1425 | int retval; |
| 1426 | printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n"); |
| 1427 | |
J. Bruce Fields | e8ff2a8 | 2007-08-01 15:30:59 -0400 | [diff] [blame] | 1428 | retval = nfs4_state_init(); /* nfs4 locking state */ |
| 1429 | if (retval) |
| 1430 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1431 | nfsd_stat_init(); /* Statistics */ |
J. Bruce Fields | d5c3428 | 2007-11-09 14:10:56 -0500 | [diff] [blame] | 1432 | retval = nfsd_reply_cache_init(); |
| 1433 | if (retval) |
| 1434 | goto out_free_stat; |
J. Bruce Fields | dbf847e | 2007-11-08 17:20:34 -0500 | [diff] [blame] | 1435 | retval = nfsd_export_init(); |
| 1436 | if (retval) |
| 1437 | goto out_free_cache; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1438 | nfsd_lockd_init(); /* lockd->nfsd callbacks */ |
J. Bruce Fields | dbf847e | 2007-11-08 17:20:34 -0500 | [diff] [blame] | 1439 | retval = nfsd_idmap_init(); |
| 1440 | if (retval) |
| 1441 | goto out_free_lockd; |
J. Bruce Fields | e331f60 | 2007-11-12 17:32:21 -0500 | [diff] [blame] | 1442 | retval = create_proc_exports_entry(); |
| 1443 | if (retval) |
| 1444 | goto out_free_idmap; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1445 | retval = register_filesystem(&nfsd_fs_type); |
J. Bruce Fields | 26808d3 | 2007-11-09 13:44:06 -0500 | [diff] [blame] | 1446 | if (retval) |
| 1447 | goto out_free_all; |
| 1448 | return 0; |
| 1449 | out_free_all: |
J. Bruce Fields | 26808d3 | 2007-11-09 13:44:06 -0500 | [diff] [blame] | 1450 | remove_proc_entry("fs/nfs/exports", NULL); |
| 1451 | remove_proc_entry("fs/nfs", NULL); |
J. Bruce Fields | e331f60 | 2007-11-12 17:32:21 -0500 | [diff] [blame] | 1452 | out_free_idmap: |
J. Bruce Fields | dbf847e | 2007-11-08 17:20:34 -0500 | [diff] [blame] | 1453 | nfsd_idmap_shutdown(); |
| 1454 | out_free_lockd: |
J. Bruce Fields | 26808d3 | 2007-11-09 13:44:06 -0500 | [diff] [blame] | 1455 | nfsd_lockd_shutdown(); |
J. Bruce Fields | e331f60 | 2007-11-12 17:32:21 -0500 | [diff] [blame] | 1456 | nfsd_export_shutdown(); |
J. Bruce Fields | dbf847e | 2007-11-08 17:20:34 -0500 | [diff] [blame] | 1457 | out_free_cache: |
J. Bruce Fields | e331f60 | 2007-11-12 17:32:21 -0500 | [diff] [blame] | 1458 | nfsd_reply_cache_shutdown(); |
J. Bruce Fields | d5c3428 | 2007-11-09 14:10:56 -0500 | [diff] [blame] | 1459 | out_free_stat: |
| 1460 | nfsd_stat_shutdown(); |
J. Bruce Fields | 26808d3 | 2007-11-09 13:44:06 -0500 | [diff] [blame] | 1461 | nfsd4_free_slabs(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | return retval; |
| 1463 | } |
| 1464 | |
| 1465 | static void __exit exit_nfsd(void) |
| 1466 | { |
| 1467 | nfsd_export_shutdown(); |
J. Bruce Fields | d5c3428 | 2007-11-09 14:10:56 -0500 | [diff] [blame] | 1468 | nfsd_reply_cache_shutdown(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1469 | remove_proc_entry("fs/nfs/exports", NULL); |
| 1470 | remove_proc_entry("fs/nfs", NULL); |
| 1471 | nfsd_stat_shutdown(); |
| 1472 | nfsd_lockd_shutdown(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | nfsd_idmap_shutdown(); |
J. Bruce Fields | e8ff2a8 | 2007-08-01 15:30:59 -0400 | [diff] [blame] | 1474 | nfsd4_free_slabs(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1475 | unregister_filesystem(&nfsd_fs_type); |
| 1476 | } |
| 1477 | |
| 1478 | MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>"); |
| 1479 | MODULE_LICENSE("GPL"); |
| 1480 | module_init(init_nfsd) |
| 1481 | module_exit(exit_nfsd) |