10 #include <linux/time.h>
12 #include <linux/errno.h>
13 #include <linux/string.h>
17 #include <linux/kdev_t.h>
19 #include <linux/nfs.h>
20 #include <linux/nfs3.h>
21 #include <linux/nfs_fs.h>
22 #include <linux/nfsacl.h>
25 #define NFSDBG_FACILITY NFSDBG_XDR
28 #define errno_NFSERR_IO EIO
34 #define NFS3_fhandle_sz (1+16)
35 #define NFS3_fh_sz (NFS3_fhandle_sz)
36 #define NFS3_sattr_sz (15)
37 #define NFS3_filename_sz (1+(NFS3_MAXNAMLEN>>2))
38 #define NFS3_path_sz (1+(NFS3_MAXPATHLEN>>2))
39 #define NFS3_fattr_sz (21)
40 #define NFS3_cookieverf_sz (NFS3_COOKIEVERFSIZE>>2)
41 #define NFS3_wcc_attr_sz (6)
42 #define NFS3_pre_op_attr_sz (1+NFS3_wcc_attr_sz)
43 #define NFS3_post_op_attr_sz (1+NFS3_fattr_sz)
44 #define NFS3_wcc_data_sz (NFS3_pre_op_attr_sz+NFS3_post_op_attr_sz)
45 #define NFS3_diropargs_sz (NFS3_fh_sz+NFS3_filename_sz)
47 #define NFS3_getattrargs_sz (NFS3_fh_sz)
48 #define NFS3_setattrargs_sz (NFS3_fh_sz+NFS3_sattr_sz+3)
49 #define NFS3_lookupargs_sz (NFS3_fh_sz+NFS3_filename_sz)
50 #define NFS3_accessargs_sz (NFS3_fh_sz+1)
51 #define NFS3_readlinkargs_sz (NFS3_fh_sz)
52 #define NFS3_readargs_sz (NFS3_fh_sz+3)
53 #define NFS3_writeargs_sz (NFS3_fh_sz+5)
54 #define NFS3_createargs_sz (NFS3_diropargs_sz+NFS3_sattr_sz)
55 #define NFS3_mkdirargs_sz (NFS3_diropargs_sz+NFS3_sattr_sz)
56 #define NFS3_symlinkargs_sz (NFS3_diropargs_sz+1+NFS3_sattr_sz)
57 #define NFS3_mknodargs_sz (NFS3_diropargs_sz+2+NFS3_sattr_sz)
58 #define NFS3_removeargs_sz (NFS3_fh_sz+NFS3_filename_sz)
59 #define NFS3_renameargs_sz (NFS3_diropargs_sz+NFS3_diropargs_sz)
60 #define NFS3_linkargs_sz (NFS3_fh_sz+NFS3_diropargs_sz)
61 #define NFS3_readdirargs_sz (NFS3_fh_sz+NFS3_cookieverf_sz+3)
62 #define NFS3_readdirplusargs_sz (NFS3_fh_sz+NFS3_cookieverf_sz+4)
63 #define NFS3_commitargs_sz (NFS3_fh_sz+3)
65 #define NFS3_getattrres_sz (1+NFS3_fattr_sz)
66 #define NFS3_setattrres_sz (1+NFS3_wcc_data_sz)
67 #define NFS3_removeres_sz (NFS3_setattrres_sz)
68 #define NFS3_lookupres_sz (1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz))
69 #define NFS3_accessres_sz (1+NFS3_post_op_attr_sz+1)
70 #define NFS3_readlinkres_sz (1+NFS3_post_op_attr_sz+1)
71 #define NFS3_readres_sz (1+NFS3_post_op_attr_sz+3)
72 #define NFS3_writeres_sz (1+NFS3_wcc_data_sz+4)
73 #define NFS3_createres_sz (1+NFS3_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
74 #define NFS3_renameres_sz (1+(2 * NFS3_wcc_data_sz))
75 #define NFS3_linkres_sz (1+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
76 #define NFS3_readdirres_sz (1+NFS3_post_op_attr_sz+2)
77 #define NFS3_fsstatres_sz (1+NFS3_post_op_attr_sz+13)
78 #define NFS3_fsinfores_sz (1+NFS3_post_op_attr_sz+12)
79 #define NFS3_pathconfres_sz (1+NFS3_post_op_attr_sz+6)
80 #define NFS3_commitres_sz (1+NFS3_wcc_data_sz+2)
82 #define ACL3_getaclargs_sz (NFS3_fh_sz+1)
83 #define ACL3_setaclargs_sz (NFS3_fh_sz+1+ \
84 XDR_QUADLEN(NFS_ACL_INLINE_BUFSIZE))
85 #define ACL3_getaclres_sz (1+NFS3_post_op_attr_sz+1+ \
86 XDR_QUADLEN(NFS_ACL_INLINE_BUFSIZE))
87 #define ACL3_setaclres_sz (1+NFS3_post_op_attr_sz)
89 static int nfs3_stat_to_errno(
enum nfs_stat);
94 static const umode_t nfs_type2fmt[] = {
109 static void prepare_reply_buffer(
struct rpc_rqst *
req,
struct page **
pages,
110 unsigned int base,
unsigned int len,
113 struct rpc_auth *
auth = req->rq_cred->cr_auth;
116 replen = RPC_REPHDRSIZE + auth->au_rslack +
bufsize;
123 static void print_overflow_msg(
const char *
func,
const struct xdr_stream *xdr)
125 dprintk(
"NFS: %s prematurely hit the end of our receive buffer. "
126 "Remaining buffer length is %tu words.\n",
127 func, xdr->end - xdr->p);
142 static void encode_uint32(
struct xdr_stream *xdr,
u32 value)
148 static int decode_uint32(
struct xdr_stream *xdr,
u32 *
value)
158 print_overflow_msg(__func__, xdr);
162 static int decode_uint64(
struct xdr_stream *xdr,
u64 *value)
169 xdr_decode_hyper(p, value);
172 print_overflow_msg(__func__, xdr);
183 return xdr_decode_hyper(p, fileid);
186 static int decode_fileid3(
struct xdr_stream *xdr,
u64 *fileid)
188 return decode_uint64(xdr, fileid);
196 static void encode_filename3(
struct xdr_stream *xdr,
206 static int decode_inline_filename3(
struct xdr_stream *xdr,
217 goto out_nametoolong;
221 *name = (
const char *)p;
226 dprintk(
"NFS: returned filename too long: %u\n", count);
229 print_overflow_msg(__func__, xdr);
238 static void encode_nfspath3(
struct xdr_stream *xdr,
struct page **
pages,
242 encode_uint32(xdr, length);
246 static int decode_nfspath3(
struct xdr_stream *xdr)
256 goto out_nametoolong;
264 dprintk(
"NFS: returned pathname too long: %u\n", count);
267 dprintk(
"NFS: server cheating in pathname result: "
268 "count %u > recvd %u\n", count, recvd);
271 print_overflow_msg(__func__, xdr);
282 return xdr_encode_hyper(p, cookie);
285 static int decode_cookie3(
struct xdr_stream *xdr,
u64 *
cookie)
287 return decode_uint64(xdr, cookie);
301 static int decode_cookieverf3(
struct xdr_stream *xdr,
__be32 *verifier)
311 print_overflow_msg(__func__, xdr);
320 static void encode_createverf3(
struct xdr_stream *xdr,
const __be32 *verifier)
328 static int decode_writeverf3(
struct xdr_stream *xdr,
struct nfs_write_verifier *verifier)
338 print_overflow_msg(__func__, xdr);
349 return xdr_decode_hyper(p, size);
360 #define NFS3_OK NFS_OK
362 static int decode_nfsstat3(
struct xdr_stream *xdr,
enum nfs_stat *
status)
372 print_overflow_msg(__func__, xdr);
389 static void encode_ftype3(
struct xdr_stream *xdr,
const u32 type)
392 encode_uint32(xdr, type);
402 *mode = nfs_type2fmt[
type];
414 static void encode_specdata3(
struct xdr_stream *xdr,
const dev_t rdev)
429 *rdev =
MKDEV(major, minor);
430 if (
MAJOR(*rdev) != major ||
MINOR(*rdev) != minor)
442 static void encode_nfs_fh3(
struct xdr_stream *xdr,
const struct nfs_fh *fh)
451 static int decode_nfs_fh3(
struct xdr_stream *xdr,
struct nfs_fh *fh)
469 dprintk(
"NFS: file handle size (%u) too big\n", length);
472 print_overflow_msg(__func__, xdr);
476 static void zero_nfs_fh3(
struct nfs_fh *fh)
478 memset(fh, 0,
sizeof(*fh));
563 static void encode_sattr3(
struct xdr_stream *xdr,
const struct iattr *
attr)
615 p = xdr_encode_nfstime3(p, &attr->
ia_atime);
623 xdr_encode_nfstime3(p, &attr->
ia_mtime);
649 static int decode_fattr3(
struct xdr_stream *xdr,
struct nfs_fattr *fattr)
658 p = xdr_decode_ftype3(p, &fmode);
665 p = xdr_decode_size3(p, &fattr->
size);
666 p = xdr_decode_size3(p, &fattr->
du.
nfs3.used);
667 p = xdr_decode_specdata3(p, &fattr->
rdev);
669 p = xdr_decode_hyper(p, &fattr->
fsid.major);
670 fattr->
fsid.minor = 0;
672 p = xdr_decode_fileid3(p, &fattr->
fileid);
673 p = xdr_decode_nfstime3(p, &fattr->
atime);
674 p = xdr_decode_nfstime3(p, &fattr->
mtime);
675 xdr_decode_nfstime3(p, &fattr->
ctime);
681 print_overflow_msg(__func__, xdr);
695 static int decode_post_op_attr(
struct xdr_stream *xdr,
struct nfs_fattr *fattr)
703 return decode_fattr3(xdr, fattr);
706 print_overflow_msg(__func__, xdr);
718 static int decode_wcc_attr(
struct xdr_stream *xdr,
struct nfs_fattr *fattr)
731 p = xdr_decode_size3(p, &fattr->
pre_size);
732 p = xdr_decode_nfstime3(p, &fattr->
pre_mtime);
733 xdr_decode_nfstime3(p, &fattr->
pre_ctime);
738 print_overflow_msg(__func__, xdr);
758 static int decode_pre_op_attr(
struct xdr_stream *xdr,
struct nfs_fattr *fattr)
766 return decode_wcc_attr(xdr, fattr);
769 print_overflow_msg(__func__, xdr);
773 static int decode_wcc_data(
struct xdr_stream *xdr,
struct nfs_fattr *fattr)
777 error = decode_pre_op_attr(xdr, fattr);
780 error = decode_post_op_attr(xdr, fattr);
795 static int decode_post_op_fh3(
struct xdr_stream *xdr,
struct nfs_fh *fh)
801 return decode_nfs_fh3(xdr, fh);
805 print_overflow_msg(__func__, xdr);
817 static void encode_diropargs3(
struct xdr_stream *xdr,
const struct nfs_fh *fh,
818 const char *name,
u32 length)
820 encode_nfs_fh3(xdr, fh);
821 encode_filename3(xdr, name, length);
839 static void nfs3_xdr_enc_getattr3args(
struct rpc_rqst *
req,
840 struct xdr_stream *xdr,
843 encode_nfs_fh3(xdr, fh);
862 static void encode_sattrguard3(
struct xdr_stream *xdr,
870 xdr_encode_nfstime3(p, &args->
guardtime);
877 static void nfs3_xdr_enc_setattr3args(
struct rpc_rqst *
req,
878 struct xdr_stream *xdr,
881 encode_nfs_fh3(xdr, args->
fh);
882 encode_sattr3(xdr, args->
sattr);
883 encode_sattrguard3(xdr, args);
893 static void nfs3_xdr_enc_lookup3args(
struct rpc_rqst *
req,
894 struct xdr_stream *xdr,
897 encode_diropargs3(xdr, args->
fh, args->
name, args->
len);
908 static void encode_access3args(
struct xdr_stream *xdr,
911 encode_nfs_fh3(xdr, args->
fh);
912 encode_uint32(xdr, args->
access);
915 static void nfs3_xdr_enc_access3args(
struct rpc_rqst *
req,
916 struct xdr_stream *xdr,
919 encode_access3args(xdr, args);
929 static void nfs3_xdr_enc_readlink3args(
struct rpc_rqst *
req,
930 struct xdr_stream *xdr,
933 encode_nfs_fh3(xdr, args->
fh);
934 prepare_reply_buffer(req, args->
pages, args->
pgbase,
947 static void encode_read3args(
struct xdr_stream *xdr,
952 encode_nfs_fh3(xdr, args->
fh);
955 p = xdr_encode_hyper(p, args->
offset);
959 static void nfs3_xdr_enc_read3args(
struct rpc_rqst *
req,
960 struct xdr_stream *xdr,
963 encode_read3args(xdr, args);
964 prepare_reply_buffer(req, args->
pages, args->
pgbase,
966 req->rq_rcv_buf.flags |= XDRBUF_READ;
986 static void encode_write3args(
struct xdr_stream *xdr,
991 encode_nfs_fh3(xdr, args->
fh);
994 p = xdr_encode_hyper(p, args->
offset);
1001 static void nfs3_xdr_enc_write3args(
struct rpc_rqst *
req,
1002 struct xdr_stream *xdr,
1005 encode_write3args(xdr, args);
1006 xdr->buf->flags |= XDRBUF_WRITE;
1031 static void encode_createhow3(
struct xdr_stream *xdr,
1038 encode_sattr3(xdr, args->
sattr);
1041 encode_createverf3(xdr, args->
verifier);
1048 static void nfs3_xdr_enc_create3args(
struct rpc_rqst *
req,
1049 struct xdr_stream *xdr,
1052 encode_diropargs3(xdr, args->
fh, args->
name, args->
len);
1053 encode_createhow3(xdr, args);
1064 static void nfs3_xdr_enc_mkdir3args(
struct rpc_rqst *
req,
1065 struct xdr_stream *xdr,
1068 encode_diropargs3(xdr, args->
fh, args->
name, args->
len);
1069 encode_sattr3(xdr, args->
sattr);
1085 static void encode_symlinkdata3(
struct xdr_stream *xdr,
1088 encode_sattr3(xdr, args->
sattr);
1092 static void nfs3_xdr_enc_symlink3args(
struct rpc_rqst *
req,
1093 struct xdr_stream *xdr,
1097 encode_symlinkdata3(xdr, args);
1124 static void encode_devicedata3(
struct xdr_stream *xdr,
1127 encode_sattr3(xdr, args->
sattr);
1128 encode_specdata3(xdr, args->
rdev);
1131 static void encode_mknoddata3(
struct xdr_stream *xdr,
1134 encode_ftype3(xdr, args->
type);
1135 switch (args->
type) {
1138 encode_devicedata3(xdr, args);
1142 encode_sattr3(xdr, args->
sattr);
1152 static void nfs3_xdr_enc_mknod3args(
struct rpc_rqst *
req,
1153 struct xdr_stream *xdr,
1156 encode_diropargs3(xdr, args->
fh, args->
name, args->
len);
1157 encode_mknoddata3(xdr, args);
1167 static void nfs3_xdr_enc_remove3args(
struct rpc_rqst *
req,
1168 struct xdr_stream *xdr,
1171 encode_diropargs3(xdr, args->
fh, args->
name.name, args->
name.len);
1182 static void nfs3_xdr_enc_rename3args(
struct rpc_rqst *
req,
1183 struct xdr_stream *xdr,
1189 encode_diropargs3(xdr, args->
old_dir, old->
name, old->len);
1190 encode_diropargs3(xdr, args->
new_dir, new->name, new->len);
1201 static void nfs3_xdr_enc_link3args(
struct rpc_rqst *
req,
1202 struct xdr_stream *xdr,
1205 encode_nfs_fh3(xdr, args->
fromfh);
1219 static void encode_readdir3args(
struct xdr_stream *xdr,
1224 encode_nfs_fh3(xdr, args->
fh);
1227 p = xdr_encode_cookie3(p, args->
cookie);
1228 p = xdr_encode_cookieverf3(p, args->
verf);
1232 static void nfs3_xdr_enc_readdir3args(
struct rpc_rqst *
req,
1233 struct xdr_stream *xdr,
1236 encode_readdir3args(xdr, args);
1237 prepare_reply_buffer(req, args->
pages, 0,
1252 static void encode_readdirplus3args(
struct xdr_stream *xdr,
1257 encode_nfs_fh3(xdr, args->
fh);
1260 p = xdr_encode_cookie3(p, args->
cookie);
1261 p = xdr_encode_cookieverf3(p, args->
verf);
1272 static void nfs3_xdr_enc_readdirplus3args(
struct rpc_rqst *
req,
1273 struct xdr_stream *xdr,
1276 encode_readdirplus3args(xdr, args);
1277 prepare_reply_buffer(req, args->
pages, 0,
1290 static void encode_commit3args(
struct xdr_stream *xdr,
1295 encode_nfs_fh3(xdr, args->
fh);
1298 p = xdr_encode_hyper(p, args->
offset);
1302 static void nfs3_xdr_enc_commit3args(
struct rpc_rqst *
req,
1303 struct xdr_stream *xdr,
1306 encode_commit3args(xdr, args);
1309 #ifdef CONFIG_NFS_V3_ACL
1311 static void nfs3_xdr_enc_getacl3args(
struct rpc_rqst *
req,
1312 struct xdr_stream *xdr,
1315 encode_nfs_fh3(xdr, args->
fh);
1316 encode_uint32(xdr, args->
mask);
1318 prepare_reply_buffer(req, args->
pages, 0,
1323 static void nfs3_xdr_enc_setacl3args(
struct rpc_rqst *req,
1324 struct xdr_stream *xdr,
1330 encode_nfs_fh3(xdr, NFS_FH(args->
inode));
1331 encode_uint32(xdr, args->
mask);
1333 base = req->rq_slen;
1373 static int nfs3_xdr_dec_getattr3res(
struct rpc_rqst *req,
1374 struct xdr_stream *xdr,
1380 error = decode_nfsstat3(xdr, &status);
1385 error = decode_fattr3(xdr, result);
1389 return nfs3_stat_to_errno(status);
1410 static int nfs3_xdr_dec_setattr3res(
struct rpc_rqst *req,
1411 struct xdr_stream *xdr,
1417 error = decode_nfsstat3(xdr, &status);
1420 error = decode_wcc_data(xdr, result);
1428 return nfs3_stat_to_errno(status);
1451 static int nfs3_xdr_dec_lookup3res(
struct rpc_rqst *req,
1452 struct xdr_stream *xdr,
1458 error = decode_nfsstat3(xdr, &status);
1463 error = decode_nfs_fh3(xdr, result->
fh);
1466 error = decode_post_op_attr(xdr, result->
fattr);
1469 error = decode_post_op_attr(xdr, result->
dir_attr);
1473 error = decode_post_op_attr(xdr, result->
dir_attr);
1476 return nfs3_stat_to_errno(status);
1498 static int nfs3_xdr_dec_access3res(
struct rpc_rqst *req,
1499 struct xdr_stream *xdr,
1505 error = decode_nfsstat3(xdr, &status);
1508 error = decode_post_op_attr(xdr, result->
fattr);
1513 error = decode_uint32(xdr, &result->
access);
1517 return nfs3_stat_to_errno(status);
1539 static int nfs3_xdr_dec_readlink3res(
struct rpc_rqst *req,
1540 struct xdr_stream *xdr,
1546 error = decode_nfsstat3(xdr, &status);
1549 error = decode_post_op_attr(xdr, result);
1554 error = decode_nfspath3(xdr);
1558 return nfs3_stat_to_errno(status);
1582 static int decode_read3resok(
struct xdr_stream *xdr,
1604 dprintk(
"NFS: READ count doesn't match length of opaque: "
1605 "count %u != ocount %u\n", count, ocount);
1608 dprintk(
"NFS: server cheating in read result: "
1609 "count %u > recvd %u\n", count, recvd);
1614 print_overflow_msg(__func__, xdr);
1618 static int nfs3_xdr_dec_read3res(
struct rpc_rqst *req,
struct xdr_stream *xdr,
1624 error = decode_nfsstat3(xdr, &status);
1627 error = decode_post_op_attr(xdr, result->
fattr);
1632 error = decode_read3resok(xdr, result);
1636 return nfs3_stat_to_errno(status);
1666 static int decode_write3resok(
struct xdr_stream *xdr,
1678 if (decode_writeverf3(xdr, &result->
verf->verifier))
1680 return result->
count;
1682 dprintk(
"NFS: bad stable_how value: %u\n", result->
verf->committed);
1685 print_overflow_msg(__func__, xdr);
1690 static int nfs3_xdr_dec_write3res(
struct rpc_rqst *req,
struct xdr_stream *xdr,
1696 error = decode_nfsstat3(xdr, &status);
1699 error = decode_wcc_data(xdr, result->
fattr);
1704 error = decode_write3resok(xdr, result);
1708 return nfs3_stat_to_errno(status);
1731 static int decode_create3resok(
struct xdr_stream *xdr,
1736 error = decode_post_op_fh3(xdr, result->
fh);
1739 error = decode_post_op_attr(xdr, result->
fattr);
1746 if (result->
fh->size == 0)
1747 result->
fattr->valid = 0;
1748 error = decode_wcc_data(xdr, result->
dir_attr);
1753 static int nfs3_xdr_dec_create3res(
struct rpc_rqst *req,
1754 struct xdr_stream *xdr,
1760 error = decode_nfsstat3(xdr, &status);
1765 error = decode_create3resok(xdr, result);
1769 error = decode_wcc_data(xdr, result->
dir_attr);
1772 return nfs3_stat_to_errno(status);
1793 static int nfs3_xdr_dec_remove3res(
struct rpc_rqst *req,
1794 struct xdr_stream *xdr,
1800 error = decode_nfsstat3(xdr, &status);
1803 error = decode_wcc_data(xdr, result->
dir_attr);
1811 return nfs3_stat_to_errno(status);
1834 static int nfs3_xdr_dec_rename3res(
struct rpc_rqst *req,
1835 struct xdr_stream *xdr,
1841 error = decode_nfsstat3(xdr, &status);
1844 error = decode_wcc_data(xdr, result->
old_fattr);
1847 error = decode_wcc_data(xdr, result->
new_fattr);
1855 return nfs3_stat_to_errno(status);
1878 static int nfs3_xdr_dec_link3res(
struct rpc_rqst *req,
struct xdr_stream *xdr,
1884 error = decode_nfsstat3(xdr, &status);
1887 error = decode_post_op_attr(xdr, result->
fattr);
1890 error = decode_wcc_data(xdr, result->
dir_attr);
1898 return nfs3_stat_to_errno(status);
1946 if (*p == xdr_zero) {
1956 error = decode_fileid3(xdr, &entry->
ino);
1960 error = decode_inline_filename3(xdr, &entry->
name, &entry->
len);
1965 error = decode_cookie3(xdr, &entry->
cookie);
1972 entry->
fattr->valid = 0;
1973 error = decode_post_op_attr(xdr, entry->
fattr);
1977 entry->
d_type = nfs_umode_to_dtype(entry->
fattr->mode);
1983 if (*p != xdr_zero) {
1984 error = decode_nfs_fh3(xdr, entry->
fh);
1986 if (error == -
E2BIG)
1991 zero_nfs_fh3(entry->
fh);
1997 print_overflow_msg(__func__, xdr);
2000 dprintk(
"NFS: directory entry contains invalid file handle\n");
2034 static int decode_dirlist3(
struct xdr_stream *xdr)
2039 static int decode_readdir3resok(
struct xdr_stream *xdr,
2044 error = decode_post_op_attr(xdr, result->
dir_attr);
2048 error = decode_cookieverf3(xdr, result->
verf);
2051 error = decode_dirlist3(xdr);
2056 static int nfs3_xdr_dec_readdir3res(
struct rpc_rqst *req,
2057 struct xdr_stream *xdr,
2063 error = decode_nfsstat3(xdr, &status);
2068 error = decode_readdir3resok(xdr, result);
2072 error = decode_post_op_attr(xdr, result->
dir_attr);
2075 return nfs3_stat_to_errno(status);
2103 static int decode_fsstat3resok(
struct xdr_stream *xdr,
2111 p = xdr_decode_size3(p, &result->
tbytes);
2112 p = xdr_decode_size3(p, &result->
fbytes);
2113 p = xdr_decode_size3(p, &result->
abytes);
2114 p = xdr_decode_size3(p, &result->
tfiles);
2115 p = xdr_decode_size3(p, &result->
ffiles);
2116 xdr_decode_size3(p, &result->
afiles);
2120 print_overflow_msg(__func__, xdr);
2124 static int nfs3_xdr_dec_fsstat3res(
struct rpc_rqst *req,
2125 struct xdr_stream *xdr,
2131 error = decode_nfsstat3(xdr, &status);
2134 error = decode_post_op_attr(xdr, result->
fattr);
2139 error = decode_fsstat3resok(xdr, result);
2143 return nfs3_stat_to_errno(status);
2174 static int decode_fsinfo3resok(
struct xdr_stream *xdr,
2196 print_overflow_msg(__func__, xdr);
2200 static int nfs3_xdr_dec_fsinfo3res(
struct rpc_rqst *req,
2201 struct xdr_stream *xdr,
2207 error = decode_nfsstat3(xdr, &status);
2210 error = decode_post_op_attr(xdr, result->
fattr);
2215 error = decode_fsinfo3resok(xdr, result);
2219 return nfs3_stat_to_errno(status);
2246 static int decode_pathconf3resok(
struct xdr_stream *xdr,
2259 print_overflow_msg(__func__, xdr);
2263 static int nfs3_xdr_dec_pathconf3res(
struct rpc_rqst *req,
2264 struct xdr_stream *xdr,
2270 error = decode_nfsstat3(xdr, &status);
2273 error = decode_post_op_attr(xdr, result->
fattr);
2278 error = decode_pathconf3resok(xdr, result);
2282 return nfs3_stat_to_errno(status);
2304 static int nfs3_xdr_dec_commit3res(
struct rpc_rqst *req,
2305 struct xdr_stream *xdr,
2311 error = decode_nfsstat3(xdr, &status);
2314 error = decode_wcc_data(xdr, result->
fattr);
2319 error = decode_writeverf3(xdr, &result->
verf->verifier);
2323 return nfs3_stat_to_errno(status);
2326 #ifdef CONFIG_NFS_V3_ACL
2328 static inline int decode_getacl3resok(
struct xdr_stream *xdr,
2332 unsigned int *aclcnt;
2336 error = decode_post_op_attr(xdr, result->
fattr);
2339 error = decode_uint32(xdr, &result->
mask);
2364 error =
nfsacl_decode(xdr->buf, hdrlen + error, aclcnt, acl);
2372 static int nfs3_xdr_dec_getacl3res(
struct rpc_rqst *req,
2373 struct xdr_stream *xdr,
2379 error = decode_nfsstat3(xdr, &status);
2384 error = decode_getacl3resok(xdr, result);
2388 return nfs3_stat_to_errno(status);
2391 static int nfs3_xdr_dec_setacl3res(
struct rpc_rqst *req,
2392 struct xdr_stream *xdr,
2398 error = decode_nfsstat3(xdr, &status);
2403 error = decode_post_op_attr(xdr, result);
2407 return nfs3_stat_to_errno(status);
2417 static const struct {
2464 static int nfs3_stat_to_errno(
enum nfs_stat status)
2468 for (i = 0; nfs_errtbl[
i].stat != -1; i++) {
2469 if (nfs_errtbl[i].
stat == (
int)status)
2470 return nfs_errtbl[
i].errno;
2472 dprintk(
"NFS: Unrecognized nfs status value: %u\n", status);
2473 return nfs_errtbl[
i].errno;
2477 #define PROC(proc, argtype, restype, timer) \
2478 [NFS3PROC_##proc] = { \
2479 .p_proc = NFS3PROC_##proc, \
2480 .p_encode = (kxdreproc_t)nfs3_xdr_enc_##argtype##3args, \
2481 .p_decode = (kxdrdproc_t)nfs3_xdr_dec_##restype##3res, \
2482 .p_arglen = NFS3_##argtype##args_sz, \
2483 .p_replen = NFS3_##restype##res_sz, \
2485 .p_statidx = NFS3PROC_##proc, \
2490 PROC(GETATTR, getattr, getattr, 1),
2491 PROC(SETATTR, setattr, setattr, 0),
2494 PROC(READLINK, readlink, readlink, 3),
2503 PROC(RENAME, rename, rename, 0),
2505 PROC(READDIR, readdir, readdir, 3),
2506 PROC(READDIRPLUS, readdirplus, readdir, 3),
2507 PROC(FSSTAT, getattr, fsstat, 0),
2508 PROC(FSINFO, getattr, fsinfo, 0),
2509 PROC(PATHCONF, getattr, pathconf, 0),
2516 .procs = nfs3_procedures
2519 #ifdef CONFIG_NFS_V3_ACL
2523 .p_encode = (kxdreproc_t)nfs3_xdr_enc_getacl3args,
2524 .
p_decode = (kxdrdproc_t)nfs3_xdr_dec_getacl3res,
2532 .p_encode = (kxdreproc_t)nfs3_xdr_enc_setacl3args,
2533 .
p_decode = (kxdrdproc_t)nfs3_xdr_dec_setacl3res,
2543 .nrprocs =
sizeof(nfs3_acl_procedures)/
2544 sizeof(nfs3_acl_procedures[0]),
2545 .procs = nfs3_acl_procedures,