diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2010-12-14 09:55:30 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-12-16 12:37:21 -0500 |
commit | 5f96e5e31b4f4a2f126adfe0586a7555c11b0562 (patch) | |
tree | 1b9b79a6af6d8208755acb09d40687208d248de4 /fs | |
parent | 661ad4239a51a2169a366a227c68cf3b654ab936 (diff) |
NFS: Move and update xdr_decode_foo() functions that we're keeping
Clean up.
Move the timestamp decoder to match the placement and naming
conventions of the other helpers. Fold xdr_decode_fattr() into
decode_fattr(), which is now it's only user.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/nfs2xdr.c | 97 |
1 files changed, 56 insertions, 41 deletions
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c index ae751163da8b..70df08a84ead 100644 --- a/fs/nfs/nfs2xdr.c +++ b/fs/nfs/nfs2xdr.c | |||
@@ -89,46 +89,6 @@ static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | |||
89 | 89 | ||
90 | 90 | ||
91 | /* | 91 | /* |
92 | * Common NFS XDR functions as inlines | ||
93 | */ | ||
94 | static inline __be32* | ||
95 | xdr_decode_time(__be32 *p, struct timespec *timep) | ||
96 | { | ||
97 | timep->tv_sec = ntohl(*p++); | ||
98 | /* Convert microseconds into nanoseconds */ | ||
99 | timep->tv_nsec = ntohl(*p++) * 1000; | ||
100 | return p; | ||
101 | } | ||
102 | |||
103 | static __be32 * | ||
104 | xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr) | ||
105 | { | ||
106 | u32 rdev, type; | ||
107 | type = ntohl(*p++); | ||
108 | fattr->mode = ntohl(*p++); | ||
109 | fattr->nlink = ntohl(*p++); | ||
110 | fattr->uid = ntohl(*p++); | ||
111 | fattr->gid = ntohl(*p++); | ||
112 | fattr->size = ntohl(*p++); | ||
113 | fattr->du.nfs2.blocksize = ntohl(*p++); | ||
114 | rdev = ntohl(*p++); | ||
115 | fattr->du.nfs2.blocks = ntohl(*p++); | ||
116 | fattr->fsid.major = ntohl(*p++); | ||
117 | fattr->fsid.minor = 0; | ||
118 | fattr->fileid = ntohl(*p++); | ||
119 | p = xdr_decode_time(p, &fattr->atime); | ||
120 | p = xdr_decode_time(p, &fattr->mtime); | ||
121 | p = xdr_decode_time(p, &fattr->ctime); | ||
122 | fattr->valid |= NFS_ATTR_FATTR_V2; | ||
123 | fattr->rdev = new_decode_dev(rdev); | ||
124 | if (type == NFCHR && rdev == NFS2_FIFO_DEV) { | ||
125 | fattr->mode = (fattr->mode & ~S_IFMT) | S_IFIFO; | ||
126 | fattr->rdev = 0; | ||
127 | } | ||
128 | return p; | ||
129 | } | ||
130 | |||
131 | /* | ||
132 | * Encode/decode NFSv2 basic data types | 92 | * Encode/decode NFSv2 basic data types |
133 | * | 93 | * |
134 | * Basic NFSv2 data types are defined in section 2.3 of RFC 1094: | 94 | * Basic NFSv2 data types are defined in section 2.3 of RFC 1094: |
@@ -208,6 +168,27 @@ out_overflow: | |||
208 | } | 168 | } |
209 | 169 | ||
210 | /* | 170 | /* |
171 | * 2.3.2. ftype | ||
172 | * | ||
173 | * enum ftype { | ||
174 | * NFNON = 0, | ||
175 | * NFREG = 1, | ||
176 | * NFDIR = 2, | ||
177 | * NFBLK = 3, | ||
178 | * NFCHR = 4, | ||
179 | * NFLNK = 5 | ||
180 | * }; | ||
181 | * | ||
182 | */ | ||
183 | static __be32 *xdr_decode_ftype(__be32 *p, u32 *type) | ||
184 | { | ||
185 | *type = be32_to_cpup(p++); | ||
186 | if (unlikely(*type > NF2FIFO)) | ||
187 | *type = NFBAD; | ||
188 | return p; | ||
189 | } | ||
190 | |||
191 | /* | ||
211 | * 2.3.3. fhandle | 192 | * 2.3.3. fhandle |
212 | * | 193 | * |
213 | * typedef opaque fhandle[FHSIZE]; | 194 | * typedef opaque fhandle[FHSIZE]; |
@@ -269,6 +250,13 @@ static __be32 *xdr_encode_current_server_time(__be32 *p, | |||
269 | return p; | 250 | return p; |
270 | } | 251 | } |
271 | 252 | ||
253 | static __be32 *xdr_decode_time(__be32 *p, struct timespec *timep) | ||
254 | { | ||
255 | timep->tv_sec = be32_to_cpup(p++); | ||
256 | timep->tv_nsec = be32_to_cpup(p++) * NSEC_PER_USEC; | ||
257 | return p; | ||
258 | } | ||
259 | |||
272 | /* | 260 | /* |
273 | * 2.3.5. fattr | 261 | * 2.3.5. fattr |
274 | * | 262 | * |
@@ -292,12 +280,39 @@ static __be32 *xdr_encode_current_server_time(__be32 *p, | |||
292 | */ | 280 | */ |
293 | static int decode_fattr(struct xdr_stream *xdr, struct nfs_fattr *fattr) | 281 | static int decode_fattr(struct xdr_stream *xdr, struct nfs_fattr *fattr) |
294 | { | 282 | { |
283 | u32 rdev, type; | ||
295 | __be32 *p; | 284 | __be32 *p; |
296 | 285 | ||
297 | p = xdr_inline_decode(xdr, NFS_fattr_sz << 2); | 286 | p = xdr_inline_decode(xdr, NFS_fattr_sz << 2); |
298 | if (unlikely(p == NULL)) | 287 | if (unlikely(p == NULL)) |
299 | goto out_overflow; | 288 | goto out_overflow; |
300 | xdr_decode_fattr(p, fattr); | 289 | |
290 | fattr->valid |= NFS_ATTR_FATTR_V2; | ||
291 | |||
292 | p = xdr_decode_ftype(p, &type); | ||
293 | |||
294 | fattr->mode = be32_to_cpup(p++); | ||
295 | fattr->nlink = be32_to_cpup(p++); | ||
296 | fattr->uid = be32_to_cpup(p++); | ||
297 | fattr->gid = be32_to_cpup(p++); | ||
298 | fattr->size = be32_to_cpup(p++); | ||
299 | fattr->du.nfs2.blocksize = be32_to_cpup(p++); | ||
300 | |||
301 | rdev = be32_to_cpup(p++); | ||
302 | fattr->rdev = new_decode_dev(rdev); | ||
303 | if (type == (u32)NFCHR && rdev == (u32)NFS2_FIFO_DEV) { | ||
304 | fattr->mode = (fattr->mode & ~S_IFMT) | S_IFIFO; | ||
305 | fattr->rdev = 0; | ||
306 | } | ||
307 | |||
308 | fattr->du.nfs2.blocks = be32_to_cpup(p++); | ||
309 | fattr->fsid.major = be32_to_cpup(p++); | ||
310 | fattr->fsid.minor = 0; | ||
311 | fattr->fileid = be32_to_cpup(p++); | ||
312 | |||
313 | p = xdr_decode_time(p, &fattr->atime); | ||
314 | p = xdr_decode_time(p, &fattr->mtime); | ||
315 | xdr_decode_time(p, &fattr->ctime); | ||
301 | return 0; | 316 | return 0; |
302 | out_overflow: | 317 | out_overflow: |
303 | print_overflow_msg(__func__, xdr); | 318 | print_overflow_msg(__func__, xdr); |