Permalink
Browse files

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.
  • Loading branch information...
1 parent bbed37c commit 6b93021bbf87092def5f83c377644234d4bfa97a @sahlberg committed Nov 17, 2012
Showing with 38 additions and 9 deletions.
  1. +1 −1 examples/Makefile.am
  2. +29 −1 nfs/Makefile.am
  3. +2 −2 nfs/nfs.x
  4. +1 −1 nlm/Makefile.am
  5. +5 −4 nlm/nlm.x
View
@@ -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
View
@@ -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
View
@@ -7,15 +7,15 @@ 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
#define U_INT64_PLATTFORM_TYPE unsigned hyper
#endif/*U_INT64_PLATTFORM_TYPE*/
typedef U_INT64_PLATTFORM_TYPE uint64;
+
typedef uint64 cookie3;
struct nfs_fh3 {
View
@@ -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
View
@@ -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 {

0 comments on commit 6b93021

Please sign in to comment.