]> The Tcpdump Group git mirrors - tcpdump/commitdiff
NFS: replace ino_t with u_int32_t (GH #335 pt. 1)
authorDenis Ovsienko <[email protected]>
Sat, 12 Oct 2013 09:36:02 +0000 (13:36 +0400)
committerDenis Ovsienko <[email protected]>
Sat, 12 Oct 2013 09:43:45 +0000 (13:43 +0400)
NFS file handle is an opaque server-issued sequence of bytes. Parse_fh()
function implements heuristics to decode file handles generated by some
NFS servers, among other information extracting the node (inode) number.
It decodes only 32-bit node numbers.

NFS implementations use ino_t C type to represent the node number. The
type size may vary across implementations/encodings and may be missing
during compile time.

Tcpdump used to have its own typedef for ino_t. Gisle Vanem points that
it caused a problem with MSVC v.16.00.40219.01 for 80x86, which defines
the same type in <sys/types.h>. This change fixes tcpdump code to use
u_int32_t and removes the typedef.

nfsfh.h
parsenfsfh.c
print-nfs.c
tcpdump-stdinc.h

diff --git a/nfsfh.h b/nfsfh.h
index 0bca424a2d0be6e9fd220a45b7a379756ca1205c..1d96f13e45473c45e6d9ccc1e28231e95b81f721 100644 (file)
--- a/nfsfh.h
+++ b/nfsfh.h
@@ -65,4 +65,4 @@ typedef       struct {
 #define        fsid_eq(a,b)    ((a.fsid_code == b.fsid_code) &&\
                         dev_eq(a.Fsid_dev, b.Fsid_dev))
 
-extern void Parse_fh(const unsigned char *, int, my_fsid *, ino_t *, const char **, const char **, int);
+extern void Parse_fh(const unsigned char *, int, my_fsid *, u_int32_t *, const char **, const char **, int);
index d5f877d82235cff4527a98d328a325c56b1b26f1..5ee7e68e21b377bc87e39f017c9db5f897abd290 100644 (file)
@@ -114,7 +114,7 @@ Parse_fh(fh, len, fsidp, inop, osnamep, fsnamep, ourself)
 register const unsigned char *fh;
 int len _U_;
 my_fsid *fsidp;
-ino_t *inop;
+u_int32_t *inop;
 const char **osnamep;          /* if non-NULL, return OS name here */
 const char **fsnamep;          /* if non-NULL, return server fs name here (for VMS) */
 int ourself;           /* true if file handle was generated on this host */
@@ -264,8 +264,7 @@ int ourself;                /* true if file handle was generated on this host */
            fsidp->Fsid_dev.Major = fhp[6];
            fsidp->fsid_code = 0;
 
-           temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
-           *inop = temp;
+           *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
 
            if (osnamep)
                *osnamep = "Auspex";
@@ -276,8 +275,7 @@ int ourself;                /* true if file handle was generated on this host */
            fsidp->Fsid_dev.Major = fhp[1];
            fsidp->fsid_code = 0;
 
-           temp = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
-           *inop = temp;
+           *inop = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
 
            if (osnamep)
                *osnamep = "BSD 4.4";
@@ -291,8 +289,7 @@ int ourself;                /* true if file handle was generated on this host */
            fsidp->Fsid_dev.Minor = temp & 0xFFFFF;
            fsidp->Fsid_dev.Major = (temp>>20) & 0xFFF;
 
-           temp = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
-           *inop = temp;
+           *inop = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
            if (osnamep)
                *osnamep = "OSF";
            break;
@@ -302,8 +299,7 @@ int ourself;                /* true if file handle was generated on this host */
            fsidp->Fsid_dev.Major = fhp[2];
            fsidp->fsid_code = 0;
 
-           temp = make_uint32(fhp[8], fhp[9], fhp[10], fhp[11]);
-           *inop = temp;
+           *inop = make_uint32(fhp[8], fhp[9], fhp[10], fhp[11]);
 
            if (osnamep)
                *osnamep = "IRIX4";
@@ -314,8 +310,7 @@ int ourself;                /* true if file handle was generated on this host */
            fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
            fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
 
-           temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
-           *inop = temp;
+           *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
 
            if (osnamep)
                *osnamep = "IRIX5";
@@ -337,8 +332,7 @@ int ourself;                /* true if file handle was generated on this host */
            fsidp->Fsid_dev.Major = fhp[2];
            fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
 
-           temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
-           *inop = temp;
+           *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
 
            if (osnamep)
                *osnamep = "SUNOS4";
@@ -351,8 +345,7 @@ int ourself;                /* true if file handle was generated on this host */
            fsidp->Fsid_dev.Minor = temp & 0x3FFFF;
            fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
 
-           temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
-           *inop = temp;
+           *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
 
            if (osnamep)
                *osnamep = "SUNOS5";
@@ -403,8 +396,7 @@ int ourself;                /* true if file handle was generated on this host */
            fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
            fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
 
-           temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
-           *inop = temp;
+           *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
 
            if (osnamep)
                *osnamep = "AIX32";
@@ -416,8 +408,7 @@ int ourself;                /* true if file handle was generated on this host */
            fsidp->Fsid_dev.Minor = temp;
            fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
 
-           temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
-           *inop = temp;
+           *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
 
            if (osnamep)
                *osnamep = "HPUX9";
index d5816ceee693bae2b69f2a41ba6b77e349f7a051..9f04e0bc5e1020ceb1c302c5e6e72d8d3f6ad81a 100644 (file)
@@ -853,7 +853,7 @@ static void
 nfs_printfh(register const u_int32_t *dp, const u_int len)
 {
        my_fsid fsid;
-       ino_t ino;
+       u_int32_t ino;
        const char *sfsname = NULL;
        char *spacep;
 
index 1e5fc3a9fcf9c1a1fa8f1ce12ee3a0a2128b087f..a5634fb0159d849f0fb688c0b05c3c03311f9374 100644 (file)
@@ -69,8 +69,6 @@
 #define read _read
 #define close _close
 #define O_RDONLY _O_RDONLY
-
-typedef short ino_t;
 #endif /* __MINGW32__ */
 
 #ifdef __MINGW32__