Mercurial > nomad > old-fuse
changeset 109:4db5838ca7d3
common: allow XDR encoding of object IDs and object handles
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Signed-off-by: Holly Sipek <holly.sipek@gmail.com>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sat, 17 Oct 2015 16:37:58 -0400 |
parents | 869d71b4e5da |
children | c5281836a1d1 |
files | src/common/include/nomad/types.h src/common/oid.c |
diffstat | 2 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/common/include/nomad/types.h Sat Oct 17 16:37:52 2015 -0400 +++ b/src/common/include/nomad/types.h Sat Oct 17 16:37:58 2015 -0400 @@ -27,6 +27,7 @@ #include <stdbool.h> #include <limits.h> #include <sys/types.h> +#include <rpc/rpc.h> #include <nomad/attr.h> #include <nomad/vclock.h> @@ -63,6 +64,9 @@ extern void noid_set(struct noid *n1, uint32_t ds, uint64_t uniq); extern int noid_cmp(const struct noid *n1, const struct noid *n2); +extern bool_t xdr_noid(XDR *xdrs, struct noid *oid); + +extern bool_t xdr_nobjhndl(XDR *xdrs, struct nobjhndl *hndl); extern void nuuid_clear(struct nuuid *uuid); extern int nuuid_compare(const struct nuuid *u1, const struct nuuid *u2);
--- a/src/common/oid.c Sat Oct 17 16:37:52 2015 -0400 +++ b/src/common/oid.c Sat Oct 17 16:37:58 2015 -0400 @@ -43,3 +43,21 @@ oid->uniq = uniq; oid->_reserved = 0; } + +bool_t xdr_noid(XDR *xdrs, struct noid *oid) +{ + if (!xdr_uint32_t(xdrs, &oid->ds)) + return FALSE; + if (!xdr_uint64_t(xdrs, &oid->uniq)) + return FALSE; + return TRUE; +} + +bool_t xdr_nobjhndl(XDR *xdrs, struct nobjhndl *hndl) +{ + if (!xdr_noid(xdrs, &hndl->oid)) + return FALSE; + if (!xdr_nvclock(xdrs, hndl->clock)) + return FALSE; + return TRUE; +}