From 6699422d92430bdb3cd95dd53ec760ea2f424e95 Mon Sep 17 00:00:00 2001 From: Russell Cattelan Date: Tue, 6 May 2003 20:54:58 +0000 Subject: [PATCH] [contributed] FreeBSD update from Alexander Kabaev --- db/sb.c | 4 +- include/builddefs.in | 1 + include/platform_defs.h.in | 85 +++++++++++++++++++++++++++++++++++--- libxfs/rdwr.c | 2 +- libxlog/util.c | 2 +- m4/package_utilies.m4 | 2 +- m4/package_uuiddev.m4 | 9 ++-- 7 files changed, 90 insertions(+), 15 deletions(-) diff --git a/db/sb.c b/db/sb.c index 5259b2155..6500d1f80 100644 --- a/db/sb.c +++ b/db/sb.c @@ -358,7 +358,7 @@ uuid_f( dbprintf("failed to read UUID from AG 0\n"); return 0; } - memcpy(&uu, *uup, sizeof(uuid_t)); + memcpy(&uu, uup, sizeof(uuid_t)); uuid_unparse(uu, bp); dbprintf("old UUID = %s\n", bp); } else { @@ -400,7 +400,7 @@ uuid_f( break; } } else { - memcpy(uu, uup, sizeof(uuid_t)); + memcpy(&uu, uup, sizeof(uuid_t)); } } if (mp->m_sb.sb_logstart) { diff --git a/include/builddefs.in b/include/builddefs.in index b6ed182ce..17e9db49a 100644 --- a/include/builddefs.in +++ b/include/builddefs.in @@ -107,6 +107,7 @@ endif ifeq ($(PKG_PLATFORM),freebsd) PLDLIBS = -L/usr/local/lib -lintl PCFLAGS = -I/usr/local/include +LIBUUID = endif GCFLAGS += -O1 $(OPTIMIZER) $(DEBUG) -funsigned-char -Wall -I$(TOPDIR)/include \ diff --git a/include/platform_defs.h.in b/include/platform_defs.h.in index d11f28d40..8c6e5f7f9 100644 --- a/include/platform_defs.h.in +++ b/include/platform_defs.h.in @@ -44,11 +44,11 @@ #include #include #include -#include #if defined(__linux__) +#include #include #include #include @@ -117,11 +117,15 @@ typedef enum { B_FALSE,B_TRUE } boolean_t; #elif defined(__FreeBSD__) #include -#include -#include #include -#include +#include +#include #include +#include +#include +#include + +#include /* FreeBSD file API is 64-bit aware */ #define fstat64 fstat @@ -130,6 +134,7 @@ typedef enum { B_FALSE,B_TRUE } boolean_t; #define stat64 stat #define pwrite64 pwrite #define pread64 pread +#define fdatasync fsync #define memalign(a,size) valloc(size) typedef u_int8_t __u8; @@ -146,10 +151,12 @@ typedef int64_t __s64; #define EFSCORRUPTED 990 /* Filesystem is corrupted */ typedef off_t xfs_off_t; +typedef off_t off64_t; typedef __uint64_t xfs_ino_t; typedef __uint32_t xfs_dev_t; typedef __int64_t xfs_daddr_t; typedef char* xfs_caddr_t; +typedef off_t loff_t; #ifndef _UCHAR_T_DEFINED typedef unsigned char uchar_t; @@ -157,15 +164,81 @@ typedef unsigned char uchar_t; #endif typedef enum { B_FALSE,B_TRUE } boolean_t; +#define O_LARGEFILE 0 + #define HAVE_FID 1 #define HAVE_SWABMACROS 1 #define INT_SWAP16(type,var) ((typeof(type))(__bswap16((__u16)(var)))) #define INT_SWAP32(type,var) ((typeof(type))(__bswap32((__u32)(var)))) #define INT_SWAP64(type,var) ((typeof(type))(__bswap64((__u64)(var)))) +static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p) +{ + return ioctl(fd, cmd, p); +} -#elif defined(__APPLE__) /* Darwin */ +static __inline__ int platform_test_xfs_fd(int fd) +{ + struct statfs buf; + if (fstatfs(fd, &buf) < 0) + return 0; + return strcpy(buf.f_fstypename, "xfs") == 0; +} + +static __inline__ int platform_test_xfs_path(const char *path) +{ + struct statfs buf; + if (statfs(path, &buf) < 0) + return 0; + return strcpy(buf.f_fstypename, "xfs") == 0; +} + +static __inline__ int platform_fstatfs(int fd, struct statfs *buf) +{ + return fstatfs(fd, buf); +} +/* + * Implement Linux libuuid functions in terms of DEC DCE's uuid + * functions from FreeBSD libc. + */ + +static __inline__ int gnu_uuid_compare(uuid_t a, uuid_t b) +{ + return uuid_compare(&a, &b, NULL); +} +#define uuid_compare gnu_uuid_compare + +static __inline__ int uuid_is_null(uuid_t uid) +{ + return uuid_is_nil(&uid, NULL); +} + +static __inline__ void uuid_unparse(uuid_t uid, char *buf) +{ + uint32_t status; + char *str; + uuid_to_string(&uid, &str, &status); + if (status == uuid_s_ok) + strcpy(buf, str); + else *buf = '\0'; + free(str); +} + +static __inline__ int gnu_uuid_parse(const char *buf, uuid_t *uid) +{ + uint32_t status; + uuid_from_string(buf, uid, &status); + return (status == uuid_s_ok); +} +#define uuid_parse(s,u) gnu_uuid_parse((s), &(u)) + +#define uuid_generate(uid) uuid_create(&(uid), NULL) +#define uuid_clear(uid) uuid_create_nil(&(uid), NULL) +#define uuid_copy(dst, src) memcpy(&(dst), &(src), sizeof(uuid_t)) + +#elif defined(__APPLE__) /* Darwin */ +#include #include #include #include @@ -261,7 +334,6 @@ typedef unsigned char uchar_t; #define HAVE_FID 1 - #elif defined(__sgi__) /* SGI IRIX */ #include @@ -275,6 +347,7 @@ typedef unsigned char uchar_t; #include #include #include +#include #define __s8 char #define __s16 short diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index 614f10b75..eb06eded5 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -132,7 +132,7 @@ libxfs_log_clear( ASSIGN_ANY_LSN(head->h_lsn, 1, 0, ARCH_CONVERT); ASSIGN_ANY_LSN(head->h_tail_lsn, 1, 0, ARCH_CONVERT); - memcpy(head->h_fs_uuid, fs_uuid, sizeof(uuid_t)); + memcpy(&head->h_fs_uuid, fs_uuid, sizeof(uuid_t)); if (len > 1) { xfs_caddr_t dp; diff --git a/libxlog/util.c b/libxlog/util.c index 4aebea634..66a65803d 100644 --- a/libxlog/util.c +++ b/libxlog/util.c @@ -50,7 +50,7 @@ header_check_uuid(xfs_mount_t *mp, xlog_rec_header_t *head) "* SB : %s\n* log: %s\n"), uu_sb, uu_log); - memcpy(&mp->m_sb.sb_uuid, head->h_fs_uuid, sizeof(uuid_t)); + memcpy(&mp->m_sb.sb_uuid, &head->h_fs_uuid, sizeof(uuid_t)); return 0; } diff --git a/m4/package_utilies.m4 b/m4/package_utilies.m4 index afad8dc0f..e0116ce9a 100644 --- a/m4/package_utilies.m4 +++ b/m4/package_utilies.m4 @@ -32,7 +32,7 @@ AC_DEFUN([AC_PACKAGE_UTILITIES], AC_PACKAGE_NEED_UTILITY($1, "$make", make, [GNU make]) if test -z "$LIBTOOL"; then - AC_PATH_PROG(LIBTOOL, libtool,,/usr/bin) + AC_PATH_PROG(LIBTOOL, libtool,,/usr/bin:/usr/local/bin) fi libtool=$LIBTOOL AC_SUBST(libtool) diff --git a/m4/package_uuiddev.m4 b/m4/package_uuiddev.m4 index c4fd3d525..30bda09ca 100644 --- a/m4/package_uuiddev.m4 +++ b/m4/package_uuiddev.m4 @@ -1,19 +1,20 @@ AC_DEFUN([AC_PACKAGE_NEED_UUID_UUID_H], - [ AC_CHECK_HEADERS([uuid/uuid.h]) - if test "$ac_cv_header_uuid_uuid_h" != yes; then + [ AC_CHECK_HEADERS(uuid/uuid.h,, [ + AC_CHECK_HEADER(uuid.h,, [ echo echo 'FATAL ERROR: could not find a valid UUID header.' echo 'Install the Universally Unique Identifiers development package.' - exit 1 + exit 1]) fi ]) AC_DEFUN([AC_PACKAGE_NEED_UUIDPARSE_LIBUUID], [ AC_CHECK_LIB(uuid, uuid_parse,, [ + AC_CHECK_FUNCS(uuid_create,, [ echo echo 'FATAL ERROR: could not find a valid UUID library.' echo 'Install the Universally Unique Identifiers library package.' - exit 1 + exit 1]) ]) libuuid="/usr/lib/libuuid.a" AC_SUBST(libuuid) -- 2.47.2