public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] xfsprogs: Partial OS X support
@ 2015-07-15 12:46 Jan Tulak
  2015-07-15 12:46 ` [PATCH 1/2] Prefix LIST_... macros to XFS_LIST_ Jan Tulak
  2015-07-15 12:46 ` [PATCH 2/2] OS X partial support Jan Tulak
  0 siblings, 2 replies; 7+ messages in thread
From: Jan Tulak @ 2015-07-15 12:46 UTC (permalink / raw)
  To: xfs

These patches fixes the current broken OS X support of xfsprogs.
The goal is to make xfsprogs buildable on current OS X Yosemite,
and to have a working mkfs.xfs. The usage is indeed limited and
there is still space for many improvements, but "it works".

Jan Tulak (2):
  Prefix LIST_... macros to XFS_LIST_...
  OS X partial support

 Makefile                  |   6 +++
 include/bitops.h          |  47 ---------------------
 include/builddefs.in      |   2 +-
 include/darwin.h          | 104 +++++++++++++++++++++++++++++++++++++---------
 include/freebsd.h         |  47 +++++++++++++++++++++
 include/gnukfreebsd.h     |  46 ++++++++++++++++++++
 include/hlist.h           |  10 ++---
 include/irix.h            |  50 +++++++++++++++++++++-
 include/linux.h           |  46 ++++++++++++++++++++
 include/list.h            |   8 ++--
 libdisk/fstype.c          |   1 +
 libhandle/Makefile        |   4 ++
 libhandle/handle.c        |   2 +-
 libxcmd/paths.c           |   2 +-
 libxfs/trans.c            |   2 +-
 libxfs/xfs_bit.h          |   4 +-
 libxfs/xfs_fs.h           |   4 +-
 libxlog/xfs_log_recover.c |   6 +--
 man/man3/xfsctl.3         |   2 +-
 repair/incore.h           |   2 +-
 repair/phase6.c           |   4 +-
 21 files changed, 307 insertions(+), 92 deletions(-)

-- 
2.4.3

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] Prefix LIST_... macros to XFS_LIST_...
  2015-07-15 12:46 [PATCH 0/2] xfsprogs: Partial OS X support Jan Tulak
