From d6fc723d568e32351764991605095154e2963890 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Thu, 19 Mar 2009 20:13:23 +0000 Subject: [PATCH] STABLE14-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 (cherry picked from commit 79d362c77cfc307dc66bfe874952a914e2313e89) --- src/viced/callback.c | 62 +++++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 15 deletions(-) diff --git a/src/viced/callback.c b/src/viced/callback.c index d8a06a63b..c6b05c2cb 100644 --- a/src/viced/callback.c +++ b/src/viced/callback.c @@ -1799,6 +1799,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 @@ -1806,8 +1808,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 @@ -1845,11 +1846,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 @@ -1861,15 +1865,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)); @@ -1901,8 +1915,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++; @@ -1934,6 +1949,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++; @@ -1947,12 +1975,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", now, ctime(&now)); -- 2.39.5