From bce63d849cdc3870d3e99fe8a968924a836aa63e Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sat, 16 Aug 2014 14:51:53 -0700 Subject: [PATCH] types: remove the [u_]quad type and replace with [u]int64 All current platforms have a quad type that maps to a 64bit scalar. But there are platforms where quad maps to a 64bit non-scalar. Replace quad with int64 in the protocol definitions and the ZDR layer so that these fields will map to a 64 bit scalar also on those platforms where quad can not be used. Signed-off-by: Ronnie Sahlberg --- include/nfsc/libnfs-zdr.h | 8 ++++---- lib/libnfs-zdr.c | 6 +++--- nfs/Makefile.am | 2 +- nfs/libnfs-raw-nfs.c | 10 +++++----- nfs/libnfs-raw-nfs.h | 19 ++++++------------- nfs/nfs.x | 10 +++++----- nlm/libnfs-raw-nlm.c | 8 ++++---- nlm/libnfs-raw-nlm.h | 8 ++++---- nlm/nlm.x | 8 ++++---- 9 files changed, 36 insertions(+), 43 deletions(-) diff --git a/include/nfsc/libnfs-zdr.h b/include/nfsc/libnfs-zdr.h index 6b2ea91..aa9f1d8 100644 --- a/include/nfsc/libnfs-zdr.h +++ b/include/nfsc/libnfs-zdr.h @@ -230,11 +230,11 @@ bool_t libnfs_zdr_u_int(ZDR *zdrs, uint32_t *u); #define zdr_int libnfs_zdr_int bool_t libnfs_zdr_int(ZDR *zdrs, int32_t *i); -#define zdr_u_quad_t libnfs_zdr_u_quad_t -bool_t libnfs_zdr_u_quad_t(ZDR *zdrs, uint64_t *u); +#define zdr_uint64_t libnfs_zdr_uint64_t +bool_t libnfs_zdr_uint64_t(ZDR *zdrs, uint64_t *u); -#define zdr_quad_t libnfs_zdr_quad_t -bool_t libnfs_zdr_quad_t(ZDR *zdrs, int64_t *i); +#define zdr_int64_t libnfs_zdr_int64_t +bool_t libnfs_zdr_int64_t(ZDR *zdrs, int64_t *i); #define zdr_enum libnfs_zdr_enum bool_t libnfs_zdr_enum(ZDR *zdrs, enum_t *e); diff --git a/lib/libnfs-zdr.c b/lib/libnfs-zdr.c index 90abe26..921ec5f 100644 --- a/lib/libnfs-zdr.c +++ b/lib/libnfs-zdr.c @@ -118,7 +118,7 @@ bool_t libnfs_zdr_int(ZDR *zdrs, int32_t *i) return libnfs_zdr_u_int(zdrs, (uint32_t *)i); } -bool_t libnfs_zdr_u_quad_t(ZDR *zdrs, uint64_t *u) +bool_t libnfs_zdr_uint64_t(ZDR *zdrs, uint64_t *u) { if (zdrs->pos + 8 > zdrs->size) { return FALSE; @@ -145,9 +145,9 @@ bool_t libnfs_zdr_u_quad_t(ZDR *zdrs, uint64_t *u) return FALSE; } -bool_t libnfs_zdr_quad_t(ZDR *zdrs, int64_t *i) +bool_t libnfs_zdr_int64_t(ZDR *zdrs, int64_t *i) { - return libnfs_zdr_u_quad_t(zdrs, (uint64_t *)i); + return libnfs_zdr_uint64_t(zdrs, (uint64_t *)i); } bool_t libnfs_zdr_bytes(ZDR *zdrs, char **bufp, uint32_t *size, uint32_t maxsize) diff --git a/nfs/Makefile.am b/nfs/Makefile.am index c155372..de62dce 100644 --- a/nfs/Makefile.am +++ b/nfs/Makefile.am @@ -19,6 +19,6 @@ nfs-stamp : nfs.x compile_rpc: cat nfs.x | head -29 >libnfs-raw-nfs.h - rpcgen -h nfs.x | sed -e "s/#include /#include /" -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" -e "s/#define _NFS_H_RPCGEN/#define _NFS_H_RPCGEN\n#include /g" -e "s/#define NFS3_COOKIEVERFSIZE 8/#define NFS3_COOKIEVERFSIZE 8\n\n#if defined(ANDROID)\ntypedef long long int quad_t;\ntypedef long long unsigned u_quad_t;\n#endif\n#if defined(WIN32)\ntypedef long long int quad_t;\ntypedef long long unsigned u_quad_t;\n#endif/g" -e "s/ CLIENT / void /g" -e "s/SVCXPRT /void /g" -e "s/bool_t/uint32_t/g" >> libnfs-raw-nfs.h + rpcgen -h nfs.x | sed -e "s/#include /#include /" -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" -e "s/#define _NFS_H_RPCGEN/#define _NFS_H_RPCGEN\n#include /g" -e "s/#define NFS3_COOKIEVERFSIZE 8/#define NFS3_COOKIEVERFSIZE 8\n\n/g" -e "s/ CLIENT / void /g" -e "s/SVCXPRT /void /g" -e "s/bool_t/uint32_t/g" >> libnfs-raw-nfs.h cat nfs.x | head -29 >libnfs-raw-nfs.c rpcgen -c nfs.x | sed -e "s/#include \".*nfs.h\"/#include \"libnfs-xdr.h\"\n#include \"libnfs-raw-nfs.h\"/" -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" -e "s/register int32_t \*buf;/register int32_t *buf;\n buf = NULL;/" -e "s/bool_t/uint32_t/g" >> libnfs-raw-nfs.c diff --git a/nfs/libnfs-raw-nfs.c b/nfs/libnfs-raw-nfs.c index 925048a..6a02346 100644 --- a/nfs/libnfs-raw-nfs.c +++ b/nfs/libnfs-raw-nfs.c @@ -52,7 +52,7 @@ zdr_cookie3 (ZDR *zdrs, cookie3 *objp) register int32_t *buf; buf = NULL; - if (!zdr_u_quad_t (zdrs, objp)) + if (!zdr_uint64_t (zdrs, objp)) return FALSE; return TRUE; } @@ -142,7 +142,7 @@ zdr_size3 (ZDR *zdrs, size3 *objp) register int32_t *buf; buf = NULL; - if (!zdr_u_quad_t (zdrs, objp)) + if (!zdr_uint64_t (zdrs, objp)) return FALSE; return TRUE; } @@ -153,7 +153,7 @@ zdr_fileid3 (ZDR *zdrs, fileid3 *objp) register int32_t *buf; buf = NULL; - if (!zdr_u_quad_t (zdrs, objp)) + if (!zdr_uint64_t (zdrs, objp)) return FALSE; return TRUE; } @@ -206,7 +206,7 @@ zdr_fattr3 (ZDR *zdrs, fattr3 *objp) return FALSE; if (!zdr_specdata3 (zdrs, &objp->rdev)) return FALSE; - if (!zdr_u_quad_t (zdrs, &objp->fsid)) + if (!zdr_uint64_t (zdrs, &objp->fsid)) return FALSE; if (!zdr_fileid3 (zdrs, &objp->fileid)) return FALSE; @@ -268,7 +268,7 @@ zdr_offset3 (ZDR *zdrs, offset3 *objp) register int32_t *buf; buf = NULL; - if (!zdr_u_quad_t (zdrs, objp)) + if (!zdr_uint64_t (zdrs, objp)) return FALSE; return TRUE; } diff --git a/nfs/libnfs-raw-nfs.h b/nfs/libnfs-raw-nfs.h index 835029e..a3b60f5 100644 --- a/nfs/libnfs-raw-nfs.h +++ b/nfs/libnfs-raw-nfs.h @@ -48,18 +48,11 @@ extern "C" { #define NFS3_CREATEVERFSIZE 8 #define NFS3_COOKIEVERFSIZE 8 -#if defined(ANDROID) -typedef long long int quad_t; -typedef long long unsigned u_quad_t; -#endif -#if defined(WIN32) -typedef long long int quad_t; -typedef long long unsigned u_quad_t; -#endif + typedef char cookieverf3[NFS3_COOKIEVERFSIZE]; -typedef u_quad_t cookie3; +typedef uint64_t cookie3; struct nfs_fh3 { struct { @@ -94,9 +87,9 @@ typedef u_int uid3; typedef u_int gid3; -typedef u_quad_t size3; +typedef uint64_t size3; -typedef u_quad_t fileid3; +typedef uint64_t fileid3; struct specdata3 { u_int specdata1; @@ -119,7 +112,7 @@ struct fattr3 { size3 size; size3 used; specdata3 rdev; - u_quad_t fsid; + uint64_t fsid; fileid3 fileid; nfstime3 atime; nfstime3 mtime; @@ -175,7 +168,7 @@ enum stable_how { }; typedef enum stable_how stable_how; -typedef u_quad_t offset3; +typedef uint64_t offset3; typedef u_int count3; diff --git a/nfs/nfs.x b/nfs/nfs.x index ca48c03..ab874a0 100644 --- a/nfs/nfs.x +++ b/nfs/nfs.x @@ -37,7 +37,7 @@ const NFS3_COOKIEVERFSIZE = 8; typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE]; -typedef u_quad_t cookie3; +typedef uint64_t cookie3; struct nfs_fh3 { opaque data; @@ -66,9 +66,9 @@ typedef unsigned int uid3; typedef unsigned int gid3; -typedef u_quad_t size3; +typedef uint64_t size3; -typedef u_quad_t fileid3; +typedef uint64_t fileid3; struct specdata3 { unsigned int specdata1; @@ -89,7 +89,7 @@ struct fattr3 { size3 size; size3 used; specdata3 rdev; - u_quad_t fsid; + uint64_t fsid; fileid3 fileid; nfstime3 atime; nfstime3 mtime; @@ -142,7 +142,7 @@ enum stable_how { FILE_SYNC = 2 }; -typedef u_quad_t offset3; +typedef uint64_t offset3; typedef unsigned int count3; diff --git a/nlm/libnfs-raw-nlm.c b/nlm/libnfs-raw-nlm.c index ccb2c82..40d70f6 100644 --- a/nlm/libnfs-raw-nlm.c +++ b/nlm/libnfs-raw-nlm.c @@ -91,9 +91,9 @@ zdr_nlm4_holder (ZDR *zdrs, nlm4_holder *objp) return FALSE; if (!zdr_nlm4_oh (zdrs, &objp->oh)) return FALSE; - if (!zdr_u_quad_t (zdrs, &objp->l_offset)) + if (!zdr_uint64_t (zdrs, &objp->l_offset)) return FALSE; - if (!zdr_u_quad_t (zdrs, &objp->l_len)) + if (!zdr_uint64_t (zdrs, &objp->l_len)) return FALSE; return TRUE; } @@ -112,9 +112,9 @@ zdr_nlm4_lock (ZDR *zdrs, nlm4_lock *objp) return FALSE; if (!zdr_u_int (zdrs, &objp->svid)) return FALSE; - if (!zdr_u_quad_t (zdrs, &objp->l_offset)) + if (!zdr_uint64_t (zdrs, &objp->l_offset)) return FALSE; - if (!zdr_u_quad_t (zdrs, &objp->l_len)) + if (!zdr_uint64_t (zdrs, &objp->l_len)) return FALSE; return TRUE; } diff --git a/nlm/libnfs-raw-nlm.h b/nlm/libnfs-raw-nlm.h index ce85259..53635f5 100644 --- a/nlm/libnfs-raw-nlm.h +++ b/nlm/libnfs-raw-nlm.h @@ -79,8 +79,8 @@ struct nlm4_holder { uint32_t exclusive; u_int svid; nlm4_oh oh; - u_quad_t l_offset; - u_quad_t l_len; + uint64_t l_offset; + uint64_t l_len; }; typedef struct nlm4_holder nlm4_holder; #define NLM_MAXNAME 256 @@ -90,8 +90,8 @@ struct nlm4_lock { struct nlm_fh4 fh; nlm4_oh oh; u_int svid; - u_quad_t l_offset; - u_quad_t l_len; + uint64_t l_offset; + uint64_t l_len; }; typedef struct nlm4_lock nlm4_lock; diff --git a/nlm/nlm.x b/nlm/nlm.x index 6cd39c2..072aa99 100644 --- a/nlm/nlm.x +++ b/nlm/nlm.x @@ -54,8 +54,8 @@ struct nlm4_holder { bool exclusive; unsigned int svid; nlm4_oh oh; - u_quad_t l_offset; - u_quad_t l_len; + uint64_t l_offset; + uint64_t l_len; }; const NLM_MAXNAME = 256; @@ -64,8 +64,8 @@ struct nlm4_lock { struct nlm_fh4 fh; nlm4_oh oh; unsigned int svid; - u_quad_t l_offset; - u_quad_t l_len; + uint64_t l_offset; + uint64_t l_len; }; struct nlm4_share { -- 2.34.1