From: Derrick Brashear Date: Thu, 19 Mar 2009 20:12:53 +0000 (+0000) Subject: cbd-new-magic-version-with-fixed-time-size-and-dump-switch-20090319 X-Git-Tag: openafs-devel-1_5_61~432 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=79d362c77cfc307dc66bfe874952a914e2313e89 cbd-new-magic-version-with-fixed-time-size-and-dump-switch-20090319 LICENSE IPL10 FIXES 124451 make cbd able to select whether time is 32 or 64 bit; when time size is known, have a new magic number so it's obvious --- diff --git a/src/viced/callback.c b/src/viced/callback.c index 3be47e1..24f17e5 100644 --- a/src/viced/callback.c +++ b/src/viced/callback.c @@ -1691,6 +1691,8 @@ PrintCallBackStats(void) } #define MAGIC 0x12345678 /* To check byte ordering of dump when it is read in */ +#define MAGICV2 0x12345679 /* To check byte ordering & version of dump when it is read in */ + #ifndef INTERPRET_DUMP @@ -2663,8 +2665,7 @@ int DumpCallBackState(void) { int fd, oflag; - afs_uint32 magic = MAGIC, freelisthead; - time_t now = FT_ApproxTime(); + afs_uint32 magic = MAGICV2, now = (afs_int32) FT_ApproxTime(), freelisthead; oflag = O_WRONLY | O_CREAT | O_TRUNC; #ifdef AFS_NT40_ENV @@ -2702,11 +2703,14 @@ DumpCallBackState(void) /* This is only compiled in for the callback analyzer program */ /* Returns the time of the dump */ time_t -ReadDump(char *file) +ReadDump(char *file, int timebits) { int fd, oflag; afs_uint32 magic, freelisthead; afs_uint32 now; +#ifdef AFS_64BIT_ENV + afs_int64 now64; +#endif oflag = O_RDONLY; #ifdef AFS_NT40_ENV @@ -2718,15 +2722,25 @@ ReadDump(char *file) exit(1); } read(fd, &magic, sizeof(magic)); - if (magic != MAGIC) { - fprintf(stderr, - "Magic number of %s is invalid. You might be trying to\n", - file); - fprintf(stderr, - "run this program on a machine type with a different byte ordering.\n"); - exit(1); + if (magic == MAGICV2) { + timebits = 32; + } else { + if (magic != MAGIC) { + fprintf(stderr, + "Magic number of %s is invalid. You might be trying to\n", + file); + fprintf(stderr, + "run this program on a machine type with a different byte ordering.\n"); + exit(1); + } } - read(fd, &now, sizeof(now)); +#ifdef AFS_64BIT_ENV + if (timebits == 64) { + read(fd, &now64, sizeof(afs_int64)); + now = (afs_int32) now64; + } else +#endif + read(fd, &now, sizeof(afs_int32)); read(fd, &cbstuff, sizeof(cbstuff)); read(fd, TimeOuts, sizeof(TimeOuts)); read(fd, timeout, sizeof(timeout)); @@ -2762,8 +2776,9 @@ main(int argc, char **argv) static AFSFid fid; register struct FileEntry *fe; register struct CallBack *cb; - time_t now; - + afs_int32 now; + int timebits = 32; + memset(&fid, 0, sizeof(fid)); argc--; argv++; @@ -2795,6 +2810,19 @@ main(int argc, char **argv) all = 1; } else if (!strcmp(*argv, "-raw")) { raw = 1; + } else if (!strcmp(*argv, "-timebits")) { + if (argc < 1) { + err++; + break; + } + argc--; + timebits = atoi(*++argv); + if ((timebits != 32) +#ifdef AFS_64BIT_ENV + && (timebits != 64) +#endif + ) + err++; } else if (!strcmp(*argv, "-volume")) { if (argc < 1) { err++; @@ -2808,12 +2836,16 @@ main(int argc, char **argv) } if (err || argc != 1) { fprintf(stderr, - "Usage: cbd [-host cbid] [-fid volume vnode] [-stats] [-all] callbackdumpfile\n"); + "Usage: cbd [-host cbid] [-fid volume vnode] [-stats] [-all] [-timebits 32" +#ifdef AFS_64BIT_ENV + "|64" +#endif + "] callbackdumpfile\n"); fprintf(stderr, "[cbid is shown for each host in the hosts.dump file]\n"); exit(1); } - now = ReadDump(*argv); + now = ReadDump(*argv, timebits); if (stats || noptions == 0) { time_t uxtfirst = UXtime(tfirst); printf("The time of the dump was %u %s", (unsigned int) now, ctime(&now));