Re: [PATCH v1 14/42] NFSD: Update the NFSv3 PATHCONF3res encoder to use struct xdr_stream

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On Mar 3, 2021, at 2:13 AM, Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:
> 
> On Mon, Mar 01, 2021 at 10:16:43AM -0500, Chuck Lever wrote:
>> +	*p++ = resp->p_no_trunc ? xdr_one : xdr_zero;
>> +	*p++ = resp->p_chown_restricted ? xdr_one : xdr_zero;
>> +	*p++ = resp->p_case_insensitive ? xdr_one : xdr_zero;
>> +	*p = resp->p_case_preserving ? xdr_one : xdr_zero;
> 
> Wouldn't a little xdr_encode_bool helper for this common pattern be
> nice?

Sure. In include/linux/sunrpc/xdr.h, I've now added:

/**
 * xdr_encode_bool - Encode a boolean item
 * @p: address in a buffer into which to encode
 * @n: boolean value to encode
 *
 * Return value:
 *   Address of item following the encoded boolean
 */
static inline __be32 *xdr_encode_bool(__be32 *p, u32 n)
{
       *p = n ? xdr_one : xdr_zero;
       return p++;
}

and xdr_stream_encode_bool() has been changed to use this helper.

In fs/nfsd/nfs3xdr.c, the PATHCONF result encoder now uses
xdr_encode_bool() to encode the four boolean fields in struct
PATHCONF3resok.

--
Chuck Lever







[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux