]> bbs.cooldavid.org Git - net-next-2.6.git/blame - fs/nfsd/nfsfh.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-2.6-dm
[net-next-2.6.git] / fs / nfsd / nfsfh.c
CommitLineData
1da177e4
LT
1/*
2 * linux/fs/nfsd/nfsfh.c
3 *
4 * NFS server file handle treatment.
5 *
6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
7 * Portions Copyright (C) 1999 G. Allen Morris III <gam3@acm.org>
8 * Extensive rewrite by Neil Brown <neilb@cse.unsw.edu.au> Southern-Spring 1999
9 * ... and again Southern-Winter 2001 to support export_operations
10 */
11
1da177e4 12#include <linux/slab.h>
1da177e4
LT
13#include <linux/fs.h>
14#include <linux/unistd.h>
15#include <linux/string.h>
16#include <linux/stat.h>
17#include <linux/dcache.h>
a5694255 18#include <linux/exportfs.h>
1da177e4 19#include <linux/mount.h>
1da177e4 20
ad06e4bd 21#include <linux/sunrpc/clnt.h>
1da177e4 22#include <linux/sunrpc/svc.h>
32c1eb0c 23#include <linux/sunrpc/svcauth_gss.h>
1da177e4 24#include <linux/nfsd/nfsd.h>
2e8138a2 25#include "auth.h"
1da177e4
LT
26
27#define NFSDDBG_FACILITY NFSDDBG_FH
1da177e4
LT
28
29
30static int nfsd_nr_verified;
31static int nfsd_nr_put;
32
1da177e4
LT
33/*
34 * our acceptability function.
35 * if NOSUBTREECHECK, accept anything
36 * if not, require that we can walk up to exp->ex_dentry
37 * doing some checks on the 'x' bits
38 */
39static int nfsd_acceptable(void *expv, struct dentry *dentry)
40{
41 struct svc_export *exp = expv;
42 int rv;
43 struct dentry *tdentry;
44 struct dentry *parent;
45
46 if (exp->ex_flags & NFSEXP_NOSUBTREECHECK)
47 return 1;
48
49 tdentry = dget(dentry);
54775491 50 while (tdentry != exp->ex_path.dentry && !IS_ROOT(tdentry)) {
1da177e4
LT
51 /* make sure parents give x permission to user */
52 int err;
53 parent = dget_parent(tdentry);
f419a2e3 54 err = inode_permission(parent->d_inode, MAY_EXEC);
1da177e4
LT
55 if (err < 0) {
56 dput(parent);
57 break;
58 }
59 dput(tdentry);
60 tdentry = parent;
61 }
54775491 62 if (tdentry != exp->ex_path.dentry)
1da177e4 63 dprintk("nfsd_acceptable failed at %p %s\n", tdentry, tdentry->d_name.name);
54775491 64 rv = (tdentry == exp->ex_path.dentry);
1da177e4
LT
65 dput(tdentry);
66 return rv;
67}
68
69/* Type check. The correct error return for type mismatches does not seem to be
70 * generally agreed upon. SunOS seems to use EISDIR if file isn't S_IFREG; a
71 * comment in the NFSv3 spec says this is incorrect (implementation notes for
72 * the write call).
73 */
83b11340 74static inline __be32
1da177e4
LT
75nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int type)
76{
77 /* Type can be negative when creating hardlinks - not to a dir */
78 if (type > 0 && (mode & S_IFMT) != type) {
79 if (rqstp->rq_vers == 4 && (mode & S_IFMT) == S_IFLNK)
80 return nfserr_symlink;
81 else if (type == S_IFDIR)
82 return nfserr_notdir;
83 else if ((mode & S_IFMT) == S_IFDIR)
84 return nfserr_isdir;
85 else
86 return nfserr_inval;
87 }
88 if (type < 0 && (mode & S_IFMT) == -type) {
89 if (rqstp->rq_vers == 4 && (mode & S_IFMT) == S_IFLNK)
90 return nfserr_symlink;
91 else if (type == -S_IFDIR)
92 return nfserr_isdir;
93 else
94 return nfserr_notdir;
95 }
96 return 0;
97}
98
6fa02839
BF
99static __be32 nfsd_setuser_and_check_port(struct svc_rqst *rqstp,
100 struct svc_export *exp)
101{
102 /* Check if the request originated from a secure port. */
103 if (!rqstp->rq_secure && EX_SECURE(exp)) {
5216a8e7 104 RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
6fa02839
BF
105 dprintk(KERN_WARNING
106 "nfsd: request from insecure port %s!\n",
107 svc_print_addr(rqstp, buf, sizeof(buf)));
108 return nfserr_perm;
109 }
110
111 /* Set user creds for this exportpoint */
112 return nfserrno(nfsd_setuser(rqstp, exp));
113}
114
03550fac
BF
115/*
116 * Use the given filehandle to look up the corresponding export and
117 * dentry. On success, the results are used to set fh_export and
118 * fh_dentry.
119 */
120static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
121{
122 struct knfsd_fh *fh = &fhp->fh_handle;
123 struct fid *fid = NULL, sfid;
124 struct svc_export *exp;
125 struct dentry *dentry;
126 int fileid_type;
127 int data_left = fh->fh_size/4;
128 __be32 error;
129
130 error = nfserr_stale;
131 if (rqstp->rq_vers > 2)
132 error = nfserr_badhandle;
133 if (rqstp->rq_vers == 4 && fh->fh_size == 0)
134 return nfserr_nofilehandle;
135
136 if (fh->fh_version == 1) {
137 int len;
138
139 if (--data_left < 0)
140 return error;
141 if (fh->fh_auth_type != 0)
142 return error;
143 len = key_len(fh->fh_fsid_type) / 4;
144 if (len == 0)
145 return error;
146 if (fh->fh_fsid_type == FSID_MAJOR_MINOR) {
147 /* deprecated, convert to type 3 */
148 len = key_len(FSID_ENCODE_DEV)/4;
149 fh->fh_fsid_type = FSID_ENCODE_DEV;
150 fh->fh_fsid[0] = new_encode_dev(MKDEV(ntohl(fh->fh_fsid[0]), ntohl(fh->fh_fsid[1])));
151 fh->fh_fsid[1] = fh->fh_fsid[2];
152 }
153 data_left -= len;
154 if (data_left < 0)
155 return error;
156 exp = rqst_exp_find(rqstp, fh->fh_fsid_type, fh->fh_auth);
157 fid = (struct fid *)(fh->fh_auth + len);
158 } else {
159 __u32 tfh[2];
160 dev_t xdev;
161 ino_t xino;
162
163 if (fh->fh_size != NFS_FHSIZE)
164 return error;
165 /* assume old filehandle format */
166 xdev = old_decode_dev(fh->ofh_xdev);
167 xino = u32_to_ino_t(fh->ofh_xino);
168 mk_fsid(FSID_DEV, tfh, xdev, xino, 0, NULL);
169 exp = rqst_exp_find(rqstp, FSID_DEV, tfh);
170 }
171
172 error = nfserr_stale;
173 if (PTR_ERR(exp) == -ENOENT)
174 return error;
175
176 if (IS_ERR(exp))
177 return nfserrno(PTR_ERR(exp));
178
496d6c32
NB
179 if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) {
180 /* Elevate privileges so that the lack of 'r' or 'x'
181 * permission on some parent directory will
182 * not stop exportfs_decode_fh from being able
183 * to reconnect a directory into the dentry cache.
184 * The same problem can affect "SUBTREECHECK" exports,
185 * but as nfsd_acceptable depends on correct
186 * access control settings being in effect, we cannot
187 * fix that case easily.
188 */
d84f4f99
DH
189 struct cred *new = prepare_creds();
190 if (!new)
191 return nfserrno(-ENOMEM);
192 new->cap_effective =
193 cap_raise_nfsd_set(new->cap_effective,
194 new->cap_permitted);
195 put_cred(override_creds(new));
196 put_cred(new);
496d6c32
NB
197 } else {
198 error = nfsd_setuser_and_check_port(rqstp, exp);
199 if (error)
200 goto out;
201 }
03550fac
BF
202
203 /*
204 * Look up the dentry using the NFS file handle.
205 */
206 error = nfserr_stale;
207 if (rqstp->rq_vers > 2)
208 error = nfserr_badhandle;
209
210 if (fh->fh_version != 1) {
211 sfid.i32.ino = fh->ofh_ino;
212 sfid.i32.gen = fh->ofh_generation;
213 sfid.i32.parent_ino = fh->ofh_dirino;
214 fid = &sfid;
215 data_left = 3;
216 if (fh->ofh_dirino == 0)
217 fileid_type = FILEID_INO32_GEN;
218 else
219 fileid_type = FILEID_INO32_GEN_PARENT;
220 } else
221 fileid_type = fh->fh_fileid_type;
222
223 if (fileid_type == FILEID_ROOT)
224 dentry = dget(exp->ex_path.dentry);
225 else {
226 dentry = exportfs_decode_fh(exp->ex_path.mnt, fid,
227 data_left, fileid_type,
228 nfsd_acceptable, exp);
229 }
230 if (dentry == NULL)
231 goto out;
232 if (IS_ERR(dentry)) {
233 if (PTR_ERR(dentry) != -EINVAL)
234 error = nfserrno(PTR_ERR(dentry));
235 goto out;
236 }
237
496d6c32
NB
238 if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) {
239 error = nfsd_setuser_and_check_port(rqstp, exp);
240 if (error) {
241 dput(dentry);
242 goto out;
243 }
244 }
245
03550fac
BF
246 if (S_ISDIR(dentry->d_inode->i_mode) &&
247 (dentry->d_flags & DCACHE_DISCONNECTED)) {
248 printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %s/%s\n",
249 dentry->d_parent->d_name.name, dentry->d_name.name);
250 }
251
252 fhp->fh_dentry = dentry;
253 fhp->fh_export = exp;
254 nfsd_nr_verified++;
255 return 0;
256out:
257 exp_put(exp);
258 return error;
259}
260
1da177e4
LT
261/*
262 * Perform sanity checks on the dentry in a client's file handle.
263 *
264 * Note that the file handle dentry may need to be freed even after
265 * an error return.
266 *
267 * This is only called at the start of an nfsproc call, so fhp points to
268 * a svc_fh which is all 0 except for the over-the-wire file handle.
269 */
83b11340 270__be32
1da177e4
LT
271fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
272{
03550fac 273 struct svc_export *exp;
1da177e4 274 struct dentry *dentry;
03550fac 275 __be32 error;
1da177e4
LT
276
277 dprintk("nfsd: fh_verify(%s)\n", SVCFH_fmt(fhp));
278
1da177e4 279 if (!fhp->fh_dentry) {
03550fac 280 error = nfsd_set_fh_dentry(rqstp, fhp);
d1bbf14f
N
281 if (error)
282 goto out;
03550fac
BF
283 dentry = fhp->fh_dentry;
284 exp = fhp->fh_export;
1da177e4 285 } else {
6fa02839
BF
286 /*
287 * just rechecking permissions
288 * (e.g. nfsproc_create calls fh_verify, then nfsd_create
289 * does as well)
1da177e4
LT
290 */
291 dprintk("nfsd: fh_verify - just checking\n");
292 dentry = fhp->fh_dentry;
293 exp = fhp->fh_export;
6fa02839
BF
294 /*
295 * Set user creds for this exportpoint; necessary even
d1bbf14f
N
296 * in the "just checking" case because this may be a
297 * filehandle that was created by fh_compose, and that
298 * is about to be used in another nfsv4 compound
6fa02839
BF
299 * operation.
300 */
301 error = nfsd_setuser_and_check_port(rqstp, exp);
d1bbf14f
N
302 if (error)
303 goto out;
1da177e4 304 }
7fc90ec9 305
1da177e4
LT
306 error = nfsd_mode_check(rqstp, dentry->d_inode->i_mode, type);
307 if (error)
308 goto out;
309
04716e66
BF
310 /*
311 * pseudoflavor restrictions are not enforced on NLM,
312 * which clients virtually always use auth_sys for,
313 * even while using RPCSEC_GSS for NFS.
314 */
315 if (access & NFSD_MAY_LOCK)
316 goto skip_pseudoflavor_check;
317 /*
318 * Clients may expect to be able to use auth_sys during mount,
319 * even if they use gss for everything else; see section 2.3.2
320 * of rfc 2623.
321 */
322 if (access & NFSD_MAY_BYPASS_GSS_ON_ROOT
323 && exp->ex_path.dentry == dentry)
324 goto skip_pseudoflavor_check;
325
326 error = check_nfsd_access(exp, rqstp);
327 if (error)
328 goto out;
32c1eb0c 329
04716e66 330skip_pseudoflavor_check:
1da177e4 331 /* Finally, check access permissions. */
0ec757df 332 error = nfsd_permission(rqstp, exp, dentry, access);
1da177e4 333
1da177e4 334 if (error) {
34e9a63b
N
335 dprintk("fh_verify: %s/%s permission failure, "
336 "acc=%x, error=%d\n",
337 dentry->d_parent->d_name.name,
338 dentry->d_name.name,
fc2dd2e5 339 access, ntohl(error));
1da177e4 340 }
1da177e4 341out:
1da177e4
LT
342 if (error == nfserr_stale)
343 nfsdstats.fh_stale++;
344 return error;
345}
346
347
348/*
349 * Compose a file handle for an NFS reply.
350 *
351 * Note that when first composed, the dentry may not yet have
352 * an inode. In this case a call to fh_update should be made
353 * before the fh goes out on the wire ...
354 */
6e91ea2b
CH
355static void _fh_update(struct svc_fh *fhp, struct svc_export *exp,
356 struct dentry *dentry)
1da177e4 357{
54775491 358 if (dentry != exp->ex_path.dentry) {
6e91ea2b
CH
359 struct fid *fid = (struct fid *)
360 (fhp->fh_handle.fh_auth + fhp->fh_handle.fh_size/4 - 1);
361 int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4;
362 int subtreecheck = !(exp->ex_flags & NFSEXP_NOSUBTREECHECK);
1da177e4 363
6e91ea2b
CH
364 fhp->fh_handle.fh_fileid_type =
365 exportfs_encode_fh(dentry, fid, &maxsize, subtreecheck);
366 fhp->fh_handle.fh_size += maxsize * 4;
367 } else {
368 fhp->fh_handle.fh_fileid_type = FILEID_ROOT;
369 }
1da177e4
LT
370}
371
372/*
373 * for composing old style file handles
374 */
375static inline void _fh_update_old(struct dentry *dentry,
376 struct svc_export *exp,
377 struct knfsd_fh *fh)
378{
379 fh->ofh_ino = ino_t_to_u32(dentry->d_inode->i_ino);
380 fh->ofh_generation = dentry->d_inode->i_generation;
381 if (S_ISDIR(dentry->d_inode->i_mode) ||
382 (exp->ex_flags & NFSEXP_NOSUBTREECHECK))
383 fh->ofh_dirino = 0;
384}
385
83b11340 386__be32
982aedfd
N
387fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
388 struct svc_fh *ref_fh)
1da177e4
LT
389{
390 /* ref_fh is a reference file handle.
7e405364
N
391 * if it is non-null and for the same filesystem, then we should compose
392 * a filehandle which is of the same version, where possible.
1da177e4
LT
393 * Currently, that means that if ref_fh->fh_handle.fh_version == 0xca
394 * Then create a 32byte filehandle using nfs_fhbase_old
395 *
396 */
397
b41eeef1 398 u8 version;
982aedfd 399 u8 fsid_type = 0;
1da177e4
LT
400 struct inode * inode = dentry->d_inode;
401 struct dentry *parent = dentry->d_parent;
402 __u32 *datap;
54775491
JB
403 dev_t ex_dev = exp->ex_path.dentry->d_inode->i_sb->s_dev;
404 int root_export = (exp->ex_path.dentry == exp->ex_path.dentry->d_sb->s_root);
1da177e4
LT
405
406 dprintk("nfsd: fh_compose(exp %02x:%02x/%ld %s/%s, ino=%ld)\n",
407 MAJOR(ex_dev), MINOR(ex_dev),
54775491 408 (long) exp->ex_path.dentry->d_inode->i_ino,
1da177e4
LT
409 parent->d_name.name, dentry->d_name.name,
410 (inode ? inode->i_ino : 0));
411
982aedfd
N
412 /* Choose filehandle version and fsid type based on
413 * the reference filehandle (if it is in the same export)
414 * or the export options.
415 */
b41eeef1
N
416 retry:
417 version = 1;
7e405364 418 if (ref_fh && ref_fh->fh_export == exp) {
982aedfd 419 version = ref_fh->fh_handle.fh_version;
b41eeef1
N
420 fsid_type = ref_fh->fh_handle.fh_fsid_type;
421
422 if (ref_fh == fhp)
423 fh_put(ref_fh);
424 ref_fh = NULL;
425
426 switch (version) {
427 case 0xca:
af6a4e28 428 fsid_type = FSID_DEV;
b41eeef1
N
429 break;
430 case 1:
431 break;
432 default:
433 goto retry;
434 }
435
436 /* Need to check that this type works for this
437 * export point. As the fsid -> filesystem mapping
438 * was guided by user-space, there is no guarantee
439 * that the filesystem actually supports that fsid
440 * type. If it doesn't we loop around again without
441 * ref_fh set.
982aedfd 442 */
b41eeef1
N
443 switch(fsid_type) {
444 case FSID_DEV:
445 if (!old_valid_dev(ex_dev))
446 goto retry;
447 /* FALL THROUGH */
448 case FSID_MAJOR_MINOR:
449 case FSID_ENCODE_DEV:
54775491 450 if (!(exp->ex_path.dentry->d_inode->i_sb->s_type->fs_flags
b41eeef1
N
451 & FS_REQUIRES_DEV))
452 goto retry;
453 break;
454 case FSID_NUM:
455 if (! (exp->ex_flags & NFSEXP_FSID))
456 goto retry;
457 break;
458 case FSID_UUID8:
459 case FSID_UUID16:
460 if (!root_export)
461 goto retry;
462 /* fall through */
463 case FSID_UUID4_INUM:
464 case FSID_UUID16_INUM:
465 if (exp->ex_uuid == NULL)
466 goto retry;
467 break;
468 }
af6a4e28
N
469 } else if (exp->ex_uuid) {
470 if (fhp->fh_maxsize >= 64) {
471 if (root_export)
472 fsid_type = FSID_UUID16;
473 else
474 fsid_type = FSID_UUID16_INUM;
475 } else {
476 if (root_export)
477 fsid_type = FSID_UUID8;
478 else
479 fsid_type = FSID_UUID4_INUM;
480 }
1da177e4 481 } else if (exp->ex_flags & NFSEXP_FSID)
af6a4e28 482 fsid_type = FSID_NUM;
982aedfd 483 else if (!old_valid_dev(ex_dev))
1da177e4 484 /* for newer device numbers, we must use a newer fsid format */
af6a4e28 485 fsid_type = FSID_ENCODE_DEV;
982aedfd 486 else
af6a4e28 487 fsid_type = FSID_DEV;
1da177e4
LT
488
489 if (ref_fh == fhp)
490 fh_put(ref_fh);
491
492 if (fhp->fh_locked || fhp->fh_dentry) {
493 printk(KERN_ERR "fh_compose: fh %s/%s not initialized!\n",
982aedfd 494 parent->d_name.name, dentry->d_name.name);
1da177e4
LT
495 }
496 if (fhp->fh_maxsize < NFS_FHSIZE)
497 printk(KERN_ERR "fh_compose: called with maxsize %d! %s/%s\n",
982aedfd
N
498 fhp->fh_maxsize,
499 parent->d_name.name, dentry->d_name.name);
1da177e4
LT
500
501 fhp->fh_dentry = dget(dentry); /* our internal copy */
502 fhp->fh_export = exp;
503 cache_get(&exp->h);
504
982aedfd 505 if (version == 0xca) {
1da177e4
LT
506 /* old style filehandle please */
507 memset(&fhp->fh_handle.fh_base, 0, NFS_FHSIZE);
508 fhp->fh_handle.fh_size = NFS_FHSIZE;
509 fhp->fh_handle.ofh_dcookie = 0xfeebbaca;
510 fhp->fh_handle.ofh_dev = old_encode_dev(ex_dev);
511 fhp->fh_handle.ofh_xdev = fhp->fh_handle.ofh_dev;
982aedfd 512 fhp->fh_handle.ofh_xino =
54775491 513 ino_t_to_u32(exp->ex_path.dentry->d_inode->i_ino);
1da177e4
LT
514 fhp->fh_handle.ofh_dirino = ino_t_to_u32(parent_ino(dentry));
515 if (inode)
516 _fh_update_old(dentry, exp, &fhp->fh_handle);
517 } else {
518 int len;
519 fhp->fh_handle.fh_version = 1;
520 fhp->fh_handle.fh_auth_type = 0;
521 datap = fhp->fh_handle.fh_auth+0;
982aedfd 522 fhp->fh_handle.fh_fsid_type = fsid_type;
af6a4e28 523 mk_fsid(fsid_type, datap, ex_dev,
54775491 524 exp->ex_path.dentry->d_inode->i_ino,
af6a4e28
N
525 exp->ex_fsid, exp->ex_uuid);
526
982aedfd 527 len = key_len(fsid_type);
1da177e4
LT
528 datap += len/4;
529 fhp->fh_handle.fh_size = 4 + len;
530
6e91ea2b
CH
531 if (inode)
532 _fh_update(fhp, exp, dentry);
1da177e4
LT
533 if (fhp->fh_handle.fh_fileid_type == 255)
534 return nfserr_opnotsupp;
535 }
536
537 nfsd_nr_verified++;
538 return 0;
539}
540
541/*
542 * Update file handle information after changing a dentry.
543 * This is only called by nfsd_create, nfsd_create_v3 and nfsd_proc_create
544 */
83b11340 545__be32
1da177e4
LT
546fh_update(struct svc_fh *fhp)
547{
548 struct dentry *dentry;
982aedfd 549
1da177e4
LT
550 if (!fhp->fh_dentry)
551 goto out_bad;
552
553 dentry = fhp->fh_dentry;
554 if (!dentry->d_inode)
555 goto out_negative;
556 if (fhp->fh_handle.fh_version != 1) {
557 _fh_update_old(dentry, fhp->fh_export, &fhp->fh_handle);
558 } else {
6e91ea2b 559 if (fhp->fh_handle.fh_fileid_type != FILEID_ROOT)
4c9608b2 560 goto out;
6e91ea2b
CH
561
562 _fh_update(fhp, fhp->fh_export, dentry);
1da177e4
LT
563 if (fhp->fh_handle.fh_fileid_type == 255)
564 return nfserr_opnotsupp;
565 }
566out:
567 return 0;
568
569out_bad:
570 printk(KERN_ERR "fh_update: fh not verified!\n");
571 goto out;
572out_negative:
573 printk(KERN_ERR "fh_update: %s/%s still negative!\n",
574 dentry->d_parent->d_name.name, dentry->d_name.name);
575 goto out;
1da177e4
LT
576}
577
578/*
579 * Release a file handle.
580 */
581void
582fh_put(struct svc_fh *fhp)
583{
584 struct dentry * dentry = fhp->fh_dentry;
585 struct svc_export * exp = fhp->fh_export;
586 if (dentry) {
587 fh_unlock(fhp);
588 fhp->fh_dentry = NULL;
589 dput(dentry);
590#ifdef CONFIG_NFSD_V3
591 fhp->fh_pre_saved = 0;
592 fhp->fh_post_saved = 0;
593#endif
594 nfsd_nr_put++;
595 }
596 if (exp) {
baab935f 597 cache_put(&exp->h, &svc_export_cache);
1da177e4
LT
598 fhp->fh_export = NULL;
599 }
600 return;
601}
602
603/*
604 * Shorthand for dprintk()'s
605 */
606char * SVCFH_fmt(struct svc_fh *fhp)
607{
608 struct knfsd_fh *fh = &fhp->fh_handle;
609
610 static char buf[80];
611 sprintf(buf, "%d: %08x %08x %08x %08x %08x %08x",
612 fh->fh_size,
613 fh->fh_base.fh_pad[0],
614 fh->fh_base.fh_pad[1],
615 fh->fh_base.fh_pad[2],
616 fh->fh_base.fh_pad[3],
617 fh->fh_base.fh_pad[4],
618 fh->fh_base.fh_pad[5]);
619 return buf;
620}
af6a4e28
N
621
622enum fsid_source fsid_source(struct svc_fh *fhp)
623{
624 if (fhp->fh_handle.fh_version != 1)
625 return FSIDSOURCE_DEV;
626 switch(fhp->fh_handle.fh_fsid_type) {
627 case FSID_DEV:
628 case FSID_ENCODE_DEV:
629 case FSID_MAJOR_MINOR:
54775491 630 if (fhp->fh_export->ex_path.dentry->d_inode->i_sb->s_type->fs_flags
b8da0d1c
NB
631 & FS_REQUIRES_DEV)
632 return FSIDSOURCE_DEV;
633 break;
af6a4e28 634 case FSID_NUM:
af6a4e28
N
635 if (fhp->fh_export->ex_flags & NFSEXP_FSID)
636 return FSIDSOURCE_FSID;
b8da0d1c
NB
637 break;
638 default:
639 break;
af6a4e28 640 }
b8da0d1c
NB
641 /* either a UUID type filehandle, or the filehandle doesn't
642 * match the export.
643 */
644 if (fhp->fh_export->ex_flags & NFSEXP_FSID)
645 return FSIDSOURCE_FSID;
646 if (fhp->fh_export->ex_uuid)
647 return FSIDSOURCE_UUID;
648 return FSIDSOURCE_DEV;
af6a4e28 649}