From 6b93021bbf87092def5f83c377644234d4bfa97a Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 18 Nov 2012 05:01:34 +1100 Subject: [PATCH] Use our own xdr_int64() for all 64 bit types. Oh dear. It is really difficult for rpc and tirpc implementors to get 64 bit types right. Sigh. I am tired of fighting broken ti-rpc libraries under linux and others that do random corruption on xdr_u_quad_t and friends so lets just override that shit and replace it with our own, non-broken, implementation of a 64 bit xdr accessor. --- examples/Makefile.am | 2 +- nfs/Makefile.am | 30 +++++++++++++++++++++++++++++- nfs/nfs.x | 4 ++-- nlm/Makefile.am | 2 +- nlm/nlm.x | 9 +++++---- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/examples/Makefile.am b/examples/Makefile.am index 314807b..878ac1a 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -8,7 +8,7 @@ AM_CPPFLAGS = \ -I../portmap \ "-D_U_=__attribute__((unused))" -AM_LDFLAGS = ../lib/.libs/libnfs.la +AM_LDFLAGS = ../lib/.libs/libnfs.la -lpopt nfsclient_async_SOURCES = nfsclient-async.c diff --git a/nfs/Makefile.am b/nfs/Makefile.am index 5052369..51b8d92 100644 --- a/nfs/Makefile.am +++ b/nfs/Makefile.am @@ -15,6 +15,34 @@ $(nfs_GENERATED) : nfs-stamp nfs-stamp : nfs.x rm -f $(nfs_GENERATED) rpcgen -h @RPCGENFLAGS@ $< > libnfs-raw-nfs.h - rpcgen -c @RPCGENFLAGS@ $< | sed -e "s/#include \".*nfs.h\"/#include \"libnfs-raw-nfs.h\"/" > libnfs-raw-nfs.c + rpcgen -c @RPCGENFLAGS@ $< | sed -e "s/#include \".*nfs.h\"/#include \"libnfs-raw-nfs.h\"/" -e "s/^xdr_uint64/static xdr_uint64_broken/" > libnfs-raw-nfs.c + echo "" >> libnfs-raw-nfs.c + echo "xdr_uint64 (XDR *xdrs, uint64 *objp)" >> libnfs-raw-nfs.c + echo "{" >> libnfs-raw-nfs.c + echo " uint32_t i;" >> libnfs-raw-nfs.c + echo "" >> libnfs-raw-nfs.c + echo " switch (xdrs->x_op) {" >> libnfs-raw-nfs.c + echo " case XDR_DECODE:" >> libnfs-raw-nfs.c + echo " if (!xdr_u_int (xdrs, &i))" >> libnfs-raw-nfs.c + echo " return FALSE;" >> libnfs-raw-nfs.c + echo " *objp = i;" >> libnfs-raw-nfs.c + echo " *objp <<= 32;" >> libnfs-raw-nfs.c + echo "" >> libnfs-raw-nfs.c + echo " if (!xdr_u_int (xdrs, &i))" >> libnfs-raw-nfs.c + echo " return FALSE;" >> libnfs-raw-nfs.c + echo " *objp |= i;" >> libnfs-raw-nfs.c + echo "" >> libnfs-raw-nfs.c + echo " return TRUE;" >> libnfs-raw-nfs.c + echo " case XDR_ENCODE:" >> libnfs-raw-nfs.c + echo " i = ((*objp) >> 32) & 0xffffffff;" >> libnfs-raw-nfs.c + echo " if (!xdr_u_int (xdrs, &i))" >> libnfs-raw-nfs.c + echo " return FALSE;" >> libnfs-raw-nfs.c + echo "" >> libnfs-raw-nfs.c + echo " i = ((*objp) ) & 0xffffffff;" >> libnfs-raw-nfs.c + echo " if (!xdr_u_int (xdrs, &i))" >> libnfs-raw-nfs.c + echo " return FALSE;" >> libnfs-raw-nfs.c + echo " return TRUE;" >> libnfs-raw-nfs.c + echo " }" >> libnfs-raw-nfs.c + echo "}" >> libnfs-raw-nfs.c touch nfs-stamp diff --git a/nfs/nfs.x b/nfs/nfs.x index c259aa6..6e2d7a4 100644 --- a/nfs/nfs.x +++ b/nfs/nfs.x @@ -7,8 +7,7 @@ const NFS3_COOKIEVERFSIZE = 8; typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE]; - -/*unsigned hyper can be overridden by giving rpcgen -DU_INT64_PLATTFORM_TYPE="foo" - for plattforms +/*unsigned hyper can be overridden by giving rpcgen -DU_INT64_PLATTFORM_TYPE=" where rpcgen doesn't know anything about hyper default to unsigned hyper as of rfc 1813 */ #ifndef U_INT64_PLATTFORM_TYPE @@ -16,6 +15,7 @@ typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE]; #endif/*U_INT64_PLATTFORM_TYPE*/ typedef U_INT64_PLATTFORM_TYPE uint64; + typedef uint64 cookie3; struct nfs_fh3 { diff --git a/nlm/Makefile.am b/nlm/Makefile.am index 7ec82da..0873dda 100644 --- a/nlm/Makefile.am +++ b/nlm/Makefile.am @@ -15,6 +15,6 @@ $(nlm_GENERATED) : nlm-stamp nlm-stamp : nlm.x rm -f $(nlm_GENERATED) rpcgen -h @RPCGENFLAGS@ $< > libnfs-raw-nlm.h - rpcgen -c @RPCGENFLAGS@ $< | sed -e "s/#include \".*nlm.h\"/#include \"libnfs-raw-nlm.h\"/" > libnfs-raw-nlm.c + rpcgen -c @RPCGENFLAGS@ $< | sed -e "s/#include \".*nlm.h\"/#include \"libnfs-raw-nlm.h\"/" -e "s/^xdr_uint64/static xdr_uint64_broken/" > libnfs-raw-nlm.c touch nlm-stamp diff --git a/nlm/nlm.x b/nlm/nlm.x index 4ca8621..8ec6614 100644 --- a/nlm/nlm.x +++ b/nlm/nlm.x @@ -1,5 +1,6 @@ /* based on rfc1813 and wireshark */ +typedef unsigned hyper uint64; struct nlm_fh4 { opaque data<>; @@ -28,8 +29,8 @@ struct nlm4_holder { bool exclusive; unsigned int svid; nlm4_oh oh; - unsigned hyper l_offset; - unsigned hyper l_len; + uint64 l_offset; + uint64 l_len; }; const NLM_MAXNAME = 256; @@ -38,8 +39,8 @@ struct nlm4_lock { struct nlm_fh4 fh; nlm4_oh oh; unsigned int svid; - unsigned hyper l_offset; - unsigned hyper l_len; + uint64 l_offset; + uint64 l_len; }; struct nlm4_share { -- 2.34.1