@ 2015-07-15 12:46 ` Jan Tulak
  2015-07-15 23:53   ` Dave Chinner
  2015-07-15 12:46 ` [PATCH 2/2] OS X partial support Jan Tulak
  1 sibling, 1 reply; 7+ messages in thread
From: Jan Tulak @ 2015-07-15 12:46 UTC (permalink / raw)
  To: xfs

OS X has some conflicting LIST_ macros, so prefix the XFS ones.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 include/hlist.h           | 10 +++++-----
 include/irix.h            |  4 ++--
 include/list.h            |  8 ++++----
 libhandle/handle.c        |  2 +-
 libxfs/trans.c            |  2 +-
 libxfs/xfs_fs.h           |  4 ++--
 libxlog/xfs_log_recover.c |  6 +++---
 man/man3/xfsctl.3         |  2 +-
 repair/incore.h           |  2 +-
 repair/phase6.c           |  4 ++--
 10 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/include/hlist.h b/include/hlist.h
index 9ee096c..0d9c5d6 100644
--- a/include/hlist.h
+++ b/include/hlist.h
@@ -15,8 +15,8 @@
  * along with this program; if not, write the Free Software Foundation,
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
-#ifndef __HLIST_H__
-#define __HLIST_H__
+#ifndef __HXFS_LIST_H__
+#define __HXFS_LIST_H__
 
 struct hlist_node {
 	struct hlist_node *next;
@@ -26,8 +26,8 @@ struct hlist_head {
 	struct hlist_node *first;
 };
 
-#define HLIST_HEAD_INIT { .first = NULL }
-static inline void INIT_HLIST_NODE(struct hlist_node *h)
+#define HXFS_LIST_HEAD_INIT { .first = NULL }
+static inline void INIT_HXFS_LIST_NODE(struct hlist_node *h)
 {
 	h->next = NULL;
 	h->pprev = NULL;
@@ -71,4 +71,4 @@ static inline void hlist_del(struct hlist_node *n)
 	     pos = pos->next)
 
 
-#endif	/* __LIST_H__ */
+#endif	/* __XFS_LIST_H__ */
diff --git a/include/irix.h b/include/irix.h
index 31050c4..c7f87d7 100644
--- a/include/irix.h
+++ b/include/irix.h
@@ -230,7 +230,7 @@ static __inline__ int xfsctl(const char *path, int fd, int cmd, void *arg)
 					((xfs_fsop_handlereq_t*)arg)->ihandlen,
 					((xfs_fsop_handlereq_t*)arg)->ohandle,
 					((xfs_fsop_handlereq_t*)arg)->ohandlen);
-		case SGI_ATTR_LIST_BY_HANDLE:
+		case SGI_ATTR_XFS_LIST_BY_HANDLE:
 			return syssgi(cmd,
 					((xfs_fsop_attrlist_handlereq_t*)arg)->hreq.ihandle,
 					((xfs_fsop_attrlist_handlereq_t*)arg)->hreq.ihandlen,
@@ -403,7 +403,7 @@ static __inline__ char * strsep(char **s, const char *ct)
 #define XFS_IOC_FREEZE			XFS_FS_FREEZE
 #define XFS_IOC_THAW			XFS_FS_THAW
 #define XFS_IOC_FSSETDM_BY_HANDLE	SGI_FSSETDM_BY_HANDLE
-#define XFS_IOC_ATTRLIST_BY_HANDLE	SGI_ATTR_LIST_BY_HANDLE
+#define XFS_IOC_ATTRXFS_LIST_BY_HANDLE	SGI_ATTR_XFS_LIST_BY_HANDLE
 #define XFS_IOC_ATTRMULTI_BY_HANDLE	SGI_ATTR_MULTI_BY_HANDLE
 #define XFS_IOC_FSGEOMETRY		XFS_FS_GEOMETRY
 #define XFS_IOC_GOINGDOWN		XFS_FS_GOINGDOWN
diff --git a/include/list.h b/include/list.h
index 3f087a4..84fdce0 100644
--- a/include/list.h
+++ b/include/list.h
@@ -27,12 +27,12 @@ struct list_head {
 	struct list_head *prev;
 };
 
-#define LIST_HEAD_INIT(name) { &(name), &(name) }
+#define XFS_LIST_HEAD_INIT(name) { &(name), &(name) }
 
-#define LIST_HEAD(name) \
-		struct list_head name = LIST_HEAD_INIT(name)
+#define XFS_LIST_HEAD(name) \
+		struct list_head name = XFS_LIST_HEAD_INIT(name)
 
-#define INIT_LIST_HEAD(list) list_head_init(list)
+#define INIT_XFS_LIST_HEAD(list) list_head_init(list)
 static inline void list_head_init(struct list_head *list)
 {
 	list->next = list->prev = list;
diff --git a/libhandle/handle.c b/libhandle/handle.c
index 54e6f71..76c8142 100644
--- a/libhandle/handle.c
+++ b/libhandle/handle.c
@@ -399,7 +399,7 @@ attr_list_by_handle(
 	if (alhreq.buflen > XATTR_LIST_MAX)
 		alhreq.buflen = XATTR_LIST_MAX;
 
-	error = xfsctl(path, fd, XFS_IOC_ATTRLIST_BY_HANDLE, &alhreq);
+	error = xfsctl(path, fd, XFS_IOC_ATTRXFS_LIST_BY_HANDLE, &alhreq);
 
 	memcpy(cursor, &alhreq.pos, sizeof(alhreq.pos));
 	return error;
diff --git a/libxfs/trans.c b/libxfs/trans.c
index 0388950..f7ff11d 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -169,7 +169,7 @@ libxfs_trans_alloc(
 	}
 	ptr->t_mountp = mp;
 	ptr->t_type = type;
-	INIT_LIST_HEAD(&ptr->t_items);
+	INIT_XFS_LIST_HEAD(&ptr->t_items);
 #ifdef XACT_DEBUG
 	fprintf(stderr, "allocated new transaction %p\n", ptr);
 #endif
diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h
index 89689c6..8c37e08 100644
--- a/libxfs/xfs_fs.h
+++ b/libxfs/xfs_fs.h
@@ -403,7 +403,7 @@ typedef struct xfs_fsop_handlereq {
 /*
  * Compound structures for passing args through Handle Request interfaces
  * xfs_fssetdm_by_handle, xfs_attrlist_by_handle, xfs_attrmulti_by_handle
- * - ioctls: XFS_IOC_FSSETDM_BY_HANDLE, XFS_IOC_ATTRLIST_BY_HANDLE, and
+ * - ioctls: XFS_IOC_FSSETDM_BY_HANDLE, XFS_IOC_ATTRXFS_LIST_BY_HANDLE, and
  *	     XFS_IOC_ATTRMULTI_BY_HANDLE
  */
 
@@ -553,7 +553,7 @@ typedef struct xfs_swapext
 #endif
 
 #define XFS_IOC_FSSETDM_BY_HANDLE    _IOW ('X', 121, struct xfs_fsop_setdm_handlereq)
-#define XFS_IOC_ATTRLIST_BY_HANDLE   _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq)
+#define XFS_IOC_ATTRXFS_LIST_BY_HANDLE   _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq)
 #define XFS_IOC_ATTRMULTI_BY_HANDLE  _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq)
 #define XFS_IOC_FSGEOMETRY	     _IOR ('X', 124, struct xfs_fsop_geom)
 #define XFS_IOC_GOINGDOWN	     _IOR ('X', 125, __uint32_t)
diff --git a/libxlog/xfs_log_recover.c b/libxlog/xfs_log_recover.c
index a80c431..1782db0 100644
--- a/libxlog/xfs_log_recover.c
+++ b/libxlog/xfs_log_recover.c
@@ -1018,9 +1018,9 @@ xlog_recover_new_tid(
 	trans = kmem_zalloc(sizeof(xlog_recover_t), KM_SLEEP);
 	trans->r_log_tid   = tid;
 	trans->r_lsn	   = lsn;
-	INIT_LIST_HEAD(&trans->r_itemq);
+	INIT_XFS_LIST_HEAD(&trans->r_itemq);
 
-	INIT_HLIST_NODE(&trans->r_list);
+	INIT_HXFS_LIST_NODE(&trans->r_list);
 	hlist_add_head(&trans->r_list, head);
 }
 
@@ -1031,7 +1031,7 @@ xlog_recover_add_item(
 	xlog_recover_item_t	*item;
 
 	item = kmem_zalloc(sizeof(xlog_recover_item_t), KM_SLEEP);
-	INIT_LIST_HEAD(&item->ri_list);
+	INIT_XFS_LIST_HEAD(&item->ri_list);
 	list_add_tail(&item->ri_list, head);
 }
 
diff --git a/man/man3/xfsctl.3 b/man/man3/xfsctl.3
index e84b829..756f4b8 100644
--- a/man/man3/xfsctl.3
+++ b/man/man3/xfsctl.3
@@ -459,7 +459,7 @@ reports unwritten=1, then the filesystem was made to flag unwritten extents.
 .B XFS_IOC_FD_TO_HANDLE
 .B XFS_IOC_OPEN_BY_HANDLE
 .B XFS_IOC_READLINK_BY_HANDLE
-.B XFS_IOC_ATTR_LIST_BY_HANDLE
+.B XFS_IOC_ATTR_XFS_LIST_BY_HANDLE
 .B XFS_IOC_ATTR_MULTI_BY_HANDLE
 .fi
 .PD 0
diff --git a/repair/incore.h b/repair/incore.h
index c92475e..0420a10 100644
--- a/repair/incore.h
+++ b/repair/incore.h
@@ -254,7 +254,7 @@ int		count_bcnt_extents(xfs_agnumber_t);
  * connected.
  */
 
-#define PLIST_CHUNK_SIZE	4
+#define PXFS_LIST_CHUNK_SIZE	4
 
 typedef xfs_ino_t parent_entry_t;
 
diff --git a/repair/phase6.c b/repair/phase6.c
index 9a5cba7..ae9f9fa 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -49,7 +49,7 @@ typedef struct dotdot_update {
 	int			ino_offset;
 } dotdot_update_t;
 
-static LIST_HEAD(dotdot_update_list);
+static XFS_LIST_HEAD(dotdot_update_list);
 static int			dotdot_update;
 
 static void
@@ -64,7 +64,7 @@ add_dotdot_update(
 		do_error(_("malloc failed add_dotdot_update (%zu bytes)\n"),
 			sizeof(dotdot_update_t));
 
-	INIT_LIST_HEAD(&dir->list);
+	INIT_XFS_LIST_HEAD(&dir->list);
 	dir->irec = irec;
 	dir->agno = agno;
 	dir->ino_offset = ino_offset;
-- 
2.4.3

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] OS X partial support
  2015-07-15 12:46 [PATCH 0/2] xfsprogs: Partial OS X support Jan Tulak
  2015-07-15 12:46 ` [PATCH 1/2] Prefix LIST_... macros to XFS_LIST_ Jan Tulak
