From 4d32d744f07ce74abac7029c3ee7c6f5e4238d25 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Fri, 28 Apr 2006 04:02:55 +0000 Subject: [PATCH] Complete uuid platform abstractions, fix do_div for 64 bit platforms. Merge of master-melb:xfs-cmds:25844a by kenmcd. --- copy/xfs_copy.c | 7 ++++--- db/fprint.c | 2 +- db/sb.c | 12 ++++++------ doc/CHANGES | 1 + include/builddefs.in | 1 + include/buildmacros | 2 +- include/darwin.h | 12 ++++++------ include/freebsd.h | 6 +++--- include/irix.h | 6 +++--- include/linux.h | 24 ++++++++++++++++++++++-- libxfs/xfs.h | 2 +- libxlog/util.c | 6 +++--- logprint/log_misc.c | 2 +- mkfs/xfs_mkfs.c | 4 ++-- 14 files changed, 55 insertions(+), 32 deletions(-) diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c index a11be521c..81cd1c641 100644 --- a/copy/xfs_copy.c +++ b/copy/xfs_copy.c @@ -854,9 +854,9 @@ main(int argc, char **argv) for (i = 0, tcarg = targ; i < num_targets; i++, tcarg++) { if (!duplicate) - uuid_generate(tcarg->uuid); + platform_uuid_generate(&tcarg->uuid); else - uuid_copy(tcarg->uuid, mp->m_sb.sb_uuid); + platform_uuid_copy(&tcarg->uuid, &mp->m_sb.sb_uuid); if (pthread_mutex_init(&tcarg->wait, NULL) != 0) { do_log(_("Error creating thread mutex %d\n"), i); @@ -1146,7 +1146,8 @@ main(int argc, char **argv) /* do each thread in turn, each has its own UUID */ for (j = 0, tcarg = targ; j < num_targets; j++) { - uuid_copy(ag_hdr.xfs_sb->sb_uuid, tcarg->uuid); + platform_uuid_copy(&ag_hdr.xfs_sb->sb_uuid, + &tcarg->uuid); do_write(tcarg); tcarg++; } diff --git a/db/fprint.c b/db/fprint.c index df8d607d6..b6738555d 100644 --- a/db/fprint.c +++ b/db/fprint.c @@ -177,7 +177,7 @@ fp_uuid( i++, p++) { if (array) dbprintf("%d:", i + base); - uuid_unparse(*p, bp); + platform_uuid_unparse(p, bp); dbprintf("%s", bp); if (i < count - 1) dbprintf(" "); diff --git a/db/sb.c b/db/sb.c index 08de3f3ef..746a72f4d 100644 --- a/db/sb.c +++ b/db/sb.c @@ -345,9 +345,9 @@ uuid_f( } if (!strcasecmp(argv[1], "generate")) { - uuid_generate(uu); + platform_uuid_generate(&uu); } else if (!strcasecmp(argv[1], "nil")) { - uuid_clear(uu); + platform_uuid_clear(&uu); } else if (!strcasecmp(argv[1], "rewrite")) { uup = do_uuid(0, NULL); if (!uup) { @@ -355,10 +355,10 @@ uuid_f( return 0; } memcpy(&uu, uup, sizeof(uuid_t)); - uuid_unparse(uu, bp); + platform_uuid_unparse(&uu, bp); dbprintf("old UUID = %s\n", bp); } else { - if (uuid_parse(argv[1], uu)) { + if (platform_uuid_parse(argv[1], &uu)) { dbprintf("invalid UUID\n"); return 0; } @@ -375,7 +375,7 @@ uuid_f( break; } - uuid_unparse(uu, bp); + platform_uuid_unparse(&uu, bp); dbprintf("new UUID = %s\n", bp); return 0; @@ -408,7 +408,7 @@ uuid_f( "for FS with an external log\n"); } - uuid_unparse(uu, bp); + platform_uuid_unparse(&uu, bp); dbprintf("UUID = %s\n", bp); } diff --git a/doc/CHANGES b/doc/CHANGES index f31138781..e89eec0da 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -3,6 +3,7 @@ b+tree nodes as corrupt. - Portability changes, get xfs_repair compiling on IRIX. - Parent pointer updates in xfs_io checker command. + - Allow LDFLAGS to be overridden, for Gentoo punters. xfsprogs-2.7.17 (05 April 2006) - Fix libxfs access(2) check on /proc/mounts, which was diff --git a/include/builddefs.in b/include/builddefs.in index 2f19afb53..50f7b652b 100644 --- a/include/builddefs.in +++ b/include/builddefs.in @@ -23,6 +23,7 @@ _BUILDDEFS_INCLUDED_ = 1 DEBUG = @debug_build@ OPTIMIZER = @opt_build@ MALLOCLIB = @malloc_lib@ +LOADERFLAGS = @LDFLAGS@ LIBUUID = @libuuid@ LIBPTHREAD = @libpthread@ diff --git a/include/buildmacros b/include/buildmacros index 928f24f71..0c81aaaaa 100644 --- a/include/buildmacros +++ b/include/buildmacros @@ -9,7 +9,7 @@ BUILDRULES = $(TOPDIR)/include/buildrules # $(CXXFILES), or $(HFILES) and is used to construct the manifest list # during the "dist" phase (packaging). -LDFLAGS = $(LLDFLAGS) +LDFLAGS += $(LOADERFLAGS) $(LLDFLAGS) LDLIBS = $(LLDLIBS) $(PLDLIBS) $(MALLOCLIB) MAKEOPTS = --no-print-directory diff --git a/include/darwin.h b/include/darwin.h index 993e6109d..e0164a596 100644 --- a/include/darwin.h +++ b/include/darwin.h @@ -66,15 +66,15 @@ static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2) return uuid_compare(uu1, uu2, NULL); } -static __inline__ void platform_uuid_unparse(uuid_t *uu, char **buffer) +static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer) { uint32_t status; - char *str; - uuid_to_string(uu, &str, &status); + char *s; + uuid_to_string(uu, &s, &status); if (status == uuid_s_ok) - strcpy(buf, str); - else *buf = '\0'; - free(str); + strcpy(buffer, s); + else buffer[0] = '\0'; + free(s); } static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu) diff --git a/include/freebsd.h b/include/freebsd.h index 1697f72c9..b68f17d41 100644 --- a/include/freebsd.h +++ b/include/freebsd.h @@ -102,14 +102,14 @@ static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2) return uuid_compare(uu1, uu2, NULL); } -static __inline__ void platform_uuid_unparse(uuid_t *uu, char **buffer) +static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer) { uint32_t status; char *s; uuid_to_string(uu, &s, &status); if (status == uuid_s_ok) - strcpy(*buffer, s); - else *buffer[0] = '\0'; + strcpy(buffer, s); + else buffer[0] = '\0'; free(s); } diff --git a/include/irix.h b/include/irix.h index 30fd0e9a4..edca008ba 100644 --- a/include/irix.h +++ b/include/irix.h @@ -258,14 +258,14 @@ static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2) return uuid_compare(uu1, uu2, &status); } -static __inline__ void platform_uuid_unparse(uuid_t *uu, char **buffer) +static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer) { uint_t status; char *s; uuid_to_string(uu, &s, &status); if (status == uuid_s_ok) - strcpy(*buffer, s); - else *buffer[0] = '\0'; + strcpy(buffer, s); + else buffer[0] = '\0'; free(s); } diff --git a/include/linux.h b/include/linux.h index bc9ad4bf6..e6dc58ff0 100644 --- a/include/linux.h +++ b/include/linux.h @@ -63,9 +63,14 @@ static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2) return uuid_compare(*uu1, *uu2); } -static __inline__ void platform_uuid_unparse(uuid_t *uu, char **buffer) +static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer) { - uuid_unparse(*uu, *buffer); + uuid_unparse(*uu, buffer); +} + +static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu) +{ + return uuid_parse(buffer, *uu); } static __inline__ int platform_uuid_is_null(uuid_t *uu) @@ -73,6 +78,21 @@ static __inline__ int platform_uuid_is_null(uuid_t *uu) return uuid_is_null(*uu); } +static __inline__ void platform_uuid_generate(uuid_t *uu) +{ + uuid_generate(*uu); +} + +static __inline__ void platform_uuid_clear(uuid_t *uu) +{ + uuid_clear(*uu); +} + +static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src) +{ + uuid_copy(*dst, *src); +} + #if (__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ <= 1)) # define constpp const char * const * #else diff --git a/libxfs/xfs.h b/libxfs/xfs.h index 39a363803..5b3f6aa02 100644 --- a/libxfs/xfs.h +++ b/libxfs/xfs.h @@ -330,7 +330,7 @@ static inline int __do_div(unsigned long long *n, unsigned base) *n = ((unsigned long) *n) / (unsigned) base; return __res; } -#define do_div(n,base) (__do_div(&(n), (base))) +#define do_div(n,base) (__do_div((unsigned long long *)&(n), (base))) #define do_mod(a, b) ((a) % (b)) #define rol32(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) diff --git a/libxlog/util.c b/libxlog/util.c index e08f9f069..1410d0581 100644 --- a/libxlog/util.c +++ b/libxlog/util.c @@ -26,13 +26,13 @@ libxfs_init_t x; static int header_check_uuid(xfs_mount_t *mp, xlog_rec_header_t *head) { - char uu_log[64], uu_sb[64], *uup_log = &uu_log[0], *uup_sb = &uu_sb[0]; + char uu_log[64], uu_sb[64]; if (print_skip_uuid) return 0; if (!platform_uuid_compare(&mp->m_sb.sb_uuid, &head->h_fs_uuid)) return 0; - platform_uuid_unparse(&mp->m_sb.sb_uuid, &uup_sb); - platform_uuid_unparse(&head->h_fs_uuid, &uup_log); + platform_uuid_unparse(&mp->m_sb.sb_uuid, uu_sb); + platform_uuid_unparse(&head->h_fs_uuid, uu_log); printf(_("* ERROR: mismatched uuid in log\n" "* SB : %s\n* log: %s\n"), diff --git a/logprint/log_misc.c b/logprint/log_misc.c index fed4dbb80..35fcfc582 100644 --- a/logprint/log_misc.c +++ b/logprint/log_misc.c @@ -1124,7 +1124,7 @@ xlog_print_rec_head(xlog_rec_header_t *head, int *len) printf("\n"); } - uuid_unparse(head->h_fs_uuid, uub); + platform_uuid_unparse(&head->h_fs_uuid, uub); printf("uuid: %s format: ", uub); switch (INT_GET(head->h_fmt, ARCH_CONVERT)) { case XLOG_FMT_UNKNOWN: diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 5bfad6a99..6b4594e03 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -1966,8 +1966,8 @@ an AG size that is one stripe unit smaller, for example %llu.\n"), sbp->sb_dblocks = dblocks; sbp->sb_rblocks = rtblocks; sbp->sb_rextents = rtextents; - uuid_generate(uuid); - uuid_copy(sbp->sb_uuid, uuid); + platform_uuid_generate(&uuid); + platform_uuid_copy(&sbp->sb_uuid, &uuid); sbp->sb_logstart = logstart; sbp->sb_rootino = sbp->sb_rbmino = sbp->sb_rsumino = NULLFSINO; sbp->sb_rextsize = rtextblocks; -- 2.47.2