static int nvshm_rpc_utils_encode_args(const struct nvshm_rpc_datum_in *data, u32 number, u32 *writer) { u32 n; for (n = 0; n < number; ++n) { const struct nvshm_rpc_datum_in *datum = &data[n]; if ((datum->type & TYPE_ARRAY_FLAG) == 0) { switch (datum->type) { case TYPE_SINT: *writer++ = cpu_to_be32(datum->d.sint_data); break; case TYPE_UINT: *writer++ = cpu_to_be32(datum->d.uint_data); break; case TYPE_STRING: writer = xdr_encode_opaque(writer, datum->d.string_data, strlen(datum->d.string_data) + 1); break; case TYPE_BLOB: writer = xdr_encode_opaque(writer, datum->d.blob_data, datum->length); break; default: pr_err("unknown RPC type %d\n", datum->type); return -EINVAL; } } else { enum nvshm_rpc_datumtype type; type = datum->type & ~TYPE_ARRAY_FLAG; *writer++ = cpu_to_be32(datum->length); if ((type == TYPE_SINT) || (type == TYPE_UINT)) { const u32 *a; u32 d; a = (const u32 *) datum->d.blob_data; for (d = 0; d < datum->length; ++d, ++a) *writer++ = cpu_to_be32(*a); } else if (type == TYPE_STRING) { const char * const *a; u32 d; a = (const char * const *) datum->d.blob_data; for (d = 0; d < datum->length; ++d, ++a) writer = xdr_encode_opaque(writer, *a, strlen(*a) + 1); } else { pr_err("invalid RPC type for array %d\n", type); return -EINVAL; } } } return 0; }
static void encode_nfs_fh3(struct xdr_stream *xdr, const struct nfs_fh *fh) { __be32 *p; BUG_ON(fh->size > NFS3_FHSIZE); p = xdr_reserve_space(xdr, 4 + fh->size); xdr_encode_opaque(p, fh->data, fh->size); }
/* * nfs_fh4 * * typedef opaque nfs_fh4<NFS4_FHSIZE>; */ static void encode_nfs_fh4(struct xdr_stream *xdr, const struct knfsd_fh *fh) { u32 length = fh->fh_size; __be32 *p; BUG_ON(length > NFS4_FHSIZE); p = xdr_reserve_space(xdr, 4 + length); xdr_encode_opaque(p, &fh->fh_base, length); }
/* * typedef opaque netobj<MAXNETOBJ_SZ> */ static void encode_netobj(struct xdr_stream *xdr, const u8 *data, const unsigned int length) { __be32 *p; BUG_ON(length > XDR_MAX_NETOBJ); p = xdr_reserve_space(xdr, 4 + length); xdr_encode_opaque(p, data, length); }
/* * 2.3.7. filename * * typedef string filename<MAXNAMLEN>; */ static void encode_filename(struct xdr_stream *xdr, const char *name, u32 length) { __be32 *p; BUG_ON(length > NFS2_MAXNAMLEN); p = xdr_reserve_space(xdr, 4 + length); xdr_encode_opaque(p, name, length); }
static unsigned encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) { uint32_t *p; p = xdr_reserve_space(xdr, 4 + len); if (unlikely(p == NULL)) return htonl(NFS4ERR_RESOURCE); xdr_encode_opaque(p, str, len); return 0; }
/* * string caller_name<LM_MAXSTRLEN>; */ static void encode_caller_name(struct xdr_stream *xdr, const char *name) { /* NB: client-side does not set lock->len */ u32 length = strlen(name); __be32 *p; BUG_ON(length > NLM_MAXSTRLEN); p = xdr_reserve_space(xdr, 4 + length); xdr_encode_opaque(p, name, length); }
static void encode_caller_name(struct xdr_stream *xdr, const char *name) { u32 length = strlen(name); __be32 *p; BUG_ON(length > NLM_MAXSTRLEN); p = xdr_reserve_space(xdr, 4 + length); xdr_encode_opaque(p, name, length); }
static int gssx_enc_buffer(struct xdr_stream *xdr, const gssx_buffer *buf) { __be32 *p; p = xdr_reserve_space(xdr, sizeof(u32) + buf->len); if (!p) return -ENOSPC; xdr_encode_opaque(p, buf->data, buf->len); return 0; }