@ 2015-07-15 12:46 ` Jan Tulak
  2015-07-16  1:25   ` Dave Chinner
  1 sibling, 1 reply; 7+ messages in thread
From: Jan Tulak @ 2015-07-15 12:46 UTC (permalink / raw)
  To: xfs

This patch introduces changes to support current OS X (10.10 Yosemite).
The previous OS X code base is about 4 years old and both OS X and
XFS changed, so there had to be done some work to make it compilable.

- Because some missing APIs in OS X (like fstab/mtab) and the
  unability to mount XFS, not all tools are compiled.
- fls (find last bit) calls were moved to platform headers,
  as OS X has a native implementation.
- xfs_db currently has only a dummy timer implementation
- Various other edits  - some API translations, some, missing
  defines.

The code compiles using Apple's clang, although it throws some
warnings. Some of them are complaints about deprecated calls, some
are false-positives and there are also some incompatible type
assignments/comparisons, so there is a place for further patches.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 Makefile              |   6 +++
 include/bitops.h      |  47 -----------------------
 include/builddefs.in  |   2 +-
 include/darwin.h      | 104 +++++++++++++++++++++++++++++++++++++++++---------
 include/freebsd.h     |  47 +++++++++++++++++++++++
 include/gnukfreebsd.h |  46 ++++++++++++++++++++++
 include/irix.h        |  46 ++++++++++++++++++++++
 include/linux.h       |  46 ++++++++++++++++++++++
 libdisk/fstype.c      |   1 +
 libhandle/Makefile    |   4 ++
 libxcmd/paths.c       |   2 +-
 libxfs/xfs_bit.h      |   4 +-
 12 files changed, 285 insertions(+), 70 deletions(-)

