xfsprogs: Partial OS X support
v2 cover xfsprogs: Partial OS X support
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 but "it works".
This v2 fixes known issues from the first patchset and builds entire xfsprogs.
Jan Tulak (4):
xfsprogs: Prefix LIST_... macros to XFS_LIST_...
xfsprogs: Don't Make .po files with gettext disabled
xfsprogs: Use glibtoolize on osx
xfsprogs: OS X partial support
Makefile | 19 +++++- configure.ac | 1 + fsr/xfs_fsr.c | 20 +++++- include/bitops.h | 2 + include/builddefs.in | 6 +- include/darwin.h | 168 ++++++++++++++++++++++++++++++++++++++++++++------ include/list.h | 6 +- io/readdir.c | 4 ++ libdisk/fstype.c | 1 + libhandle/Makefile | 4 ++ libxcmd/paths.c | 2 +- m4/package_libcdev.m4 | 14 +++++ repair/phase6.c | 2 +- 13 files changed, 218 insertions(+), 31 deletions(-)
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 1/4 xfsprogs: Prefix LIST_... macros to XFS_LIST_...
OS X has some conflicting LIST_ macros, so prefix the XFS ones.
--- include/list.h | 6 +++--- repair/phase6.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
include/list.h +3 -3
@@ -27,10 +27,10 @@ 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)static inline void list_head_init (struct list_head *list)
repair/phase6.c +1 -1
@@ -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
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v2 1/4] xfsprogs: Prefix LIST_... macros to XFS_LIST_...
Quoted 1 line · Jan Tulak
OS X has some conflicting
LIST_macros, so prefix the XFS ones.
What macros, and how do we get them included in the build? I shouldn't need to go and use google to work out why a change is beign made....
Quoted 14 lines
Signed-off-by Jan Tulak <[email protected]>--- include/list.h | 6 +++--- repair/phase6.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)include/list.h +0
-0@@ -27,10 +27,10 @@ struct list_head {struct list_head *prev; };
include/list.h struct list_head { · line 36
Quoted 10 lines
include/list.h +3
-3-#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)static inline void list_head_init (struct list_head *list)
This is supposed to match what is required for libxfs/ so we don't have to modify the kernel code we bring across. Without knowing exactly how we are including conflicting definitions from the OS X include files, it's really hard to suggest other possible solutions...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v2 1/4] xfsprogs: Prefix LIST_... macros to XFS_LIST_...
----- Original Message -----
Quoted 9 lines
From: "Dave Chinner" <[email protected]>
What macros, and how do we get them included in the build? I shouldn't need to go and use google to work out why a change is beign made....Quoted 3 lines
Quoted 6 lines
This is supposed to match what is required for libxfs/ so we don't have to modify the kernel code we bring across. Without knowing exactly how we are including conflicting definitions from the OS X include files, it's really hard to suggest other possible solutions...
Ahh, sorry, I already wrote a reply to Chris, but it looks like I pressed "save" instead "send" - I found it in drafts and not in send emails. /shy
I will edit the commit message appropriately when resubmitting.
The conflicting macros are LIST_HEAD and LIST_HEAD_INIT.
Here is the reply I didn't sent:
----- Original Message -----
Quoted 4 lines
From: "Christoph Hellwig" <[email protected]>
Can you post the compiler warnings you see without this patch?
Sure, these:
../include/xfs/list.h:32:9: warning: 'LIST_HEAD' macro redefined [-Wmacro-redefined]
#define LIST_HEAD(name) \
^
/usr/include/sys/queue.h:417:9: note: previous definition is here
#define LIST_HEAD(name, type) \
^(and the same for LIST_HEAD_INIT)
sys/queue.h is not linked directly, but from many system libraries. A quick grep on /usr/include/ shows 24 header files including the queue, sys/mount.h one of them. And I didn't found a way how to avoid it.
If you have an idea what else to to with it, I'm happy to try it.
Cheers,
Jan
Signature · 7 lines
Jan Tulak [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v2 1/4] xfsprogs: Prefix LIST_... macros to XFS_LIST_...
Quoted 12 lines · Jan Tulak
Quoted 11 lines
From: "Dave Chinner" <[email protected]>
What macros, and how do we get them included in the build? I shouldn't need to go and use google to work out why a change is beign made....This is supposed to match what is required for libxfs/ so we don't have to modify the kernel code we bring across. Without knowing exactly how we are including conflicting definitions from the OS X include files, it's really hard to suggest other possible solutions...
Quoted 3 lines
Ahh, sorry, I already wrote a reply to Chris, but it looks like I pressed "save" instead "send" - I found it in drafts and not in send emails. /shy
No worries, we all do silly things like that from time to time, myself included.
Quoted 8 lines
Sure, these:
../include/xfs/list.h:32:9: warning: 'LIST_HEAD' macro redefined [-Wmacro-redefined]#define LIST_HEAD(name) \ ^ /usr/include/sys/queue.h:417:9: note: previous definition is here #define LIST_HEAD(name, type) \ ^
Quoted 5 lines
(and the same for
LIST_HEAD_INIT)
sys/queue.his not linked directly, but from many system libraries. A quick grep on/usr/include/shows 24 header files including the queue,sys/mount.hone of them. And I didn't found a way how to avoid it.
Ok, so 4.4BSD introduced these years ago. Now it rings a bell, but I can't find the relevant thread I'm thinking of (google has become almost useless as a mailing list search engine in recent times).
I suspect that we are going to need an
#undef LIST_HEAD
somewhere in include/libxfs.h, libxfs/libxfs_priv.h and/or include/list.h just to ensure we don't use the system definitions (with a large comment explaining it).
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v2 1/4] xfsprogs: Prefix LIST_... macros to XFS_LIST_...
----- Original Message -----
Quoted 15 lines
From: "Dave Chinner" <[email protected]>
Quoted 8 lines
/usr/include/sys/queue.h:417:9: note: previous definition is here#define LIST_HEAD(name, type) \ ^(and the same for
LIST_HEAD_INIT)
sys/queue.his not linked directly, but from many system libraries. A quick grep on/usr/include/shows 24 header files including the queue,sys/mount.hone of them. And I didn't found a way how to avoid it.Ok, so 4.4BSD introduced these years ago. Now it rings a bell, but I can't find the relevant thread I'm thinking of (google has become almost useless as a mailing list search engine in recent times).
Quoted 8 lines
I suspect that we are going to need an
#undef
LIST_HEADsomewhere in
include/libxfs.h,libxfs/libxfs_priv.hand/orinclude/list.hjust to ensure we don't use the system definitions (with a large comment explaining it).
Great! Putting it in libxfs/list.h seems to be enough. This header should be included anywhere where our lists are used, so I think there should be no risk of using the system definition anymore. I'm making an updated patch.
Thanks for pointing on #undef. I'm sure I must have heard of it before, but as I never used it... :-)
Cheers,
Jan
Signature · 7 lines
Jan Tulak [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 2/4 xfsprogs: Don't Make .po files with gettext disabled
In reply to Jan Tulak"po" target is added only if gettext binary is found. Without this patch, Make tried to build the target even with --enable-gettext=no configure option, which led to a failing build.
--- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Makefile +5 -1
@@ -46,7 +46,11 @@ HDR_SUBDIRS = include libxfs DLIB_SUBDIRS = libxlog libxcmd libhandle libdisk 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 + mdrestore repair rtcp m4 man doc debian + +ifneq ("$(XGETTEXT)","") +TOOL_SUBDIRS += po +endif # include is listed last so it is processed last in clean rules. SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS) include
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v2 2/4] xfsprogs: Don't Make .po files with gettext disabled
Quoted 6 lines · Jan Tulak
"po" target is added only if gettext binary is found. Without this patch, Make tried to build the target even with --enable-gettext=no configure option, which led to a failing build.
Signed-off-by Jan Tulak <[email protected]>
Looks good,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 3/4 xfsprogs: Use glibtoolize on osx
In reply to Jan TulakOS X doesn't have libtoolize binary by default, and the available$ ports are named "glibtoolize". Autodetect this issue.
--- Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
Makefile +11 -2
@@ -52,6 +52,14 @@ ifneq ("$(XGETTEXT)","") TOOL_SUBDIRS += po endif +# If we are on OS X, use glibtoolize from MacPorts, as OS X doesn't have +# libtoolize binary itself. +LIBTOOLIZE_TEST=$(shell libtoolize --version >/dev/null 2>&1 && echo found) +LIBTOOLIZE_BIN=libtoolize +ifneq ("$(LIBTOOLIZE_TEST)","found") +LIBTOOLIZE_BIN=glibtoolize +endif + # include is listed last so it is processed last in clean rules. SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS) include
@@ -85,13 +93,14 @@ else clean: # if configure hasn't run, nothing to clean endif + # Recent versions of libtool require the -i option for copying auxiliary # files (config.sub, config.guess, install-sh, ltmain.sh), while older # versions will copy those files anyway, and don't understand -i. -LIBTOOLIZE_INSTALL = `libtoolize -n -i >/dev/null 2>/dev/null && echo -i` +LIBTOOLIZE_INSTALL = `$(LIBTOOLIZE_BIN) -n -i >/dev/null 2>/dev/null && echo -i` configure: - libtoolize -c $(LIBTOOLIZE_INSTALL) -f + $(LIBTOOLIZE_BIN) -c $(LIBTOOLIZE_INSTALL) -f cp include/install-sh . aclocal -I m4 autoconf
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v2 3/4] xfsprogs: Use glibtoolize on osx
Quoted 4 lines · Jan Tulak
OS X doesn't have libtoolize binary by default, and the available$ ports are named "glibtoolize". Autodetect this issue.
Signed-off-by Jan Tulak <[email protected]>
Looks good,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 4/4 xfsprogs: OS X partial support
In reply to Jan TulakThis 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.
- xfs_repair currently has only a dummy timer implementation
- fsr and io, as tools working with a mounted XFS, are really not expected to work - lots of dummy functions
- 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. Fixing these looks like an ugly work, but fortunately, incompatible assignments are only in the tools not expected to work anyway (fsr and io).
--- configure.ac | 1 + fsr/xfs_fsr.c | 20 +++++- include/bitops.h | 2 + include/builddefs.in | 6 +- include/darwin.h | 168 ++++++++++++++++++++++++++++++++++++++++++++------ io/readdir.c | 4 ++ libdisk/fstype.c | 1 + libhandle/Makefile | 4 ++ libxcmd/paths.c | 2 +- m4/package_libcdev.m4 | 14 +++++ 10 files changed, 198 insertions(+), 24 deletions(-)
configure.ac +1 -0
@@ -113,6 +113,7 @@ AC_HAVE_PREADV AC_HAVE_SYNC_FILE_RANGE AC_HAVE_BLKID_TOPO($enable_blkid) AC_HAVE_READDIR +AC_HAVE_FLS AC_CHECK_SIZEOF([long]) AC_CHECK_SIZEOF([char *])
fsr/xfs_fsr.c +17 -3
@@ -25,16 +25,22 @@#include <fcntl.h> #include <errno.h> -#include <malloc.h> -#include <mntent.h> #include <syslog.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/wait.h> -#include <sys/vfs.h> #include <sys/statvfs.h> #include <sys/xattr.h> +#ifndef PLATFORM_HAS_NO_MALLOC_H +# include <malloc.h> +#endif +#ifndef PLATFORM_HAS_NO_MNTENT_H +# include <mntent.h> +#endif +#ifndef PLATFORM_HAS_NO_VFS_H +# include <sys/vfs.h> +#endif #ifndef XFS_XFLAG_NODEFRAG #define XFS_XFLAG_NODEFRAG 0x00002000/* src dependancy, remove later */
@@ -43,6 +49,14 @@#define _PATH_FSRLAST "/var/tmp/.fsrlast_xfs"#define _PATH_PROC_MOUNTS "/proc/mounts" +#ifdef USE_DUMMY_XATTR +/* OS X has fsetxattr with different number of arguments. +* Because it won't work anyway (no fstab/mtab and so on), +* hijack the call to a dummy function so it can at least +* compile. +*/ +# define fsetxattr (a,b,c,d,e) dummy_fsetxattr(a,b,c,d,e) +#endif char *progname;
include/bitops.h +2 -0
@@ -5,6 +5,7 @@* fls: find last bit set. */ +#ifndef HAVE_FLS static inline int fls (int x) {int r =32 ;
@@ -32,6 +33,7 @@ static inline int fls(int x) }return r; } +#endif /* HAVE_FLS */ static inline int fls64 (__u64 x) {
include/builddefs.in +5 -1
@@ -104,6 +104,7 @@ HAVE_FIEMAP = @have_fiemap@ HAVE_PREADV = @have_preadv@ HAVE_SYNC_FILE_RANGE = @have_sync_file_range@ HAVE_READDIR = @have_readdir@ +HAVE_FLS = @have_fls@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall # -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
@@ -119,7 +120,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)
@@ -131,6 +132,9 @@ PLDLIBS = -L/usr/local/lib -lintl PCFLAGS = -I/usr/local/include $(GCCFLAGS) DEPENDFLAGS = -D__FreeBSD__ endif +ifeq ($(HAVE_FLS),yes) +LCFLAGS+= -DHAVE_FLS +endif GCFLAGS = $(OPTIMIZER) $(DEBUG) \ -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\" \
include/darwin.h +149 -19
226 lines not on this page · raw message
io/readdir.c +4 -0
@@ -104,12 +104,16 @@ read_directory(if (!dirent)break ; +#ifdef _DIRENT_HAVE_D_RECLEN *total += dirent->d_reclen; +#endif count++;if (dump) {dump_dirent (offset, dirent); +#ifdef _DIRENT_HAVE_D_OFF offset = dirent->d_off; +#endif } }
libdisk/fstype.c +1 -0
@@ -22,6 +22,7 @@#include <stdlib.h> #include <string.h> #include <sys/stat.h> +#include <sys/types.h> #include "fstype.h" /*
libhandle/Makefile +4 -0
@@ -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
libxcmd/paths.c +1 -1
@@ -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 &&
m4/package_libcdev.m4 +14 -0
@@ -202,3 +202,17 @@ AC_DEFUN([AC_HAVE_READDIR], AC_SUBST(have_readdir) ]) +# +# Check if we have a flc call (Mac OS X) +# +AC_DEFUN([AC_HAVE_FLS], + [ AC_MSG_CHECKING([for fls]) + AC_TRY_LINK([ +#include <string.h> + ], [ + fls(0); + ], have_fls=yes + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no)) + AC_SUBST(have_fls) + ])
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v2 4/4] xfsprogs: OS X partial support
I think this needs to be split into one patch per issue. A few comments below:
Quoted 1 line
-#include <
malloc.h>
malloc and friends need to be in stdlib.h per Posix, so the right fix is to drop every include of malloc.h and mae sure we include stdlib.h where needed.
fsr/xfs_fsr.c line 34
Quoted 6 lines
fsr/xfs_fsr.c +0
-2-#include <mntent.h> #include <syslog.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/wait.h> -#include <sys/vfs.h>
sys/vfs.h is jsut an alias for sys/stafs.h, ut given that this file doesn't even use statfs we can simply drop the include unconditionally.
fsr/xfs_fsr.c line 40
Quoted 3 lines
fsr/xfs_fsr.c +3
-0+#ifndef PLATFORM_HAS_NO_MNTENT_H +# include <mntent.h> +#endif
Why aren't you using the standard autoconf-generate include checks?
io/readdir.c read_directory( · line 116
Quoted 10 lines
io/readdir.c +4
-0+#ifdef _DIRENT_HAVE_D_RECLEN *total += dirent->d_reclen; +#endif count++;if (dump) {dump_dirent (offset, dirent); +#ifdef _DIRENT_HAVE_D_OFF offset = dirent->d_off; +#endif
I'm pretty sure autoconf has a standard macro for this, try looking it up in the autoconf manual.
libxcmd/paths.c fs_table_initialise_mounts( · line 367
Quoted 10 lines
libxcmd/paths.c +1
-1@@ -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))
I don't understand this change.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v2 4/4] xfsprogs: OS X partial support
----- Original Message -----
Quoted 8 lines
From: "Christoph Hellwig" <[email protected]>
To: "Jan Tulak" <[email protected]>
Cc: [email protected]
Sent: Sunday, July 26, 2015 6:34:38 PM
Subject: Re: [PATCH v2 4/4] xfsprogs: OS X partial supportI think this needs to be split into one patch per issue. A few comments below:
Sure, I guess it is a good idea.
Quoted 8 lines
Quoted 2 lines
-#include <
malloc.h>malloc and friends need to be in
stdlib.hper Posix, so the right fix is to drop every include ofmalloc.hand mae sure we includestdlib.hwhere needed.
stdlib.h contains posix_memalign(), but the code is using memalign(). So should I prefix the calls?
Regarding the autoconf related issues, I'm looking on it, though it can take me some time. I can't say I love the way autoconf is done... :)
[ snip autoconf related issues ]
Quoted 13 lines
libxcmd/paths.c fs_table_initialise_mounts( · line 367
Quoted 11 lines
libxcmd/paths.c +1
-1@@ -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))I don't understand this change.
Typo fix, which wasn't catched earlier due to #ifdef branching. The 'rmnttomname' does not exists anywhere and looks like a hybrid between rmntfromname and rmntonname. And because the previous if has has 'fromname' on both arguments of realpath, I choose the same approach when fixing it.
I'm making it a standalone patch too, though.
Cheers,
Jan
Signature · 7 lines
Jan Tulak [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs