xdr4.c (03ab8e6297acd1bc0eedaa050e2a1635c576fd11) | xdr4.c (6930bcbfb6ceda63e298c6af6d733ecdf6bd4cde) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/fs/lockd/xdr4.c 4 * 5 * XDR support for lockd and the lock client. 6 * 7 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> 8 * Copyright (C) 1999, Trond Myklebust <trond.myklebust@fys.uio.no> --- 6 unchanged lines hidden (view full) --- 15#include <linux/sunrpc/xdr.h> 16#include <linux/sunrpc/clnt.h> 17#include <linux/sunrpc/svc.h> 18#include <linux/sunrpc/stats.h> 19#include <linux/lockd/lockd.h> 20 21#include "svcxdr.h" 22 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/fs/lockd/xdr4.c 4 * 5 * XDR support for lockd and the lock client. 6 * 7 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> 8 * Copyright (C) 1999, Trond Myklebust <trond.myklebust@fys.uio.no> --- 6 unchanged lines hidden (view full) --- 15#include <linux/sunrpc/xdr.h> 16#include <linux/sunrpc/clnt.h> 17#include <linux/sunrpc/svc.h> 18#include <linux/sunrpc/stats.h> 19#include <linux/lockd/lockd.h> 20 21#include "svcxdr.h" 22 |
23static inline loff_t 24s64_to_loff_t(__s64 offset) 25{ 26 return (loff_t)offset; 27} 28 29 | |
30static inline s64 31loff_t_to_s64(loff_t offset) 32{ 33 s64 res; 34 if (offset > NLM4_OFFSET_MAX) 35 res = NLM4_OFFSET_MAX; 36 else if (offset < -NLM4_OFFSET_MAX) 37 res = -NLM4_OFFSET_MAX; --- 27 unchanged lines hidden (view full) --- 65 66 return true; 67} 68 69static bool 70svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock) 71{ 72 struct file_lock *fl = &lock->fl; | 23static inline s64 24loff_t_to_s64(loff_t offset) 25{ 26 s64 res; 27 if (offset > NLM4_OFFSET_MAX) 28 res = NLM4_OFFSET_MAX; 29 else if (offset < -NLM4_OFFSET_MAX) 30 res = -NLM4_OFFSET_MAX; --- 27 unchanged lines hidden (view full) --- 58 59 return true; 60} 61 62static bool 63svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock) 64{ 65 struct file_lock *fl = &lock->fl; |
73 u64 len, start; 74 s64 end; | |
75 76 if (!svcxdr_decode_string(xdr, &lock->caller, &lock->len)) 77 return false; 78 if (!svcxdr_decode_fhandle(xdr, &lock->fh)) 79 return false; 80 if (!svcxdr_decode_owner(xdr, &lock->oh)) 81 return false; 82 if (xdr_stream_decode_u32(xdr, &lock->svid) < 0) 83 return false; | 66 67 if (!svcxdr_decode_string(xdr, &lock->caller, &lock->len)) 68 return false; 69 if (!svcxdr_decode_fhandle(xdr, &lock->fh)) 70 return false; 71 if (!svcxdr_decode_owner(xdr, &lock->oh)) 72 return false; 73 if (xdr_stream_decode_u32(xdr, &lock->svid) < 0) 74 return false; |
84 if (xdr_stream_decode_u64(xdr, &start) < 0) | 75 if (xdr_stream_decode_u64(xdr, &lock->lock_start) < 0) |
85 return false; | 76 return false; |
86 if (xdr_stream_decode_u64(xdr, &len) < 0) | 77 if (xdr_stream_decode_u64(xdr, &lock->lock_len) < 0) |
87 return false; 88 89 locks_init_lock(fl); 90 fl->fl_flags = FL_POSIX; 91 fl->fl_type = F_RDLCK; | 78 return false; 79 80 locks_init_lock(fl); 81 fl->fl_flags = FL_POSIX; 82 fl->fl_type = F_RDLCK; |
92 end = start + len - 1; 93 fl->fl_start = s64_to_loff_t(start); 94 if (len == 0 || end < 0) 95 fl->fl_end = OFFSET_MAX; 96 else 97 fl->fl_end = s64_to_loff_t(end); | |
98 99 return true; 100} 101 102static bool 103svcxdr_encode_holder(struct xdr_stream *xdr, const struct nlm_lock *lock) 104{ 105 const struct file_lock *fl = &lock->fl; --- 248 unchanged lines hidden --- | 83 84 return true; 85} 86 87static bool 88svcxdr_encode_holder(struct xdr_stream *xdr, const struct nlm_lock *lock) 89{ 90 const struct file_lock *fl = &lock->fl; --- 248 unchanged lines hidden --- |