diff --git a/Makefile b/Makefile
index 6d6803b..2ab928b 100644
--- a/Makefile
+++ b/Makefile
@@ -48,6 +48,12 @@ LIB_SUBDIRS = libxfs $(DLIB_SUBDIRS)
 TOOL_SUBDIRS = copy db estimate fsck fsr growfs io logprint mkfs quota \
 		mdrestore repair rtcp m4 man doc po debian
 
+# Not every tool can work on OS X, so include only those, which has a reason.
+ifeq ($(PKG_PLATFORM),darwin)
+TOOL_SUBDIRS = copy db estimate fsck logprint mkfs quota \
+		mdrestore repair rtcp m4 man doc
+endif
+
 # include is listed last so it is processed last in clean rules.
 SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS) include
 
diff --git a/include/bitops.h b/include/bitops.h
index 930f64a..c6593bd 100644
--- a/include/bitops.h
+++ b/include/bitops.h
@@ -2,53 +2,6 @@
 #define __BITOPS_H__
 
 /*
- * fls: find last bit set.
- */
-
-static inline int fls(int x)
-{
-	int r = 32;
-
-	if (!x)
-		return 0;
-	if (!(x & 0xffff0000u)) {
-		x <<= 16;
-		r -= 16;
-	}
-	if (!(x & 0xff000000u)) {
-		x <<= 8;
-		r -= 8;
-	}
-	if (!(x & 0xf0000000u)) {
-		x <<= 4;
-		r -= 4;
-	}
-	if (!(x & 0xc0000000u)) {
-		x <<= 2;
-		r -= 2;
-	}
-	if (!(x & 0x80000000u)) {
-		r -= 1;
-	}
-	return r;
-}
-
-static inline int fls64(__u64 x)
-{
-	__u32 h = x >> 32;
-	if (h)
-		return fls(h) + 32;
-	return fls(x);
-}
-
-static inline unsigned fls_long(unsigned long l)
-{
-        if (sizeof(l) == 4)
-                return fls(l);
-        return fls64(l);
-}
-
-/*
  * ffz: find first zero bit.
  * Result is undefined if no zero bit exists.
  */
diff --git a/include/builddefs.in b/include/builddefs.in
index 7e9f53d..7f939f6 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -119,7 +119,7 @@ ifeq ($(PKG_PLATFORM),gnukfreebsd)
 PCFLAGS = -D_GNU_SOURCE $(GCCFLAGS)
 endif
 ifeq ($(PKG_PLATFORM),darwin)
-PCFLAGS = -traditional-cpp $(GCCFLAGS)
+PCFLAGS = $(GCCFLAGS)
 DEPENDFLAGS = -D__APPLE__
 endif
 ifeq ($(PKG_PLATFORM),irix)
diff --git a/include/darwin.h b/include/darwin.h
index 30f0052..df47d05 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -24,11 +24,15 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/mount.h>
+#include <sys/types.h>
+#include <ftw.h>
+#include <mach/mach_time.h>
+#include <inttypes.h>
 
 #include <machine/endian.h>
-#define __BYTE_ORDER	BYTE_ORDER
-#define __BIG_ENDIAN	BIG_ENDIAN
-#define __LITTLE_ENDIAN	LITTLE_ENDIAN
+#define __BYTE_ORDER   BYTE_ORDER
+#define __BIG_ENDIAN   BIG_ENDIAN
+#define __LITTLE_ENDIAN        LITTLE_ENDIAN
 
 #include <sys/syscall.h>
 # ifndef SYS_fsctl
@@ -68,45 +72,37 @@ static __inline__ void platform_getoptreset(void)
 
 static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2)
 {
-	return uuid_compare(uu1, uu2, NULL);
+	return uuid_compare((const unsigned char *) uu1, (const unsigned char*) uu2);
 }
 
 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';
