@@ -80,15 +80,6 @@ svcxdr_decode_fhandle(struct xdr_stream *xdr, struct nfs_fh *fh)
80
80
return true;
81
81
}
82
82
83
- /*
84
- * Encode and decode owner handle
85
- */
86
- static inline __be32 *
87
- nlm_encode_oh (__be32 * p , struct xdr_netobj * oh )
88
- {
89
- return xdr_encode_netobj (p , oh );
90
- }
91
-
92
83
static bool
93
84
svcxdr_decode_lock (struct xdr_stream * xdr , struct nlm_lock * lock )
94
85
{
@@ -121,39 +112,44 @@ svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock)
121
112
return true;
122
113
}
123
114
124
- /*
125
- * Encode result of a TEST/TEST_MSG call
126
- */
127
- static __be32 *
128
- nlm_encode_testres (__be32 * p , struct nlm_res * resp )
115
+ static bool
116
+ svcxdr_encode_holder (struct xdr_stream * xdr , const struct nlm_lock * lock )
129
117
{
130
- s32 start , len ;
131
-
132
- if (!(p = nlm_encode_cookie (p , & resp -> cookie )))
133
- return NULL ;
134
- * p ++ = resp -> status ;
118
+ const struct file_lock * fl = & lock -> fl ;
119
+ s32 start , len ;
135
120
136
- if (resp -> status == nlm_lck_denied ) {
137
- struct file_lock * fl = & resp -> lock .fl ;
138
-
139
- * p ++ = (fl -> fl_type == F_RDLCK )? xdr_zero : xdr_one ;
140
- * p ++ = htonl (resp -> lock .svid );
141
-
142
- /* Encode owner handle. */
143
- if (!(p = xdr_encode_netobj (p , & resp -> lock .oh )))
144
- return NULL ;
121
+ /* exclusive */
122
+ if (xdr_stream_encode_bool (xdr , fl -> fl_type != F_RDLCK ) < 0 )
123
+ return false;
124
+ if (xdr_stream_encode_u32 (xdr , lock -> svid ) < 0 )
125
+ return false;
126
+ if (!svcxdr_encode_owner (xdr , & lock -> oh ))
127
+ return false;
128
+ start = loff_t_to_s32 (fl -> fl_start );
129
+ if (fl -> fl_end == OFFSET_MAX )
130
+ len = 0 ;
131
+ else
132
+ len = loff_t_to_s32 (fl -> fl_end - fl -> fl_start + 1 );
133
+ if (xdr_stream_encode_u32 (xdr , start ) < 0 )
134
+ return false;
135
+ if (xdr_stream_encode_u32 (xdr , len ) < 0 )
136
+ return false;
145
137
146
- start = loff_t_to_s32 (fl -> fl_start );
147
- if (fl -> fl_end == OFFSET_MAX )
148
- len = 0 ;
149
- else
150
- len = loff_t_to_s32 (fl -> fl_end - fl -> fl_start + 1 );
138
+ return true;
139
+ }
151
140
152
- * p ++ = htonl (start );
153
- * p ++ = htonl (len );
141
+ static bool
142
+ svcxdr_encode_testrply (struct xdr_stream * xdr , const struct nlm_res * resp )
143
+ {
144
+ if (!svcxdr_encode_stats (xdr , resp -> status ))
145
+ return false;
146
+ switch (resp -> status ) {
147
+ case nlm_lck_denied :
148
+ if (!svcxdr_encode_holder (xdr , & resp -> lock ))
149
+ return false;
154
150
}
155
151
156
- return p ;
152
+ return true ;
157
153
}
158
154
159
155
@@ -345,11 +341,11 @@ nlmsvc_encode_void(struct svc_rqst *rqstp, __be32 *p)
345
341
int
346
342
nlmsvc_encode_testres (struct svc_rqst * rqstp , __be32 * p )
347
343
{
344
+ struct xdr_stream * xdr = & rqstp -> rq_res_stream ;
348
345
struct nlm_res * resp = rqstp -> rq_resp ;
349
346
350
- if (!(p = nlm_encode_testres (p , resp )))
351
- return 0 ;
352
- return xdr_ressize_check (rqstp , p );
347
+ return svcxdr_encode_cookie (xdr , & resp -> cookie ) &&
348
+ svcxdr_encode_testrply (xdr , resp );
353
349
}
354
350
355
351
int
0 commit comments