blob: 8d995bcef806bc99a668b183cf9dee29bfe27bea [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/slab.h>
13#include <linux/smp_lock.h>
14#include <linux/fs.h>
15#include <linux/unistd.h>
16#include <linux/string.h>
17#include <linux/stat.h>
18#include <linux/dcache.h>
19#include <linux/mount.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Chuck Leverad06e4b2007-02-12 00:53:32 -080021#include <linux/sunrpc/clnt.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <linux/sunrpc/svc.h>
23#include <linux/nfsd/nfsd.h>
24
25#define NFSDDBG_FACILITY NFSDDBG_FH
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27
28static int nfsd_nr_verified;
29static int nfsd_nr_put;
30
31extern struct export_operations export_op_default;
32
33#define CALL(ops,fun) ((ops->fun)?(ops->fun):export_op_default.fun)
34
35/*
36 * our acceptability function.
37 * if NOSUBTREECHECK, accept anything
38 * if not, require that we can walk up to exp->ex_dentry
39 * doing some checks on the 'x' bits
40 */
41static int nfsd_acceptable(void *expv, struct dentry *dentry)
42{
43 struct svc_export *exp = expv;
44 int rv;
45 struct dentry *tdentry;
46 struct dentry *parent;
47
48 if (exp->ex_flags & NFSEXP_NOSUBTREECHECK)
49 return 1;
50
51 tdentry = dget(dentry);
52 while (tdentry != exp->ex_dentry && ! IS_ROOT(tdentry)) {
53 /* make sure parents give x permission to user */
54 int err;
55 parent = dget_parent(tdentry);
56 err = permission(parent->d_inode, MAY_EXEC, NULL);
57 if (err < 0) {
58 dput(parent);
59 break;
60 }
61 dput(tdentry);
62 tdentry = parent;
63 }
64 if (tdentry != exp->ex_dentry)
65 dprintk("nfsd_acceptable failed at %p %s\n", tdentry, tdentry->d_name.name);
66 rv = (tdentry == exp->ex_dentry);
67 dput(tdentry);
68 return rv;
69}
70
71/* Type check. The correct error return for type mismatches does not seem to be
72 * generally agreed upon. SunOS seems to use EISDIR if file isn't S_IFREG; a
73 * comment in the NFSv3 spec says this is incorrect (implementation notes for
74 * the write call).
75 */
Al Viro83b11342006-10-19 23:28:55 -070076static inline __be32
Linus Torvalds1da177e2005-04-16 15:20:36 -070077nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int type)
78{
79 /* Type can be negative when creating hardlinks - not to a dir */
80 if (type > 0 && (mode & S_IFMT) != type) {
81 if (rqstp->rq_vers == 4 && (mode & S_IFMT) == S_IFLNK)
82 return nfserr_symlink;
83 else if (type == S_IFDIR)
84 return nfserr_notdir;
85 else if ((mode & S_IFMT) == S_IFDIR)
86 return nfserr_isdir;
87 else
88 return nfserr_inval;
89 }
90 if (type < 0 && (mode & S_IFMT) == -type) {
91 if (rqstp->rq_vers == 4 && (mode & S_IFMT) == S_IFLNK)
92 return nfserr_symlink;
93 else if (type == -S_IFDIR)
94 return nfserr_isdir;
95 else
96 return nfserr_notdir;
97 }
98 return 0;
99}
100
101/*
102 * Perform sanity checks on the dentry in a client's file handle.
103 *
104 * Note that the file handle dentry may need to be freed even after
105 * an error return.
106 *
107 * This is only called at the start of an nfsproc call, so fhp points to
108 * a svc_fh which is all 0 except for the over-the-wire file handle.
109 */
Al Viro83b11342006-10-19 23:28:55 -0700110__be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
112{
113 struct knfsd_fh *fh = &fhp->fh_handle;
114 struct svc_export *exp = NULL;
115 struct dentry *dentry;
Al Viro83b11342006-10-19 23:28:55 -0700116 __be32 error = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
118 dprintk("nfsd: fh_verify(%s)\n", SVCFH_fmt(fhp));
119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 if (!fhp->fh_dentry) {
121 __u32 *datap=NULL;
122 __u32 tfh[3]; /* filehandle fragment for oldstyle filehandles */
123 int fileid_type;
124 int data_left = fh->fh_size/4;
125
126 error = nfserr_stale;
127 if (rqstp->rq_client == NULL)
128 goto out;
129 if (rqstp->rq_vers > 2)
130 error = nfserr_badhandle;
131 if (rqstp->rq_vers == 4 && fh->fh_size == 0)
132 return nfserr_nofilehandle;
133
134 if (fh->fh_version == 1) {
135 int len;
136 datap = fh->fh_auth;
137 if (--data_left<0) goto out;
138 switch (fh->fh_auth_type) {
139 case 0: break;
140 default: goto out;
141 }
142 len = key_len(fh->fh_fsid_type) / 4;
143 if (len == 0) goto out;
NeilBrownaf6a4e22007-02-14 00:33:12 -0800144 if (fh->fh_fsid_type == FSID_MAJOR_MINOR) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 /* deprecated, convert to type 3 */
NeilBrownaf6a4e22007-02-14 00:33:12 -0800146 len = key_len(FSID_ENCODE_DEV)/4;
147 fh->fh_fsid_type = FSID_ENCODE_DEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 fh->fh_fsid[0] = new_encode_dev(MKDEV(ntohl(fh->fh_fsid[0]), ntohl(fh->fh_fsid[1])));
149 fh->fh_fsid[1] = fh->fh_fsid[2];
150 }
151 if ((data_left -= len)<0) goto out;
152 exp = exp_find(rqstp->rq_client, fh->fh_fsid_type, datap, &rqstp->rq_chandle);
153 datap += len;
154 } else {
155 dev_t xdev;
156 ino_t xino;
157 if (fh->fh_size != NFS_FHSIZE)
158 goto out;
159 /* assume old filehandle format */
160 xdev = old_decode_dev(fh->ofh_xdev);
161 xino = u32_to_ino_t(fh->ofh_xino);
NeilBrownaf6a4e22007-02-14 00:33:12 -0800162 mk_fsid(FSID_DEV, tfh, xdev, xino, 0, NULL);
163 exp = exp_find(rqstp->rq_client, FSID_DEV, tfh,
164 &rqstp->rq_chandle);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 }
166
J.Bruce Fieldse0bb89e2006-12-13 00:35:25 -0800167 if (IS_ERR(exp) && (PTR_ERR(exp) == -EAGAIN
168 || PTR_ERR(exp) == -ETIMEDOUT)) {
169 error = nfserrno(PTR_ERR(exp));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 goto out;
J.Bruce Fieldse0bb89e2006-12-13 00:35:25 -0800171 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
173 error = nfserr_stale;
174 if (!exp || IS_ERR(exp))
175 goto out;
176
177 /* Check if the request originated from a secure port. */
178 error = nfserr_perm;
179 if (!rqstp->rq_secure && EX_SECURE(exp)) {
Chuck Leverad06e4b2007-02-12 00:53:32 -0800180 char buf[RPC_MAX_ADDRBUFLEN];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 printk(KERN_WARNING
Chuck Leverad06e4b2007-02-12 00:53:32 -0800182 "nfsd: request from insecure port %s!\n",
183 svc_print_addr(rqstp, buf, sizeof(buf)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 goto out;
185 }
186
NeilBrownd1bbf142006-07-30 03:03:16 -0700187 /* Set user creds for this exportpoint */
188 error = nfserrno(nfsd_setuser(rqstp, exp));
189 if (error)
190 goto out;
191
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 /*
193 * Look up the dentry using the NFS file handle.
194 */
195 error = nfserr_stale;
196 if (rqstp->rq_vers > 2)
197 error = nfserr_badhandle;
198
199 if (fh->fh_version != 1) {
200 tfh[0] = fh->ofh_ino;
201 tfh[1] = fh->ofh_generation;
202 tfh[2] = fh->ofh_dirino;
203 datap = tfh;
204 data_left = 3;
205 if (fh->ofh_dirino == 0)
206 fileid_type = 1;
207 else
208 fileid_type = 2;
209 } else
210 fileid_type = fh->fh_fileid_type;
NeilBrown982aedf2007-02-14 00:33:11 -0800211
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 if (fileid_type == 0)
213 dentry = dget(exp->ex_dentry);
214 else {
215 struct export_operations *nop = exp->ex_mnt->mnt_sb->s_export_op;
216 dentry = CALL(nop,decode_fh)(exp->ex_mnt->mnt_sb,
217 datap, data_left,
218 fileid_type,
219 nfsd_acceptable, exp);
220 }
221 if (dentry == NULL)
222 goto out;
223 if (IS_ERR(dentry)) {
224 if (PTR_ERR(dentry) != -EINVAL)
225 error = nfserrno(PTR_ERR(dentry));
226 goto out;
227 }
NeilBrown34e9a632007-01-29 13:19:52 -0800228
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 if (S_ISDIR(dentry->d_inode->i_mode) &&
230 (dentry->d_flags & DCACHE_DISCONNECTED)) {
231 printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %s/%s\n",
232 dentry->d_parent->d_name.name, dentry->d_name.name);
233 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234
235 fhp->fh_dentry = dentry;
236 fhp->fh_export = exp;
237 nfsd_nr_verified++;
238 } else {
239 /* just rechecking permissions
240 * (e.g. nfsproc_create calls fh_verify, then nfsd_create does as well)
241 */
242 dprintk("nfsd: fh_verify - just checking\n");
243 dentry = fhp->fh_dentry;
244 exp = fhp->fh_export;
NeilBrownd1bbf142006-07-30 03:03:16 -0700245 /* Set user creds for this exportpoint; necessary even
246 * in the "just checking" case because this may be a
247 * filehandle that was created by fh_compose, and that
248 * is about to be used in another nfsv4 compound
249 * operation */
250 error = nfserrno(nfsd_setuser(rqstp, exp));
251 if (error)
252 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 }
254 cache_get(&exp->h);
255
J. Bruce Fields7fc90ec2006-06-30 01:56:14 -0700256
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 error = nfsd_mode_check(rqstp, dentry->d_inode->i_mode, type);
258 if (error)
259 goto out;
260
261 /* Finally, check access permissions. */
262 error = nfsd_permission(exp, dentry, access);
263
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 if (error) {
NeilBrown34e9a632007-01-29 13:19:52 -0800265 dprintk("fh_verify: %s/%s permission failure, "
266 "acc=%x, error=%d\n",
267 dentry->d_parent->d_name.name,
268 dentry->d_name.name,
Al Virofc2dd2e2007-02-01 13:52:43 +0000269 access, ntohl(error));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271out:
272 if (exp && !IS_ERR(exp))
273 exp_put(exp);
274 if (error == nfserr_stale)
275 nfsdstats.fh_stale++;
276 return error;
277}
278
279
280/*
281 * Compose a file handle for an NFS reply.
282 *
283 * Note that when first composed, the dentry may not yet have
284 * an inode. In this case a call to fh_update should be made
285 * before the fh goes out on the wire ...
286 */
287static inline int _fh_update(struct dentry *dentry, struct svc_export *exp,
288 __u32 *datap, int *maxsize)
289{
290 struct export_operations *nop = exp->ex_mnt->mnt_sb->s_export_op;
NeilBrown982aedf2007-02-14 00:33:11 -0800291
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 if (dentry == exp->ex_dentry) {
293 *maxsize = 0;
294 return 0;
295 }
296
297 return CALL(nop,encode_fh)(dentry, datap, maxsize,
298 !(exp->ex_flags&NFSEXP_NOSUBTREECHECK));
299}
300
301/*
302 * for composing old style file handles
303 */
304static inline void _fh_update_old(struct dentry *dentry,
305 struct svc_export *exp,
306 struct knfsd_fh *fh)
307{
308 fh->ofh_ino = ino_t_to_u32(dentry->d_inode->i_ino);
309 fh->ofh_generation = dentry->d_inode->i_generation;
310 if (S_ISDIR(dentry->d_inode->i_mode) ||
311 (exp->ex_flags & NFSEXP_NOSUBTREECHECK))
312 fh->ofh_dirino = 0;
313}
314
Al Viro83b11342006-10-19 23:28:55 -0700315__be32
NeilBrown982aedf2007-02-14 00:33:11 -0800316fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
317 struct svc_fh *ref_fh)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318{
319 /* ref_fh is a reference file handle.
NeilBrown7e405362006-06-30 01:56:12 -0700320 * if it is non-null and for the same filesystem, then we should compose
321 * a filehandle which is of the same version, where possible.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 * Currently, that means that if ref_fh->fh_handle.fh_version == 0xca
323 * Then create a 32byte filehandle using nfs_fhbase_old
324 *
325 */
326
NeilBrown982aedf2007-02-14 00:33:11 -0800327 u8 version = 1;
328 u8 fsid_type = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 struct inode * inode = dentry->d_inode;
330 struct dentry *parent = dentry->d_parent;
331 __u32 *datap;
332 dev_t ex_dev = exp->ex_dentry->d_inode->i_sb->s_dev;
NeilBrownaf6a4e22007-02-14 00:33:12 -0800333 int root_export = (exp->ex_dentry == exp->ex_dentry->d_sb->s_root);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334
335 dprintk("nfsd: fh_compose(exp %02x:%02x/%ld %s/%s, ino=%ld)\n",
336 MAJOR(ex_dev), MINOR(ex_dev),
337 (long) exp->ex_dentry->d_inode->i_ino,
338 parent->d_name.name, dentry->d_name.name,
339 (inode ? inode->i_ino : 0));
340
NeilBrown982aedf2007-02-14 00:33:11 -0800341 /* Choose filehandle version and fsid type based on
342 * the reference filehandle (if it is in the same export)
343 * or the export options.
344 */
NeilBrown7e405362006-06-30 01:56:12 -0700345 if (ref_fh && ref_fh->fh_export == exp) {
NeilBrown982aedf2007-02-14 00:33:11 -0800346 version = ref_fh->fh_handle.fh_version;
347 if (version == 0xca)
NeilBrownaf6a4e22007-02-14 00:33:12 -0800348 fsid_type = FSID_DEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 else
NeilBrown982aedf2007-02-14 00:33:11 -0800350 fsid_type = ref_fh->fh_handle.fh_fsid_type;
351 /* We know this version/type works for this export
352 * so there is no need for further checks.
353 */
NeilBrownaf6a4e22007-02-14 00:33:12 -0800354 } else if (exp->ex_uuid) {
355 if (fhp->fh_maxsize >= 64) {
356 if (root_export)
357 fsid_type = FSID_UUID16;
358 else
359 fsid_type = FSID_UUID16_INUM;
360 } else {
361 if (root_export)
362 fsid_type = FSID_UUID8;
363 else
364 fsid_type = FSID_UUID4_INUM;
365 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 } else if (exp->ex_flags & NFSEXP_FSID)
NeilBrownaf6a4e22007-02-14 00:33:12 -0800367 fsid_type = FSID_NUM;
NeilBrown982aedf2007-02-14 00:33:11 -0800368 else if (!old_valid_dev(ex_dev))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 /* for newer device numbers, we must use a newer fsid format */
NeilBrownaf6a4e22007-02-14 00:33:12 -0800370 fsid_type = FSID_ENCODE_DEV;
NeilBrown982aedf2007-02-14 00:33:11 -0800371 else
NeilBrownaf6a4e22007-02-14 00:33:12 -0800372 fsid_type = FSID_DEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373
374 if (ref_fh == fhp)
375 fh_put(ref_fh);
376
377 if (fhp->fh_locked || fhp->fh_dentry) {
378 printk(KERN_ERR "fh_compose: fh %s/%s not initialized!\n",
NeilBrown982aedf2007-02-14 00:33:11 -0800379 parent->d_name.name, dentry->d_name.name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 }
381 if (fhp->fh_maxsize < NFS_FHSIZE)
382 printk(KERN_ERR "fh_compose: called with maxsize %d! %s/%s\n",
NeilBrown982aedf2007-02-14 00:33:11 -0800383 fhp->fh_maxsize,
384 parent->d_name.name, dentry->d_name.name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385
386 fhp->fh_dentry = dget(dentry); /* our internal copy */
387 fhp->fh_export = exp;
388 cache_get(&exp->h);
389
NeilBrown982aedf2007-02-14 00:33:11 -0800390 if (version == 0xca) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 /* old style filehandle please */
392 memset(&fhp->fh_handle.fh_base, 0, NFS_FHSIZE);
393 fhp->fh_handle.fh_size = NFS_FHSIZE;
394 fhp->fh_handle.ofh_dcookie = 0xfeebbaca;
395 fhp->fh_handle.ofh_dev = old_encode_dev(ex_dev);
396 fhp->fh_handle.ofh_xdev = fhp->fh_handle.ofh_dev;
NeilBrown982aedf2007-02-14 00:33:11 -0800397 fhp->fh_handle.ofh_xino =
398 ino_t_to_u32(exp->ex_dentry->d_inode->i_ino);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 fhp->fh_handle.ofh_dirino = ino_t_to_u32(parent_ino(dentry));
400 if (inode)
401 _fh_update_old(dentry, exp, &fhp->fh_handle);
402 } else {
403 int len;
404 fhp->fh_handle.fh_version = 1;
405 fhp->fh_handle.fh_auth_type = 0;
406 datap = fhp->fh_handle.fh_auth+0;
NeilBrown982aedf2007-02-14 00:33:11 -0800407 fhp->fh_handle.fh_fsid_type = fsid_type;
NeilBrownaf6a4e22007-02-14 00:33:12 -0800408 mk_fsid(fsid_type, datap, ex_dev,
409 exp->ex_dentry->d_inode->i_ino,
410 exp->ex_fsid, exp->ex_uuid);
411
NeilBrown982aedf2007-02-14 00:33:11 -0800412 len = key_len(fsid_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 datap += len/4;
414 fhp->fh_handle.fh_size = 4 + len;
415
416 if (inode) {
417 int size = (fhp->fh_maxsize-len-4)/4;
418 fhp->fh_handle.fh_fileid_type =
419 _fh_update(dentry, exp, datap, &size);
420 fhp->fh_handle.fh_size += size*4;
421 }
422 if (fhp->fh_handle.fh_fileid_type == 255)
423 return nfserr_opnotsupp;
424 }
425
426 nfsd_nr_verified++;
427 return 0;
428}
429
430/*
431 * Update file handle information after changing a dentry.
432 * This is only called by nfsd_create, nfsd_create_v3 and nfsd_proc_create
433 */
Al Viro83b11342006-10-19 23:28:55 -0700434__be32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435fh_update(struct svc_fh *fhp)
436{
437 struct dentry *dentry;
438 __u32 *datap;
NeilBrown982aedf2007-02-14 00:33:11 -0800439
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 if (!fhp->fh_dentry)
441 goto out_bad;
442
443 dentry = fhp->fh_dentry;
444 if (!dentry->d_inode)
445 goto out_negative;
446 if (fhp->fh_handle.fh_version != 1) {
447 _fh_update_old(dentry, fhp->fh_export, &fhp->fh_handle);
448 } else {
449 int size;
450 if (fhp->fh_handle.fh_fileid_type != 0)
NeilBrown4c9608b2006-06-30 01:56:11 -0700451 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 datap = fhp->fh_handle.fh_auth+
453 fhp->fh_handle.fh_size/4 -1;
454 size = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4;
455 fhp->fh_handle.fh_fileid_type =
456 _fh_update(dentry, fhp->fh_export, datap, &size);
457 fhp->fh_handle.fh_size += size*4;
458 if (fhp->fh_handle.fh_fileid_type == 255)
459 return nfserr_opnotsupp;
460 }
461out:
462 return 0;
463
464out_bad:
465 printk(KERN_ERR "fh_update: fh not verified!\n");
466 goto out;
467out_negative:
468 printk(KERN_ERR "fh_update: %s/%s still negative!\n",
469 dentry->d_parent->d_name.name, dentry->d_name.name);
470 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471}
472
473/*
474 * Release a file handle.
475 */
476void
477fh_put(struct svc_fh *fhp)
478{
479 struct dentry * dentry = fhp->fh_dentry;
480 struct svc_export * exp = fhp->fh_export;
481 if (dentry) {
482 fh_unlock(fhp);
483 fhp->fh_dentry = NULL;
484 dput(dentry);
485#ifdef CONFIG_NFSD_V3
486 fhp->fh_pre_saved = 0;
487 fhp->fh_post_saved = 0;
488#endif
489 nfsd_nr_put++;
490 }
491 if (exp) {
NeilBrownbaab9352006-03-27 01:15:09 -0800492 cache_put(&exp->h, &svc_export_cache);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 fhp->fh_export = NULL;
494 }
495 return;
496}
497
498/*
499 * Shorthand for dprintk()'s
500 */
501char * SVCFH_fmt(struct svc_fh *fhp)
502{
503 struct knfsd_fh *fh = &fhp->fh_handle;
504
505 static char buf[80];
506 sprintf(buf, "%d: %08x %08x %08x %08x %08x %08x",
507 fh->fh_size,
508 fh->fh_base.fh_pad[0],
509 fh->fh_base.fh_pad[1],
510 fh->fh_base.fh_pad[2],
511 fh->fh_base.fh_pad[3],
512 fh->fh_base.fh_pad[4],
513 fh->fh_base.fh_pad[5]);
514 return buf;
515}
NeilBrownaf6a4e22007-02-14 00:33:12 -0800516
517enum fsid_source fsid_source(struct svc_fh *fhp)
518{
519 if (fhp->fh_handle.fh_version != 1)
520 return FSIDSOURCE_DEV;
521 switch(fhp->fh_handle.fh_fsid_type) {
522 case FSID_DEV:
523 case FSID_ENCODE_DEV:
524 case FSID_MAJOR_MINOR:
525 return FSIDSOURCE_DEV;
526 case FSID_NUM:
527 return FSIDSOURCE_FSID;
528 default:
529 if (fhp->fh_export->ex_flags & NFSEXP_FSID)
530 return FSIDSOURCE_FSID;
531 else
532 return FSIDSOURCE_UUID;
533 }
534}