-	free(s);
+	uuid_unparse(*uu, buffer);
 }
 
 static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu)
 {
-	uint32_t status;
-	uuid_from_string(buffer, uu, &status);
-	return (status == uuid_s_ok);
+	return uuid_parse(buffer, *uu);
 }
 
 static __inline__ int platform_uuid_is_null(uuid_t *uu)
 {
-	return uuid_is_nil(uu, NULL);
+	return uuid_is_null(*uu);
 }
 
 static __inline__ void platform_uuid_generate(uuid_t *uu)
 {
-	uuid_create(uu, NULL);
+	uuid_generate(*uu);
 }
 
 static __inline__ void platform_uuid_clear(uuid_t *uu)
 {
-	uuid_create_nil(uu, NULL);
+	uuid_clear(*uu);
 }
 
 static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src)
 {
-	memcpy(dst, src, sizeof(uuid_t));
+	uuid_copy(*dst, *src);
 }
 
 #define __int8_t	int8_t
@@ -142,11 +138,13 @@ typedef int64_t		xfs_daddr_t;
 #define O_SYNC          0
 #endif
 
-#define ENOATTR		989     /* Attribute not found */
 #define EFSCORRUPTED	990	/* Filesystem is corrupted */
 #define EFSBADCRC	991	/* Bad CRC detected */
 #define constpp		char * const *
 
+#define XATTR_SIZE_MAX 65536    /* size of an extended attribute value (64k) */
+#define XATTR_LIST_MAX 65536    /* size of extended attribute namelist (64k) */
+
 #define HAVE_FID	1
 
 static __inline__ int
@@ -155,4 +153,72 @@ platform_discard_blocks(int fd, uint64_t start, uint64_t len)
 	return 0;
 }
 
+
+/*
+ * Dummy POSIX timer replacement
+ */
+#define CLOCK_REALTIME 1
+typedef uint64_t timer_t;
+typedef double   timer_c;
+typedef clock_id_t clockid_t;
+struct itimerspec
+  {
+    struct timespec it_interval;
+    struct timespec it_value;
+  };
+
+static inline int timer_create (clockid_t __clock_id,
+                         struct sigevent *__restrict __evp,
+                         timer_t *__restrict __timerid)
+{
+	return 0;
+}
+
+static inline int timer_settime (timer_t __timerid, int __flags,
+                          const struct itimerspec *__restrict __value,
+                          struct itimerspec *__restrict __ovalue)
+{
+	return 0;
+}
+
+static inline int timer_delete (timer_t __timerid)
+{
+	return 0;
+}
+
+static inline int timer_gettime (timer_t __timerid, struct itimerspec *__value)
+{
+	return 0;
+}
+
+/*
+ * fls: find last bit set.
+ */
+
+static inline int platform_fls(int x)
+{
+	return fls(x);
+}
+
+static inline int platform_fls64(__u64 x)
+{
+	__u32 h = x >> 32;
+	if (h)
+		return platform_fls(h) + 32;
+	return platform_fls(x);
+}
+
+static inline unsigned platform_fls_long(unsigned long l)
+{
+        if (sizeof(l) == 4)
+                return platform_fls(l);
+        return platform_fls64(l);
+}
+
+static inline int nftw64(const char *path, int (*fn)(const char *, const struct stat *ptr, int flag, struct FTW *), int depth,
+         int flags)
+{
+	return nftw(path, fn, depth, flags);
+}
+
 #endif	/* __XFS_DARWIN_H__ */
diff --git a/include/freebsd.h b/include/freebsd.h
index e59b1e8..59deb30 100644
--- a/include/freebsd.h
+++ b/include/freebsd.h
@@ -138,4 +138,51 @@ platform_discard_blocks(int fd, uint64_t start, uint64_t len)
 	return 0;
 }
 
+/*
+ * fls: find last bit set.
+ */
+
+static inline int platform_fls(int x)
+{
+	int r = 32;
+
+	if (!x)
+		return 0;
+	if (!(x & 0xffff0000u)) {
+		x <<= 16;
+		r -= 16;
+	}
+	if (!(x & 0xff000000u)) {
+		x <<= 8;
+		r -= 8;
+	}
+	if (!(x & 0xf0000000u)) {
+		x <<= 4;
+		r -= 4;
+	}
+	if (!(x & 0xc0000000u)) {
+		x <<= 2;
+		r -= 2;
+	}
+	if (!(x & 0x80000000u)) {
+		r -= 1;
+	}
+	return r;
+}
+
+static inline int platform_fls64(__u64 x)
+{
+	__u32 h = x >> 32;
+	if (h)
+		return platform_fls(h) + 32;
+	return platform_fls(x);
+}
+
+static inline unsigned platform_fls_long(unsigned long l)
+{
+        if (sizeof(l) == 4)
+                return platform_fls(l);
+        return platform_fls64(l);
+}
+
 #endif	/* __XFS_FREEBSD_H__ */
diff --git a/include/gnukfreebsd.h b/include/gnukfreebsd.h
index f2e1bf5..8d75b6d 100644
--- a/include/gnukfreebsd.h
+++ b/include/gnukfreebsd.h
@@ -118,4 +118,50 @@ platform_discard_blocks(int fd, uint64_t start, uint64_t len)
 	return 0;
 }
 
+/*
+ * fls: find last bit set.
+ */
+
+static inline int platform_fls(int x)
+{
+	int r = 32;
+
+	if (!x)
+		return 0;
+	if (!(x & 0xffff0000u)) {
+		x <<= 16;
+		r -= 16;
+	}
+	if (!(x & 0xff000000u)) {
+		x <<= 8;
+		r -= 8;
+	}
+	if (!(x & 0xf0000000u)) {
+		x <<= 4;
+		r -= 4;
+	}
+	if (!(x & 0xc0000000u)) {
+		x <<= 2;
+		r -= 2;
+	}
+	if (!(x & 0x80000000u)) {
+		r -= 1;
+	}
+	return r;
+}
+
+static inline int platform_fls64(__u64 x)
+{
+	__u32 h = x >> 32;
+	if (h)
+		return platform_fls(h) + 32;
+	return platform_fls(x);
+}
+
+static inline unsigned platform_fls_long(unsigned long l)
+{
+        if (sizeof(l) == 4)
+                return platform_fls(l);
+        return platform_fls64(l);
+}
 #endif	/* __XFS_KFREEBSD_H__ */
diff --git a/include/irix.h b/include/irix.h
index c7f87d7..6dc4eb2 100644
--- a/include/irix.h
+++ b/include/irix.h
@@ -414,4 +414,50 @@ static __inline__ char * strsep(char **s, const char *ct)
 
 #define	XFS_XFLAG_NODEFRAG		0x00002000
 
+/*
+ * fls: find last bit set.
+ */
+
+static inline int platform_fls(int x)
+{
+	int r = 32;
+
+	if (!x)
+		return 0;
+	if (!(x & 0xffff0000u)) {
+		x <<= 16;
+		r -= 16;
+	}
+	if (!(x & 0xff000000u)) {
+		x <<= 8;
+		r -= 8;
+	}
+	if (!(x & 0xf0000000u)) {
+		x <<= 4;
+		r -= 4;
+	}
+	if (!(x & 0xc0000000u)) {
+		x <<= 2;
+		r -= 2;
+	}
+	if (!(x & 0x80000000u)) {
+		r -= 1;
+	}
+	return r;
+}
+
+static inline int platform_fls64(__u64 x)
+{
+	__u32 h = x >> 32;
+	if (h)
+		return platform_fls(h) + 32;
+	return platform_fls(x);
+}
+
+static inline unsigned platform_fls_long(unsigned long l)
+{
+        if (sizeof(l) == 4)
+                return platform_fls(l);
+        return platform_fls64(l);
+}
 #endif	/* __XFS_IRIX_H__ */
diff --git a/include/linux.h b/include/linux.h
index 31c077a..38321ab 100644
--- a/include/linux.h
+++ b/include/linux.h
@@ -143,4 +143,50 @@ typedef __uint64_t	xfs_ino_t;
 typedef __uint32_t	xfs_dev_t;
 typedef __int64_t	xfs_daddr_t;
 
+/*
+ * fls: find last bit set.
+ */
+
+static inline int platform_fls(int x)
+{
+	int r = 32;
+
+	if (!x)
+		return 0;
+	if (!(x & 0xffff0000u)) {
+		x <<= 16;
+		r -= 16;
+	}
+	if (!(x & 0xff000000u)) {
+		x <<= 8;
+		r -= 8;
+	}
+	if (!(x & 0xf0000000u)) {
+		x <<= 4;
+		r -= 4;
+	}
+	if (!(x & 0xc0000000u)) {
+		x <<= 2;
+		r -= 2;
+	}
+	if (!(x & 0x80000000u)) {
+		r -= 1;
+	}
+	return r;
+}
+
+static inline int platform_fls64(__u64 x)
+{
+	__u32 h = x >> 32;
+	if (h)
+		return platform_fls(h) + 32;
+	return platform_fls(x);
+}
+
+static inline unsigned platform_fls_long(unsigned long l)
+{
+        if (sizeof(l) == 4)
+                return platform_fls(l);
+        return platform_fls64(l);
+}
 #endif	/* __XFS_LINUX_H__ */
