~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/sunrpc/xdr.h

Version: ~ [ linux-5.16 ] ~ [ linux-5.15.13 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.90 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.170 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.224 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.261 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.296 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.298 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * XDR standard data types and function declarations
  4  *
  5  * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
  6  *
  7  * Based on:
  8  *   RFC 4506 "XDR: External Data Representation Standard", May 2006
  9  */
 10 
 11 #ifndef _SUNRPC_XDR_H_
 12 #define _SUNRPC_XDR_H_
 13 
 14 #include <linux/uio.h>
 15 #include <asm/byteorder.h>
 16 #include <asm/unaligned.h>
 17 #include <linux/scatterlist.h>
 18 
 19 struct bio_vec;
 20 struct rpc_rqst;
 21 
 22 /*
 23  * Buffer adjustment
 24  */
 25 #define XDR_QUADLEN(l)          (((l) + 3) >> 2)
 26 
 27 /*
 28  * Generic opaque `network object.' At the kernel level, this type
 29  * is used only by lockd.
 30  */
 31 #define XDR_MAX_NETOBJ          1024
 32 struct xdr_netobj {
 33         unsigned int            len;
 34         u8 *                    data;
 35 };
 36 
 37 /*
 38  * Basic structure for transmission/reception of a client XDR message.
 39  * Features a header (for a linear buffer containing RPC headers
 40  * and the data payload for short messages), and then an array of
 41  * pages.
 42  * The tail iovec allows you to append data after the page array. Its
 43  * main interest is for appending padding to the pages in order to
 44  * satisfy the int_32-alignment requirements in RFC1832.
 45  *
 46  * For the future, we might want to string several of these together
 47  * in a list if anybody wants to make use of NFSv4 COMPOUND
 48  * operations and/or has a need for scatter/gather involving pages.
 49  */
 50 struct xdr_buf {
 51         struct kvec     head[1],        /* RPC header + non-page data */
 52                         tail[1];        /* Appended after page data */
 53 
 54         struct bio_vec  *bvec;
 55         struct page **  pages;          /* Array of pages */
 56         unsigned int    page_base,      /* Start of page data */
 57                         page_len,       /* Length of page data */
 58                         flags;          /* Flags for data disposition */
 59 #define XDRBUF_READ             0x01            /* target of file read */
 60 #define XDRBUF_WRITE            0x02            /* source of file write */
 61 #define XDRBUF_SPARSE_PAGES     0x04            /* Page array is sparse */
 62 
 63         unsigned int    buflen,         /* Total length of storage buffer */
 64                         len;            /* Length of XDR encoded message */
 65 };
 66 
 67 static inline void
 68 xdr_buf_init(struct xdr_buf *buf, void *start, size_t len)
 69 {
 70         buf->head[0].iov_base = start;
 71         buf->head[0].iov_len = len;
 72         buf->tail[0].iov_len = 0;
 73         buf->pages = NULL;
 74         buf->page_len = 0;
 75         buf->flags = 0;
 76         buf->len = 0;
 77         buf->buflen = len;
 78 }
 79 
 80 /*
 81  * pre-xdr'ed macros.
 82  */
 83 
 84 #define xdr_zero        cpu_to_be32(0)
 85 #define xdr_one         cpu_to_be32(1)
 86 #define xdr_two         cpu_to_be32(2)
 87 
 88 #define rpc_auth_null   cpu_to_be32(RPC_AUTH_NULL)
 89 #define rpc_auth_unix   cpu_to_be32(RPC_AUTH_UNIX)
 90 #define rpc_auth_short  cpu_to_be32(RPC_AUTH_SHORT)
 91 #define rpc_auth_gss    cpu_to_be32(RPC_AUTH_GSS)
 92 
 93 #define rpc_call        cpu_to_be32(RPC_CALL)
 94 #define rpc_reply       cpu_to_be32(RPC_REPLY)
 95 
 96 #define rpc_msg_accepted        cpu_to_be32(RPC_MSG_ACCEPTED)
 97 
 98 #define rpc_success             cpu_to_be32(RPC_SUCCESS)
 99 #define rpc_prog_unavail        cpu_to_be32(RPC_PROG_UNAVAIL)
100 #define rpc_prog_mismatch       cpu_to_be32(RPC_PROG_MISMATCH)
101 #define rpc_proc_unavail        cpu_to_be32(RPC_PROC_UNAVAIL)
102 #define rpc_garbage_args        cpu_to_be32(RPC_GARBAGE_ARGS)
103 #define rpc_system_err          cpu_to_be32(RPC_SYSTEM_ERR)
104 #define rpc_drop_reply          cpu_to_be32(RPC_DROP_REPLY)
105 
106 #define rpc_mismatch            cpu_to_be32(RPC_MISMATCH)
107 #define rpc_auth_error          cpu_to_be32(RPC_AUTH_ERROR)
108 
109 #define rpc_auth_ok             cpu_to_be32(RPC_AUTH_OK)
110 #define rpc_autherr_badcred     cpu_to_be32(RPC_AUTH_BADCRED)
111 #define rpc_autherr_rejectedcred cpu_to_be32(RPC_AUTH_REJECTEDCRED)
112 #define rpc_autherr_badverf     cpu_to_be32(RPC_AUTH_BADVERF)
113 #define rpc_autherr_rejectedverf cpu_to_be32(RPC_AUTH_REJECTEDVERF)
114 #define rpc_autherr_tooweak     cpu_to_be32(RPC_AUTH_TOOWEAK)
115 #define rpcsec_gsserr_credproblem       cpu_to_be32(RPCSEC_GSS_CREDPROBLEM)
116 #define rpcsec_gsserr_ctxproblem        cpu_to_be32(RPCSEC_GSS_CTXPROBLEM)
117 
118 /*
119  * Miscellaneous XDR helper functions
120  */
121 __be32 *xdr_encode_opaque_fixed(__be32 *p, const void *ptr, unsigned int len);
122 __be32 *xdr_encode_opaque(__be32 *p, const void *ptr, unsigned int len);
123 __be32 *xdr_encode_string(__be32 *p, const char *s);
124 __be32 *xdr_decode_string_inplace(__be32 *p, char **sp, unsigned int *lenp,
125                         unsigned int maxlen);
126 __be32 *xdr_encode_netobj(__be32 *p, const struct xdr_netobj *);
127 __be32 *xdr_decode_netobj(__be32 *p, struct xdr_netobj *);
128 
129 void    xdr_inline_pages(struct xdr_buf *, unsigned int,
130                          struct page **, unsigned int, unsigned int);
131 void    xdr_terminate_string(struct xdr_buf *, const u32);
132 size_t  xdr_buf_pagecount(struct xdr_buf *buf);
133 int     xdr_alloc_bvec(struct xdr_buf *buf, gfp_t gfp);
134 void    xdr_free_bvec(struct xdr_buf *buf);
135 
136 static inline __be32 *xdr_encode_array(__be32 *p, const void *s, unsigned int len)
137 {
138         return xdr_encode_opaque(p, s, len);
139 }
140 
141 /*
142  * Decode 64bit quantities (NFSv3 support)
143  */
144 static inline __be32 *
145 xdr_encode_hyper(__be32 *p, __u64 val)
146 {
147         put_unaligned_be64(val, p);
148         return p + 2;
149 }
150 
151 static inline __be32 *
152 xdr_decode_hyper(__be32 *p, __u64 *valp)
153 {
154         *valp = get_unaligned_be64(p);
155         return p + 2;
156 }
157 
158 static inline __be32 *
159 xdr_decode_opaque_fixed(__be32 *p, void *ptr, unsigned int len)
160 {
161         memcpy(ptr, p, len);
162         return p + XDR_QUADLEN(len);
163 }
164 
165 static inline void xdr_netobj_dup(struct xdr_netobj *dst,
166                                   struct xdr_netobj *src, gfp_t gfp_mask)
167 {
168         dst->data = kmemdup(src->data, src->len, gfp_mask);
169         dst->len = src->len;
170 }
171 
172 /*
173  * Adjust kvec to reflect end of xdr'ed data (RPC client XDR)
174  */
175 static inline int
176 xdr_adjust_iovec(struct kvec *iov, __be32 *p)
177 {
178         return iov->iov_len = ((u8 *) p - (u8 *) iov->iov_base);
179 }
180 
181 /*
182  * XDR buffer helper functions
183  */
184 extern void xdr_shift_buf(struct xdr_buf *, size_t);
185 extern void xdr_buf_from_iov(struct kvec *, struct xdr_buf *);
186 extern int xdr_buf_subsegment(struct xdr_buf *, struct xdr_buf *, unsigned int, unsigned int);
187 extern void xdr_buf_trim(struct xdr_buf *, unsigned int);
188 extern int xdr_buf_read_mic(struct xdr_buf *, struct xdr_netobj *, unsigned int);
189 extern int read_bytes_from_xdr_buf(struct xdr_buf *, unsigned int, void *, unsigned int);
190 extern int write_bytes_to_xdr_buf(struct xdr_buf *, unsigned int, void *, unsigned int);
191 
192 /*
193  * Helper structure for copying from an sk_buff.
194  */
195 struct xdr_skb_reader {
196         struct sk_buff  *skb;
197         unsigned int    offset;
198         size_t          count;
199         __wsum          csum;
200 };
201 
202 typedef size_t (*xdr_skb_read_actor)(struct xdr_skb_reader *desc, void *to, size_t len);
203 
204 extern int csum_partial_copy_to_xdr(struct xdr_buf *, struct sk_buff *);
205 
206 extern int xdr_encode_word(struct xdr_buf *, unsigned int, u32);
207 extern int xdr_decode_word(struct xdr_buf *, unsigned int, u32 *);
208 
209 struct xdr_array2_desc;
210 typedef int (*xdr_xcode_elem_t)(struct xdr_array2_desc *desc, void *elem);
211 struct xdr_array2_desc {
212         unsigned int elem_size;
213         unsigned int array_len;
214         unsigned int array_maxlen;
215         xdr_xcode_elem_t xcode;
216 };
217 
218 extern int xdr_decode_array2(struct xdr_buf *buf, unsigned int base,
219                              struct xdr_array2_desc *desc);
220 extern int xdr_encode_array2(struct xdr_buf *buf, unsigned int base,
221                              struct xdr_array2_desc *desc);
222 extern void _copy_from_pages(char *p, struct page **pages, size_t pgbase,
223                              size_t len);
224 
225 /*
226  * Provide some simple tools for XDR buffer overflow-checking etc.
227  */
228 struct xdr_stream {
229         __be32 *p;              /* start of available buffer */
230         struct xdr_buf *buf;    /* XDR buffer to read/write */
231 
232         __be32 *end;            /* end of available buffer space */
233         struct kvec *iov;       /* pointer to the current kvec */
234         struct kvec scratch;    /* Scratch buffer */
235         struct page **page_ptr; /* pointer to the current page */
236         unsigned int nwords;    /* Remaining decode buffer length */
237 
238         struct rpc_rqst *rqst;  /* For debugging */
239 };
240 
241 /*
242  * These are the xdr_stream style generic XDR encode and decode functions.
243  */
244 typedef void    (*kxdreproc_t)(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
245                 const void *obj);
246 typedef int     (*kxdrdproc_t)(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
247                 void *obj);
248 
249 extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf,
250                             __be32 *p, struct rpc_rqst *rqst);
251 extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes);
252 extern void xdr_commit_encode(struct xdr_stream *xdr);
253 extern void xdr_truncate_encode(struct xdr_stream *xdr, size_t len);
254 extern int xdr_restrict_buflen(struct xdr_stream *xdr, int newbuflen);
255 extern void xdr_write_pages(struct xdr_stream *xdr, struct page **pages,
256                 unsigned int base, unsigned int len);
257 extern unsigned int xdr_stream_pos(const struct xdr_stream *xdr);
258 extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf,
259                             __be32 *p, struct rpc_rqst *rqst);
260 extern void xdr_init_decode_pages(struct xdr_stream *xdr, struct xdr_buf *buf,
261                 struct page **pages, unsigned int len);
262 extern void xdr_set_scratch_buffer(struct xdr_stream *xdr, void *buf, size_t buflen);
263 extern __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes);
264 extern unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len);
265 extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len);
266 extern int xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, int (*actor)(struct scatterlist *, void *), void *data);
267 
268 /**
269  * xdr_stream_remaining - Return the number of bytes remaining in the stream
270  * @xdr: pointer to struct xdr_stream
271  *
272  * Return value:
273  *   Number of bytes remaining in @xdr before xdr->end
274  */
275 static inline size_t
276 xdr_stream_remaining(const struct xdr_stream *xdr)
277 {
278         return xdr->nwords << 2;
279 }
280 
281 ssize_t xdr_stream_decode_opaque(struct xdr_stream *xdr, void *ptr,
282                 size_t size);
283 ssize_t xdr_stream_decode_opaque_dup(struct xdr_stream *xdr, void **ptr,
284                 size_t maxlen, gfp_t gfp_flags);
285 ssize_t xdr_stream_decode_string(struct xdr_stream *xdr, char *str,
286                 size_t size);
287 ssize_t xdr_stream_decode_string_dup(struct xdr_stream *xdr, char **str,
288                 size_t maxlen, gfp_t gfp_flags);
289 /**
290  * xdr_align_size - Calculate padded size of an object
291  * @n: Size of an object being XDR encoded (in bytes)
292  *
293  * Return value:
294  *   Size (in bytes) of the object including xdr padding
295  */
296 static inline size_t
297 xdr_align_size(size_t n)
298 {
299         const size_t mask = sizeof(__u32) - 1;
300 
301         return (n + mask) & ~mask;
302 }
303 
304 /**
305  * xdr_stream_encode_u32 - Encode a 32-bit integer
306  * @xdr: pointer to xdr_stream
307  * @n: integer to encode
308  *
309  * Return values:
310  *   On success, returns length in bytes of XDR buffer consumed
311  *   %-EMSGSIZE on XDR buffer overflow
312  */
313 static inline ssize_t
314 xdr_stream_encode_u32(struct xdr_stream *xdr, __u32 n)
315 {
316         const size_t len = sizeof(n);
317         __be32 *p = xdr_reserve_space(xdr, len);
318 
319         if (unlikely(!p))
320                 return -EMSGSIZE;
321         *p = cpu_to_be32(n);
322         return len;
323 }
324 
325 /**
326  * xdr_stream_encode_u64 - Encode a 64-bit integer
327  * @xdr: pointer to xdr_stream
328  * @n: 64-bit integer to encode
329  *
330  * Return values:
331  *   On success, returns length in bytes of XDR buffer consumed
332  *   %-EMSGSIZE on XDR buffer overflow
333  */
334 static inline ssize_t
335 xdr_stream_encode_u64(struct xdr_stream *xdr, __u64 n)
336 {
337         const size_t len = sizeof(n);
338         __be32 *p = xdr_reserve_space(xdr, len);
339 
340         if (unlikely(!p))
341                 return -EMSGSIZE;
342         xdr_encode_hyper(p, n);
343         return len;
344 }
345 
346 /**
347  * xdr_stream_encode_opaque_inline - Encode opaque xdr data
348  * @xdr: pointer to xdr_stream
349  * @ptr: pointer to void pointer
350  * @len: size of object
351  *
352  * Return values:
353  *   On success, returns length in bytes of XDR buffer consumed
354  *   %-EMSGSIZE on XDR buffer overflow
355  */
356 static inline ssize_t
357 xdr_stream_encode_opaque_inline(struct xdr_stream *xdr, void **ptr, size_t len)
358 {
359         size_t count = sizeof(__u32) + xdr_align_size(len);
360         __be32 *p = xdr_reserve_space(xdr, count);
361 
362         if (unlikely(!p)) {
363                 *ptr = NULL;
364                 return -EMSGSIZE;
365         }
366         xdr_encode_opaque(p, NULL, len);
367         *ptr = ++p;
368         return count;
369 }
370 
371 /**
372  * xdr_stream_encode_opaque_fixed - Encode fixed length opaque xdr data
373  * @xdr: pointer to xdr_stream
374  * @ptr: pointer to opaque data object
375  * @len: size of object pointed to by @ptr
376  *
377  * Return values:
378  *   On success, returns length in bytes of XDR buffer consumed
379  *   %-EMSGSIZE on XDR buffer overflow
380  */
381 static inline ssize_t
382 xdr_stream_encode_opaque_fixed(struct xdr_stream *xdr, const void *ptr, size_t len)
383 {
384         __be32 *p = xdr_reserve_space(xdr, len);
385 
386         if (unlikely(!p))
387                 return -EMSGSIZE;
388         xdr_encode_opaque_fixed(p, ptr, len);
389         return xdr_align_size(len);
390 }
391 
392 /**
393  * xdr_stream_encode_opaque - Encode variable length opaque xdr data
394  * @xdr: pointer to xdr_stream
395  * @ptr: pointer to opaque data object
396  * @len: size of object pointed to by @ptr
397  *
398  * Return values:
399  *   On success, returns length in bytes of XDR buffer consumed
400  *   %-EMSGSIZE on XDR buffer overflow
401  */
402 static inline ssize_t
403 xdr_stream_encode_opaque(struct xdr_stream *xdr, const void *ptr, size_t len)
404 {
405         size_t count = sizeof(__u32) + xdr_align_size(len);
406         __be32 *p = xdr_reserve_space(xdr, count);
407 
408         if (unlikely(!p))
409                 return -EMSGSIZE;
410         xdr_encode_opaque(p, ptr, len);
411         return count;
412 }
413 
414 /**
415  * xdr_stream_encode_uint32_array - Encode variable length array of integers
416  * @xdr: pointer to xdr_stream
417  * @array: array of integers
418  * @array_size: number of elements in @array
419  *
420  * Return values:
421  *   On success, returns length in bytes of XDR buffer consumed
422  *   %-EMSGSIZE on XDR buffer overflow
423  */
424 static inline ssize_t
425 xdr_stream_encode_uint32_array(struct xdr_stream *xdr,
426                 const __u32 *array, size_t array_size)
427 {
428         ssize_t ret = (array_size+1) * sizeof(__u32);
429         __be32 *p = xdr_reserve_space(xdr, ret);
430 
431         if (unlikely(!p))
432                 return -EMSGSIZE;
433         *p++ = cpu_to_be32(array_size);
434         for (; array_size > 0; p++, array++, array_size--)
435                 *p = cpu_to_be32p(array);
436         return ret;
437 }
438 
439 /**
440  * xdr_stream_decode_u32 - Decode a 32-bit integer
441  * @xdr: pointer to xdr_stream
442  * @ptr: location to store integer
443  *
444  * Return values:
445  *   %0 on success
446  *   %-EBADMSG on XDR buffer overflow
447  */
448 static inline ssize_t
449 xdr_stream_decode_u32(struct xdr_stream *xdr, __u32 *ptr)
450 {
451         const size_t count = sizeof(*ptr);
452         __be32 *p = xdr_inline_decode(xdr, count);
453 
454         if (unlikely(!p))
455                 return -EBADMSG;
456         *ptr = be32_to_cpup(p);
457         return 0;
458 }
459 
460 /**
461  * xdr_stream_decode_opaque_fixed - Decode fixed length opaque xdr data
462  * @xdr: pointer to xdr_stream
463  * @ptr: location to store data
464  * @len: size of buffer pointed to by @ptr
465  *
466  * Return values:
467  *   On success, returns size of object stored in @ptr
468  *   %-EBADMSG on XDR buffer overflow
469  */
470 static inline ssize_t
471 xdr_stream_decode_opaque_fixed(struct xdr_stream *xdr, void *ptr, size_t len)
472 {
473         __be32 *p = xdr_inline_decode(xdr, len);
474 
475         if (unlikely(!p))
476                 return -EBADMSG;
477         xdr_decode_opaque_fixed(p, ptr, len);
478         return len;
479 }
480 
481 /**
482  * xdr_stream_decode_opaque_inline - Decode variable length opaque xdr data
483  * @xdr: pointer to xdr_stream
484  * @ptr: location to store pointer to opaque data
485  * @maxlen: maximum acceptable object size
486  *
487  * Note: the pointer stored in @ptr cannot be assumed valid after the XDR
488  * buffer has been destroyed, or even after calling xdr_inline_decode()
489  * on @xdr. It is therefore expected that the object it points to should
490  * be processed immediately.
491  *
492  * Return values:
493  *   On success, returns size of object stored in *@ptr
494  *   %-EBADMSG on XDR buffer overflow
495  *   %-EMSGSIZE if the size of the object would exceed @maxlen
496  */
497 static inline ssize_t
498 xdr_stream_decode_opaque_inline(struct xdr_stream *xdr, void **ptr, size_t maxlen)
499 {
500         __be32 *p;
501         __u32 len;
502 
503         *ptr = NULL;
504         if (unlikely(xdr_stream_decode_u32(xdr, &len) < 0))
505                 return -EBADMSG;
506         if (len != 0) {
507                 p = xdr_inline_decode(xdr, len);
508                 if (unlikely(!p))
509                         return -EBADMSG;
510                 if (unlikely(len > maxlen))
511                         return -EMSGSIZE;
512                 *ptr = p;
513         }
514         return len;
515 }
516 
517 /**
518  * xdr_stream_decode_uint32_array - Decode variable length array of integers
519  * @xdr: pointer to xdr_stream
520  * @array: location to store the integer array or NULL
521  * @array_size: number of elements to store
522  *
523  * Return values:
524  *   On success, returns number of elements stored in @array
525  *   %-EBADMSG on XDR buffer overflow
526  *   %-EMSGSIZE if the size of the array exceeds @array_size
527  */
528 static inline ssize_t
529 xdr_stream_decode_uint32_array(struct xdr_stream *xdr,
530                 __u32 *array, size_t array_size)
531 {
532         __be32 *p;
533         __u32 len;
534         ssize_t retval;
535 
536         if (unlikely(xdr_stream_decode_u32(xdr, &len) < 0))
537                 return -EBADMSG;
538         p = xdr_inline_decode(xdr, len * sizeof(*p));
539         if (unlikely(!p))
540                 return -EBADMSG;
541         if (array == NULL)
542                 return len;
543         if (len <= array_size) {
544                 if (len < array_size)
545                         memset(array+len, 0, (array_size-len)*sizeof(*array));
546                 array_size = len;
547                 retval = len;
548         } else
549                 retval = -EMSGSIZE;
550         for (; array_size > 0; p++, array++, array_size--)
551                 *array = be32_to_cpup(p);
552         return retval;
553 }
554 
555 #endif /* _SUNRPC_XDR_H_ */
556 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp