Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfsd: factor out a helper to decode nfstime4 values

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>

authored by

Christoph Hellwig and committed by
J. Bruce Fields
4c94e13e 3c519914

+26 -17
+26 -17
fs/nfsd/nfs4xdr.c
··· 234 234 return ret; 235 235 } 236 236 237 + /* 238 + * We require the high 32 bits of 'seconds' to be 0, and 239 + * we ignore all 32 bits of 'nseconds'. 240 + */ 241 + static __be32 242 + nfsd4_decode_time(struct nfsd4_compoundargs *argp, struct timespec *tv) 243 + { 244 + DECODE_HEAD; 245 + u64 sec; 246 + 247 + READ_BUF(12); 248 + p = xdr_decode_hyper(p, &sec); 249 + tv->tv_sec = sec; 250 + tv->tv_nsec = be32_to_cpup(p++); 251 + if (tv->tv_nsec >= (u32)1000000000) 252 + return nfserr_inval; 253 + 254 + DECODE_TAIL; 255 + } 256 + 237 257 static __be32 238 258 nfsd4_decode_bitmap(struct nfsd4_compoundargs *argp, u32 *bmval) 239 259 { ··· 287 267 { 288 268 int expected_len, len = 0; 289 269 u32 dummy32; 290 - u64 sec; 291 270 char *buf; 292 271 293 272 DECODE_HEAD; ··· 377 358 dummy32 = be32_to_cpup(p++); 378 359 switch (dummy32) { 379 360 case NFS4_SET_TO_CLIENT_TIME: 380 - /* We require the high 32 bits of 'seconds' to be 0, and we ignore 381 - all 32 bits of 'nseconds'. */ 382 - READ_BUF(12); 383 361 len += 12; 384 - p = xdr_decode_hyper(p, &sec); 385 - iattr->ia_atime.tv_sec = (time_t)sec; 386 - iattr->ia_atime.tv_nsec = be32_to_cpup(p++); 387 - if (iattr->ia_atime.tv_nsec >= (u32)1000000000) 388 - return nfserr_inval; 362 + status = nfsd4_decode_time(argp, &iattr->ia_atime); 363 + if (status) 364 + return status; 389 365 iattr->ia_valid |= (ATTR_ATIME | ATTR_ATIME_SET); 390 366 break; 391 367 case NFS4_SET_TO_SERVER_TIME: ··· 396 382 dummy32 = be32_to_cpup(p++); 397 383 switch (dummy32) { 398 384 case NFS4_SET_TO_CLIENT_TIME: 399 - /* We require the high 32 bits of 'seconds' to be 0, and we ignore 400 - all 32 bits of 'nseconds'. */ 401 - READ_BUF(12); 402 385 len += 12; 403 - p = xdr_decode_hyper(p, &sec); 404 - iattr->ia_mtime.tv_sec = sec; 405 - iattr->ia_mtime.tv_nsec = be32_to_cpup(p++); 406 - if (iattr->ia_mtime.tv_nsec >= (u32)1000000000) 407 - return nfserr_inval; 386 + status = nfsd4_decode_time(argp, &iattr->ia_mtime); 387 + if (status) 388 + return status; 408 389 iattr->ia_valid |= (ATTR_MTIME | ATTR_MTIME_SET); 409 390 break; 410 391 case NFS4_SET_TO_SERVER_TIME: