10 #include <linux/types.h>
11 #include <linux/sched.h>
12 #include <linux/nfs.h>
20 #define NLMDBG_FACILITY NLMDBG_XDR
30 loff_t_to_s64(loff_t
offset)
65 dprintk(
"lockd: bad cookie size %d (only cookies under "
66 "%d bytes are supported.)\n",
78 p+=XDR_QUADLEN(c->
len);
88 dprintk(
"lockd: bad fhandle size %d (should be <=%d)\n",
93 return p + XDR_QUADLEN(f->
size);
100 nlm4_decode_oh(
__be32 *p,
struct xdr_netobj *oh)
114 || !(p = nlm4_decode_fh(p, &lock->
fh))
115 || !(p = nlm4_decode_oh(p, &lock->
oh)))
124 p = xdr_decode_hyper(p, &start);
125 p = xdr_decode_hyper(p, &len);
126 end = start + len - 1;
128 fl->
fl_start = s64_to_loff_t(start);
130 if (len == 0 || end < 0)
133 fl->
fl_end = s64_to_loff_t(end);
145 dprintk(
"xdr: before encode_testres (p %p resp %p)\n", p, resp);
146 if (!(p = nlm4_encode_cookie(p, &resp->
cookie)))
160 start = loff_t_to_s64(fl->
fl_start);
166 p = xdr_encode_hyper(p, start);
167 p = xdr_encode_hyper(p, len);
168 dprintk(
"xdr: encode_testres (status %u pid %d type %d start %Ld end %Ld)\n",
173 dprintk(
"xdr: after encode_testres (p %p resp %p)\n", p, resp);
186 if (!(p = nlm4_decode_cookie(p, &argp->
cookie)))
189 exclusive =
ntohl(*p++);
190 if (!(p = nlm4_decode_lock(p, &argp->
lock)))
195 return xdr_argsize_check(rqstp, p);
201 if (!(p = nlm4_encode_testres(p, resp)))
203 return xdr_ressize_check(rqstp, p);
211 if (!(p = nlm4_decode_cookie(p, &argp->
cookie)))
214 exclusive =
ntohl(*p++);
215 if (!(p = nlm4_decode_lock(p, &argp->
lock)))
223 return xdr_argsize_check(rqstp, p);
231 if (!(p = nlm4_decode_cookie(p, &argp->
cookie)))
234 exclusive =
ntohl(*p++);
235 if (!(p = nlm4_decode_lock(p, &argp->
lock)))
239 return xdr_argsize_check(rqstp, p);
245 if (!(p = nlm4_decode_cookie(p, &argp->
cookie))
246 || !(p = nlm4_decode_lock(p, &argp->
lock)))
249 return xdr_argsize_check(rqstp, p);
257 memset(lock, 0,
sizeof(*lock));
262 if (!(p = nlm4_decode_cookie(p, &argp->
cookie))
265 || !(p = nlm4_decode_fh(p, &lock->
fh))
266 || !(p = nlm4_decode_oh(p, &lock->
oh)))
270 return xdr_argsize_check(rqstp, p);
276 if (!(p = nlm4_encode_cookie(p, &resp->
cookie)))
280 return xdr_ressize_check(rqstp, p);
286 if (!(p = nlm4_encode_cookie(p, &resp->
cookie)))
289 return xdr_ressize_check(rqstp, p);
301 return xdr_argsize_check(rqstp, p);
312 return xdr_argsize_check(rqstp, p);
318 if (!(p = nlm4_decode_cookie(p, &resp->
cookie)))
321 return xdr_argsize_check(rqstp, p);
327 return xdr_argsize_check(rqstp, p);
333 return xdr_ressize_check(rqstp, p);