]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
[contributed] FreeBSD update from Alexander Kabaev
authorRussell Cattelan <cattelan@sgi.com>
Tue, 6 May 2003 20:54:58 +0000 (20:54 +0000)
committerRussell Cattelan <cattelan@sgi.com>
Tue, 6 May 2003 20:54:58 +0000 (20:54 +0000)
db/sb.c
include/builddefs.in
include/platform_defs.h.in
libxfs/rdwr.c
libxlog/util.c
m4/package_utilies.m4
m4/package_uuiddev.m4

diff --git a/db/sb.c b/db/sb.c
index 5259b21558ad3e27eb7c7b18b47da3b65a987a46..6500d1f809c429ed58108adf3938e32dc328678a 100644 (file)
--- 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) {
index b6ed182ce5bb0204fa48735cdc6d3bb5f5c2102b..17e9db49a08b400d2bdd707df0535e883b8e2a0e 100644 (file)
@@ -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 \
index d11f28d40f554cf8917daa7cb3b54f81bfdbd737..8c6e5f7f9d202787881f9aa98f7b35b2dea269ef 100644 (file)
 #include <string.h>
 #include <unistd.h>
 #include <sys/types.h>
-#include <uuid/uuid.h>
 
 
 #if defined(__linux__)
 
+#include <uuid/uuid.h>
 #include <sys/vfs.h>
 #include <sys/ioctl.h>
 #include <sys/param.h>
@@ -117,11 +117,15 @@ typedef enum { B_FALSE,B_TRUE }   boolean_t;
 #elif defined(__FreeBSD__)
 
 #include <sys/stat.h>
-#include <libgen.h>
-#include <machine/endian.h>
 #include <sys/param.h>
-#include <paths.h>
+#include <sys/ioccom.h>
+#include <sys/mount.h>
 #include <ctype.h>
+#include <libgen.h>
+#include <paths.h>
+#include <uuid.h>
+
+#include <machine/endian.h>
 
 /* 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 <uuid/uuid.h>
 #include <libgen.h>
 #include <sys/vm.h>
 #include <sys/stat.h>
@@ -261,7 +334,6 @@ typedef unsigned char       uchar_t;
 
 #define HAVE_FID       1
 
-
 #elif defined(__sgi__) /* SGI IRIX */
 
 #include <libgen.h>
@@ -275,6 +347,7 @@ typedef unsigned char       uchar_t;
 #include <sys/statfs.h>
 #include <sys/statvfs.h>
 #include <sys/sysmacros.h>
+#include <uuid/uuid.h>
 
 #define __s8           char
 #define __s16          short
index 614f10b75954175c64cb375721d6137915cd7406..eb06eded5e156e671bcf2f79e96f84ea5df97301 100644 (file)
@@ -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;
index 4aebea634b1b37551dc53214b8646538c23cd48a..66a65803d88c20736e7c9aaa29e3cefdc500abf9 100644 (file)
@@ -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;
 }
index afad8dc0f181449b681bd3429a49075554c4b82e..e0116ce9a1e36af2fbd4cf345bbf50b8495ec8bb 100644 (file)
@@ -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)
index c4fd3d525be2a74261084d5102e2a1b75b4d357e..30bda09ca47dca9ff3d204ff16aec84de1fcf49f 100644 (file)
@@ -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)