diff --git a/libdisk/fstype.c b/libdisk/fstype.c
index 548f297..c8bde34 100644
--- a/libdisk/fstype.c
+++ b/libdisk/fstype.c
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 #include "fstype.h"
 
 /*
diff --git a/libhandle/Makefile b/libhandle/Makefile
index 865ca22..0b5e1ad 100644
--- a/libhandle/Makefile
+++ b/libhandle/Makefile
@@ -10,7 +10,11 @@ LT_CURRENT = 1
 LT_REVISION = 3
 LT_AGE = 0
 
+ifeq ($(PKG_PLATFORM),darwin)
+LTLDFLAGS += -Wl,libhandle.sym
+else
 LTLDFLAGS += -Wl,--version-script,libhandle.sym
+endif
 
 CFILES = handle.c jdm.c
 LSRCFILES = libhandle.sym
diff --git a/libxcmd/paths.c b/libxcmd/paths.c
index c0b1ddb..b360617 100644
--- a/libxcmd/paths.c
+++ b/libxcmd/paths.c
@@ -364,7 +364,7 @@ fs_table_initialise_mounts(
 			continue;
 		if (!realpath(stats[i].f_mntfromname, rmntfromname))
 			continue;
-		if (!realpath(stats[i].f_mntonname, rmnttomname)))
+		if (!realpath(stats[i].f_mntonname, rmntonname))
 			continue;
 
 		if (path &&
diff --git a/libxfs/xfs_bit.h b/libxfs/xfs_bit.h
index e1649c0..f3e000c 100644
--- a/libxfs/xfs_bit.h
+++ b/libxfs/xfs_bit.h
@@ -41,13 +41,13 @@ static inline __uint64_t xfs_mask64lo(int n)
 /* Get high bit set out of 32-bit argument, -1 if none set */
 static inline int xfs_highbit32(__uint32_t v)
 {
-	return fls(v) - 1;
+	return platform_fls(v) - 1;
 }
 
 /* Get high bit set out of 64-bit argument, -1 if none set */
 static inline int xfs_highbit64(__uint64_t v)
 {
-	return fls64(v) - 1;
+	return platform_fls64(v) - 1;
 }
 
 /* Get low bit set out of 32-bit argument, -1 if none set */
-- 
2.4.3

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] Prefix LIST_... macros to XFS_LIST_...
  2015-07-15 12:46 ` [PATCH 1/2] Prefix LIST_... macros to XFS_LIST_ Jan Tulak
@ 2015-07-15 23:53   ` Dave Chinner
  2015-07-16  7:12     ` Jan Tulak
  0 siblings, 1 reply; 7+ messages in thread
From: Dave Chinner @ 2015-07-15 23:53 UTC (permalink / raw)
  To: Jan Tulak; +Cc: xfs

On Wed, Jul 15, 2015 at 02:46:51PM +0200, Jan Tulak wrote:
> OS X has some conflicting LIST_ macros, so prefix the XFS ones.

What are the macros that conflict and where do they come from?

> --- a/include/irix.h
> +++ b/include/irix.h
> @@ -230,7 +230,7 @@ static __inline__ int xfsctl(const char *path, int fd, int cmd, void *arg)
>  					((xfs_fsop_handlereq_t*)arg)->ihandlen,
>  					((xfs_fsop_handlereq_t*)arg)->ohandle,
>  					((xfs_fsop_handlereq_t*)arg)->ohandlen);
> -		case SGI_ATTR_LIST_BY_HANDLE:
> +		case SGI_ATTR_XFS_LIST_BY_HANDLE:

This is wrong - that's an Irix ioctl name and should not be renamed.
It won' compile on Irix with this change...

> diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h
> index 89689c6..8c37e08 100644
> --- a/libxfs/xfs_fs.h
> +++ b/libxfs/xfs_fs.h
> @@ -403,7 +403,7 @@ typedef struct xfs_fsop_handlereq {
>  /*
>   * Compound structures for passing args through Handle Request interfaces
>   * xfs_fssetdm_by_handle, xfs_attrlist_by_handle, xfs_attrmulti_by_handle
> - * - ioctls: XFS_IOC_FSSETDM_BY_HANDLE, XFS_IOC_ATTRLIST_BY_HANDLE, and
> + * - ioctls: XFS_IOC_FSSETDM_BY_HANDLE, XFS_IOC_ATTRXFS_LIST_BY_HANDLE, and
>   *	     XFS_IOC_ATTRMULTI_BY_HANDLE
>   */
>  
> @@ -553,7 +553,7 @@ typedef struct xfs_swapext
>  #endif
>  
>  #define XFS_IOC_FSSETDM_BY_HANDLE    _IOW ('X', 121, struct xfs_fsop_setdm_handlereq)
> -#define XFS_IOC_ATTRLIST_BY_HANDLE   _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq)
> +#define XFS_IOC_ATTRXFS_LIST_BY_HANDLE   _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq)
>  #define XFS_IOC_ATTRMULTI_BY_HANDLE  _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq)
>  #define XFS_IOC_FSGEOMETRY	     _IOR ('X', 124, struct xfs_fsop_geom)
>  #define XFS_IOC_GOINGDOWN	     _IOR ('X', 125, __uint32_t)

Renaming Linux ioctls is wrong, too, as that will break all source
code outside xfsprogs that uses this ioctl.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] OS X partial support
  2015-07-15 12:46 ` [PATCH 2/2] OS X partial support Jan Tulak
@ 2015-07-16  1:25   ` Dave Chinner
  0 siblings, 0 replies; 7+ messages in thread
From: Dave Chinner @ 2015-07-16  1:25 UTC (permalink / raw)
  To: Jan Tulak; +Cc: xfs

On Wed, Jul 15, 2015 at 02:46:52PM +0200, Jan Tulak wrote:
> This patch introduces changes to support current OS X (10.10 Yosemite).
> The previous OS X code base is about 4 years old and both OS X and
> XFS changed, so there had to be done some work to make it compilable.
> 
> - Because some missing APIs in OS X (like fstab/mtab) and the
>   unability to mount XFS, not all tools are compiled.

hmmmm. We should still try to compile them, otherwise anyone
doing dev work on OS X is going to make changes that aren't
complete (i.e. cause compile errors on other platforms).

> - fls (find last bit) calls were moved to platform headers,
>   as OS X has a native implementation.

I think that's the wrong way to do this - this is what autoconf is
for. i.e. create a "HAVE_FLS" check, and surround the fls code
in bitops.h with "#ifndef HAVE_FLS"....

> - xfs_db currently has only a dummy timer implementation

xfs_repair, actually ;)

> - Various other edits  - some API translations, some, missing
>   defines.
> 
> The code compiles using Apple's clang, although it throws some
> warnings. Some of them are complaints about deprecated calls, some
> are false-positives and there are also some incompatible type
> assignments/comparisons, so there is a place for further patches.

Let's try and keep the changes within the darwin and autoconf code
as much as possible. 

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] Prefix LIST_... macros to XFS_LIST_...
  2015-07-15 23:53   ` Dave Chinner
@ 2015-07-16  7:12     ` Jan Tulak
  2015-07-26 16:19       ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Tulak @ 2015-07-16  7:12 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs



----- Original Message -----
> From: "Dave Chinner" <david@fromorbit.com>
> To: "Jan Tulak" <jtulak@redhat.com>
> Cc: xfs@oss.sgi.com
> Sent: Thursday, July 16, 2015 1:53:06 AM
> Subject: Re: [PATCH 1/2] Prefix LIST_... macros to XFS_LIST_...
> 
> On Wed, Jul 15, 2015 at 02:46:51PM +0200, Jan Tulak wrote:
> > OS X has some conflicting LIST_ macros, so prefix the XFS ones.
> 
> What are the macros that conflict and where do they come from?
>

Ah, I see, I messed this patch a bit. :P 

Written as regular expressions, only ^LIST_[A-Z_]+$ macros are an 
issue. Like LIST_HEAD and so on. The IRIX and ioctls should be OK. 
I'm fixing it. :-)

Thanks for noticing it,
Jan

-- 
Jan Tulak
jtulak@redhat.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] Prefix LIST_... macros to XFS_LIST_...
  2015-07-16  7:12     ` Jan Tulak
@ 2015-07-26 16:19       ` Christoph Hellwig
  0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2015-07-26 16:19 UTC (permalink / raw)
  To: Jan Tulak; +Cc: xfs

libxfs comes form the Linux kernel which uses these names,
so we shouldn't rename them either.

On various BSDS LIST* is used for different list macros, so the real
question is how we end up including those.

Can you post the compiler warnings you see without this patch?

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-07-26 16:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-15 12:46 [PATCH 0/2] xfsprogs: Partial OS X support Jan Tulak
2015-07-15 12:46 ` [PATCH 1/2] Prefix LIST_... macros to XFS_LIST_ Jan Tulak
2015-07-15 23:53   ` Dave Chinner
2015-07-16  7:12     ` Jan Tulak
2015-07-26 16:19       ` Christoph Hellwig
2015-07-15 12:46 ` [PATCH 2/2] OS X partial support Jan Tulak
2015-07-16  1:25   ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox