public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/11] xfsprogs: OS X partial support
@ 2015-08-03 14:39 Jan Tulak
  2015-08-03 14:39 ` [PATCH v2 01/11] xfsprogs: Don't Make .po files with gettext disabled Jan Tulak
                   ` (10 more replies)
  0 siblings, 11 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-03 14:39 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Hi folks.

All right, this is a third iteration of fixing the out-of-date
OS X code in xfsprogs (4 years since the last touch).

Against v2, I made these changes:

- Patch 4/4 was broken to 8 smaller patches
- Issues in that patch were addressed
- Greatly enhanced commit message about LIST_ macros renaming

The last point is still open and may change, so I moved it
into the last commit. First two commits were already reviewed,
but I include them to keep their trace in this new numbering of
the patchset.

Cheers,
Jan

Jan Tulak (11):
  xfsprogs: Don't Make .po files with gettext disabled
  xfsprogs: Use glibtoolize on osx
  xfsprogs: undefined variable fix
  xfsprogs: Add ifdef dirent checks where it was missing
  xfsprogs: Change OS X-specific CFLAGS/LDFLAGS
  xfsprogs: Add includes required for OS X builds
  xfsprogs: missing and dummy calls for OS X support
  xfsprogs: Add fls check into autoconf
  xfsprogs: Add mntent.h check into autoconf
  xfsprogs: replace obsolete memalign with posix_memalign
  xfsprogs: Prefix LIST_... macros to XFS_LIST_...

 Makefile              |  19 +++++-
 configure.ac          |   2 +
 copy/xfs_copy.c       |   2 +-
 db/attrset.c          |   2 +-
 fsr/xfs_fsr.c         |  17 ++++--
 include/bitops.h      |   2 +
 include/builddefs.in  |  10 +++-
 include/darwin.h      | 159 ++++++++++++++++++++++++++++++++++++++++++++------
 include/freebsd.h     |   1 -
 include/gnukfreebsd.h |   1 -
 include/linux.h       |   1 -
 include/list.h        |   6 +-
 io/pread.c            |   4 +-
 io/readdir.c          |   4 ++
 libdisk/fstype.c      |   1 +
 libhandle/Makefile    |   4 ++
 libxcmd/paths.c       |   2 +-
 libxfs/rdwr.c         |  19 ++++--
 m4/package_libcdev.m4 |  26 +++++++++
 mkfs/xfs_mkfs.c       |   6 +-
 repair/incore.c       |   2 +-
 repair/incore_ino.c   |  13 ++++-
 repair/phase1.c       |   2 +-
 repair/phase6.c       |   2 +-
 repair/prefetch.c     |   7 +--
 repair/sb.c           |  10 ++--
 rtcp/xfs_rtcp.c       |   7 ++-
 27 files changed, 274 insertions(+), 57 deletions(-)

-- 
2.4.3

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

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

* [PATCH v2 01/11] xfsprogs: Don't Make .po files with gettext disabled
  2015-08-03 14:39 [PATCH v3 00/11] xfsprogs: OS X partial support Jan Tulak
@ 2015-08-03 14:39 ` Jan Tulak
  2015-08-03 14:39 ` [PATCH v2 02/11] xfsprogs: Use glibtoolize on osx Jan Tulak
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-03 14:39 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

(Already reviewed by Chris, but resubmiting
as the patchset itself was partially reworked.)

"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 <jtulak@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 Makefile | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 6d6803b..3da4d5d 100644
--- a/Makefile
+++ b/Makefile
@@ -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
-- 
2.4.3

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

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

* [PATCH v2 02/11] xfsprogs: Use glibtoolize on osx
  2015-08-03 14:39 [PATCH v3 00/11] xfsprogs: OS X partial support Jan Tulak
  2015-08-03 14:39 ` [PATCH v2 01/11] xfsprogs: Don't Make .po files with gettext disabled Jan Tulak
@ 2015-08-03 14:39 ` Jan Tulak
  2015-08-03 14:39 ` [PATCH v3 03/11] xfsprogs: undefined variable fix Jan Tulak
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-03 14:39 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

(Already reviewed by Chris, but resubmiting
as the patchset itself was partially reworked.)

OS X doesn't have libtoolize binary by default, and the available$
ports are named "glibtoolize". Autodetect this issue.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 Makefile | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 3da4d5d..4abaaac 100644
--- a/Makefile
+++ b/Makefile
@@ -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
-- 
2.4.3

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

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

* [PATCH v3 03/11] xfsprogs: undefined variable fix
  2015-08-03 14:39 [PATCH v3 00/11] xfsprogs: OS X partial support Jan Tulak
  2015-08-03 14:39 ` [PATCH v2 01/11] xfsprogs: Don't Make .po files with gettext disabled Jan Tulak
  2015-08-03 14:39 ` [PATCH v2 02/11] xfsprogs: Use glibtoolize on osx Jan Tulak
@ 2015-08-03 14:39 ` Jan Tulak
  2015-08-04  8:41   ` Christoph Hellwig
  2015-08-03 14:39 ` [PATCH v3 04/11] xfsprogs: Add ifdef dirent checks where it was missing Jan Tulak
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Tulak @ 2015-08-03 14:39 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Typo fix, which wasn't catch 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.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 libxcmd/paths.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 &&
-- 
2.4.3

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

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

* [PATCH v3 04/11] xfsprogs: Add ifdef dirent checks where it was missing
  2015-08-03 14:39 [PATCH v3 00/11] xfsprogs: OS X partial support Jan Tulak
                   ` (2 preceding siblings ...)
  2015-08-03 14:39 ` [PATCH v3 03/11] xfsprogs: undefined variable fix Jan Tulak
@ 2015-08-03 14:39 ` Jan Tulak
  2015-08-04  8:46   ` Christoph Hellwig
  2015-08-04  9:25   ` [PATCH v4 " Jan Tulak
  2015-08-03 14:39 ` [PATCH v3 05/11] xfsprogs: Change OS X-specific CFLAGS/LDFLAGS Jan Tulak
                   ` (6 subsequent siblings)
  10 siblings, 2 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-03 14:39 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Add check for _DIRENT_HAVED_RECLEN/_OFF to read_directory().
In dump_dirent() these checks already are used, but they were
missing in read_directory.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 io/readdir.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/io/readdir.c b/io/readdir.c
index 20b8898..ed8f04d 100644
--- a/io/readdir.c
+++ b/io/readdir.c
@@ -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
 		}
 	}
 
-- 
2.4.3

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

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

* [PATCH v3 05/11] xfsprogs: Change OS X-specific CFLAGS/LDFLAGS
  2015-08-03 14:39 [PATCH v3 00/11] xfsprogs: OS X partial support Jan Tulak
                   ` (3 preceding siblings ...)
  2015-08-03 14:39 ` [PATCH v3 04/11] xfsprogs: Add ifdef dirent checks where it was missing Jan Tulak
@ 2015-08-03 14:39 ` Jan Tulak
  2015-08-04 11:17   ` Christoph Hellwig
  2015-08-03 14:39 ` [PATCH v3 06/11] xfsprogs: Add includes required for OS X builds Jan Tulak
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Tulak @ 2015-08-03 14:39 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

OS X uses clang as a default compiler.
So remove incompatible options.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 include/builddefs.in | 2 +-
 libhandle/Makefile   | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

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/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
-- 
2.4.3

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

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

* [PATCH v3 06/11] xfsprogs: Add includes required for OS X builds
  2015-08-03 14:39 [PATCH v3 00/11] xfsprogs: OS X partial support Jan Tulak
                   ` (4 preceding siblings ...)
  2015-08-03 14:39 ` [PATCH v3 05/11] xfsprogs: Change OS X-specific CFLAGS/LDFLAGS Jan Tulak
@ 2015-08-03 14:39 ` Jan Tulak
  2015-08-04 11:18   ` Christoph Hellwig
  2015-08-03 14:39 ` [PATCH v3 07/11] xfsprogs: missing and dummy calls for OS X support Jan Tulak
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Tulak @ 2015-08-03 14:39 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 include/darwin.h | 5 +++++
 libdisk/fstype.c | 1 +
 2 files changed, 6 insertions(+)

diff --git a/include/darwin.h b/include/darwin.h
index 30f0052..2b470b4 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -24,6 +24,11 @@
 #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 <stdio.h>
 
 #include <machine/endian.h>
 #define __BYTE_ORDER	BYTE_ORDER
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"
 
 /*
-- 
2.4.3

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

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

* [PATCH v3 07/11] xfsprogs: missing and dummy calls for OS X support
  2015-08-03 14:39 [PATCH v3 00/11] xfsprogs: OS X partial support Jan Tulak
                   ` (5 preceding siblings ...)
  2015-08-03 14:39 ` [PATCH v3 06/11] xfsprogs: Add includes required for OS X builds Jan Tulak
@ 2015-08-03 14:39 ` Jan Tulak
  2015-08-03 14:39 ` [PATCH v3 08/11] xfsprogs: Add fls check into autoconf Jan Tulak
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-03 14:39 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Add and update various API, macros and types where is some change
in OS X or xfsprogs. Most changes are in darwin.h.

Add dummy implementations where native support is nonexistent
and the tools are not expected to work anyway, so all tools can be
at least compiled.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 fsr/xfs_fsr.c    |   8 +++
 include/darwin.h | 153 +++++++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 145 insertions(+), 16 deletions(-)

diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index efc17a8..d8a4ece 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -43,6 +43,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;
 
diff --git a/include/darwin.h b/include/darwin.h
index 2b470b4..caec897 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -73,45 +73,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
@@ -147,11 +139,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
@@ -160,4 +154,131 @@ 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;
+}
+
+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);
+}
+
+#define MREMAP_FIXED 1
+#define MREMAP_MAYMOVE 2
+static inline void *mremap(void *old_address, size_t old_size,
+                    size_t new_size, int flags, ... /* void *new_address */)
+{
+	return NULL;
+}
+
+/* FSR */
+
+#define		_PATH_MOUNTED   "/etc/mtab"
+#define		USE_DUMMY_XATTR
+
+typedef int __fsblkcnt_t;
+typedef int __fsfilcnt_t;
+typedef long long int __fsblkcnt64_t;
+typedef long long int __fsfilcnt64_t;
+
+struct statvfs64
+{
+	unsigned long int f_bsize;
+	unsigned long int f_frsize;
+	__fsblkcnt64_t f_blocks;
+	__fsblkcnt64_t f_bfree;
+	__fsblkcnt64_t f_bavail;
+	__fsfilcnt64_t f_files;
+	__fsfilcnt64_t f_ffree;
+	__fsfilcnt64_t f_favail;
+	unsigned long int f_fsid;
+	int __f_unused;
+	unsigned long int f_flag;
+	unsigned long int f_namemax;
+	int __f_spare[6];
+};
+
+struct mntent
+{
+	char *mnt_fsname;		/* Device or server for filesystem.  */
+	char *mnt_dir;		/* Directory mounted on.  */
+	char *mnt_type;		/* Type of filesystem: ufs, nfs, etc.  */
+	char *mnt_opts;		/* Comma-separated options for fs.  */
+	int mnt_freq;		/* Dump frequency (in days).  */
+	int mnt_passno;		/* Pass number for `fsck'.  */
+};
+
+static inline FILE *setmntent(const char *filename, const char *type)
+{
+	return NULL;
+}
+
+static inline int endmntent(FILE *fp)
+{
+	return 0;
+}
+
+static inline struct mntent *getmntent(FILE *fp)
+{
+	return NULL;
+}
+
+static inline int addmntent(FILE *fp, const struct mntent *mnt)
+{
+	return 0;
+}
+
+static inline char *hasmntopt(const struct mntent *mnt, const char *opt)
+{
+	return NULL;
+}
+
+static inline int statvfs64 (const char *__restrict __file, 
+							 struct statvfs64 *__restrict __buf)
+{
+	return 0;
+}
+
+static inline int dummy_fsetxattr (int filedes, const char *name,
+                       const void *value, size_t size, int flags)
+{
+	return 0;
+}
+
+
 #endif	/* __XFS_DARWIN_H__ */
-- 
2.4.3

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

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

* [PATCH v3 08/11] xfsprogs: Add fls check into autoconf
  2015-08-03 14:39 [PATCH v3 00/11] xfsprogs: OS X partial support Jan Tulak
                   ` (6 preceding siblings ...)
  2015-08-03 14:39 ` [PATCH v3 07/11] xfsprogs: missing and dummy calls for OS X support Jan Tulak
@ 2015-08-03 14:39 ` Jan Tulak
  2015-08-04 11:21   ` Christoph Hellwig
  2015-08-03 14:39 ` [PATCH v3 09/11] xfsprogs: Add mntent.h " Jan Tulak
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Tulak @ 2015-08-03 14:39 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Add a check for fls call, and a replacement call
for platforms without fls.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 configure.ac          |  1 +
 include/bitops.h      |  2 ++
 include/builddefs.in  |  4 ++++
 m4/package_libcdev.m4 | 14 ++++++++++++++
 4 files changed, 21 insertions(+)

diff --git a/configure.ac b/configure.ac
index fe991cc..8f966a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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 *])
diff --git a/include/bitops.h b/include/bitops.h
index 930f64a..44599a7 100644
--- a/include/bitops.h
+++ b/include/bitops.h
@@ -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)
 {
diff --git a/include/builddefs.in b/include/builddefs.in
index 7f939f6..9feb096 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -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
@@ -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)\"  \
diff --git a/m4/package_libcdev.m4 b/m4/package_libcdev.m4
index 919ae0a..d7f37ca 100644
--- a/m4/package_libcdev.m4
+++ b/m4/package_libcdev.m4
@@ -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)
+  ])
-- 
2.4.3

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

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

* [PATCH v3 09/11] xfsprogs: Add mntent.h check into autoconf
  2015-08-03 14:39 [PATCH v3 00/11] xfsprogs: OS X partial support Jan Tulak
                   ` (7 preceding siblings ...)
  2015-08-03 14:39 ` [PATCH v3 08/11] xfsprogs: Add fls check into autoconf Jan Tulak
@ 2015-08-03 14:39 ` Jan Tulak
  2015-08-04 11:21   ` Christoph Hellwig
  2015-08-03 14:39 ` [PATCH v3 10/11] xfsprogs: replace obsolete memalign with posix_memalign Jan Tulak
  2015-08-03 14:39 ` [PATCH v2 11/11] xfsprogs: Prefix LIST_... macros to XFS_LIST_ Jan Tulak
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Tulak @ 2015-08-03 14:39 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 configure.ac          |  1 +
 fsr/xfs_fsr.c         |  6 +++---
 include/builddefs.in  |  4 ++++
 m4/package_libcdev.m4 | 12 ++++++++++++
 4 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8f966a6..e2d395b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,6 +113,7 @@ AC_HAVE_PREADV
 AC_HAVE_SYNC_FILE_RANGE
 AC_HAVE_BLKID_TOPO($enable_blkid)
 AC_HAVE_READDIR
+AC_HAVE_MNTENT
 AC_HAVE_FLS
 
 AC_CHECK_SIZEOF([long])
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index d8a4ece..12eb172 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -25,16 +25,16 @@
 
 #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>
 
+#ifdef HAVE_MNTENT
+#  include <mntent.h>
+#endif
 
 #ifndef XFS_XFLAG_NODEFRAG
 #define XFS_XFLAG_NODEFRAG 0x00002000 /* src dependancy, remove later */
diff --git a/include/builddefs.in b/include/builddefs.in
index 9feb096..1132f26 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -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_MNTENT = @have_mntent@
 HAVE_FLS = @have_fls@
 
 GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall 
@@ -135,6 +136,9 @@ endif
 ifeq ($(HAVE_FLS),yes)
 LCFLAGS+= -DHAVE_FLS
 endif
+ifeq ($(HAVE_MNTENT),yes)
+PCFLAGS+= -DHAVE_MNTENT
+endif
 
 GCFLAGS = $(OPTIMIZER) $(DEBUG) \
 	  -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\"  \
diff --git a/m4/package_libcdev.m4 b/m4/package_libcdev.m4
index d7f37ca..bb7bcdb 100644
--- a/m4/package_libcdev.m4
+++ b/m4/package_libcdev.m4
@@ -216,3 +216,15 @@ AC_DEFUN([AC_HAVE_FLS],
        AC_MSG_RESULT(no))
     AC_SUBST(have_fls)
   ])
+
+#
+# Check if there is mntent.h
+#
+AC_DEFUN([AC_HAVE_MNTENT],
+  [ AC_MSG_CHECKING([for mntent])
+    AC_CHECK_HEADERS(mntent.h,
+    have_mntent=yes
+    AC_MSG_RESULT(yes),
+    AC_MSG_RESULT(no))
+    AC_SUBST(have_mntent)
+  ])
-- 
2.4.3

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

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

* [PATCH v3 10/11] xfsprogs: replace obsolete memalign with posix_memalign
  2015-08-03 14:39 [PATCH v3 00/11] xfsprogs: OS X partial support Jan Tulak
                   ` (8 preceding siblings ...)
  2015-08-03 14:39 ` [PATCH v3 09/11] xfsprogs: Add mntent.h " Jan Tulak
@ 2015-08-03 14:39 ` Jan Tulak
  2015-08-05 22:57   ` Dave Chinner
  2015-08-03 14:39 ` [PATCH v2 11/11] xfsprogs: Prefix LIST_... macros to XFS_LIST_ Jan Tulak
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Tulak @ 2015-08-03 14:39 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Memalign from <malloc.h> was marked obsolete in favor of a posix
variant from <stdlib.h>. So replace all calls and remove <malloc.h>
includes. This also enhances support on other posix platforms,
which doesn't have <malloc.h>.

Because posix_memalign returns any error as a return code, not in
errno, change relevant checks in code (and add a missing one).

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 copy/xfs_copy.c       |  2 +-
 db/attrset.c          |  2 +-
 fsr/xfs_fsr.c         |  3 ++-
 include/darwin.h      |  1 -
 include/freebsd.h     |  1 -
 include/gnukfreebsd.h |  1 -
 include/linux.h       |  1 -
 io/pread.c            |  4 ++--
 libxfs/rdwr.c         | 19 +++++++++++++++----
 mkfs/xfs_mkfs.c       |  6 +++++-
 repair/incore.c       |  2 +-
 repair/incore_ino.c   | 13 ++++++++++---
 repair/phase1.c       |  2 +-
 repair/prefetch.c     |  7 +++----
 repair/sb.c           | 10 +++++-----
 rtcp/xfs_rtcp.c       |  7 ++++++-
 16 files changed, 52 insertions(+), 29 deletions(-)

diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
index 44a32e8..5badd74 100644
--- a/copy/xfs_copy.c
+++ b/copy/xfs_copy.c
@@ -332,7 +332,7 @@ wbuf *
 wbuf_init(wbuf *buf, int data_size, int data_align, int min_io_size, int id)
 {
 	ASSERT(data_size % BBSIZE == 0);
-	while ((buf->data = memalign(data_align, data_size)) == NULL) {
+	while (posix_memalign((void**)&(buf->data), data_align, data_size)) {
 		data_size >>= 1;
 		if (data_size < min_io_size)
 			return NULL;
diff --git a/db/attrset.c b/db/attrset.c
index 1afadd2..3e293be 100644
--- a/db/attrset.c
+++ b/db/attrset.c
@@ -141,7 +141,7 @@ attr_set_f(
 	name = argv[optind];
 
 	if (valuelen) {
-		value = (char *)memalign(getpagesize(), valuelen);
+		posix_memalign((void**)&value, getpagesize(), valuelen);
 		if (!value) {
 			dbprintf(_("cannot allocate buffer (%d)\n"), valuelen);
 			goto out;
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index 12eb172..44626ba 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -1306,7 +1306,8 @@ packfile(char *fname, char *tname, int fd,
 			dio.d_maxiosz, pagesize);
 	}
 
-	if (!(fbuf = (char *)memalign(dio.d_mem, blksz_dio))) {
+	posix_memalign((void **)&fbuf, dio.d_mem, blksz_dio);
+	if (!fbuf) {
 		fsrprintf(_("could not allocate buf: %s\n"), tname);
 		goto out;
 	}
diff --git a/include/darwin.h b/include/darwin.h
index caec897..34264f9 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -129,7 +129,6 @@ typedef int64_t		xfs_daddr_t;
 #define pwrite64	pwrite
 #define ftruncate64	ftruncate
 #define fdatasync	fsync
-#define memalign(a,sz)	valloc(sz)
 
 #define O_LARGEFILE     0
 #ifndef O_DIRECT
diff --git a/include/freebsd.h b/include/freebsd.h
index e59b1e8..b4051ea 100644
--- a/include/freebsd.h
+++ b/include/freebsd.h
@@ -40,7 +40,6 @@
 #define pwrite64	pwrite
 #define pread64		pread
 #define fdatasync	fsync
-#define memalign(a,sz)	valloc(sz)
 
 #define constpp	char * const *
 
diff --git a/include/gnukfreebsd.h b/include/gnukfreebsd.h
index f2e1bf5..f9c0c15 100644
--- a/include/gnukfreebsd.h
+++ b/include/gnukfreebsd.h
@@ -22,7 +22,6 @@
 #include <sys/vfs.h>
 #include <sys/ioctl.h>
 #include <sys/sysmacros.h>
-#include <malloc.h>
 #include <getopt.h>
 #include <endian.h>
 #include <sys/stat.h>
diff --git a/include/linux.h b/include/linux.h
index 31c077a..2abda79 100644
--- a/include/linux.h
+++ b/include/linux.h
@@ -24,7 +24,6 @@
 #include <sys/sysmacros.h>
 #include <sys/stat.h>
 #include <inttypes.h>
-#include <malloc.h>
 #include <getopt.h>
 #include <endian.h>
 #include <stdbool.h>
diff --git a/io/pread.c b/io/pread.c
index 280cc9d..2dd5b7a 100644
--- a/io/pread.c
+++ b/io/pread.c
@@ -78,7 +78,7 @@ alloc_iovec(
 
 	buffersize = 0;
 	for (i = 0; i < vectors; i++) {
-		iov[i].iov_base = memalign(pagesize, bsize);
+		posix_memalign((void**)&(iov[i].iov_base), pagesize, bsize);
 		if (!iov[i].iov_base) {
 			perror("memalign");
 			goto unwind;
@@ -109,7 +109,7 @@ alloc_buffer(
 	if (bsize > highwater) {
 		if (buffer)
 			free(buffer);
-		buffer = memalign(pagesize, bsize);
+		posix_memalign((void**)&buffer, pagesize, bsize);
 		if (!buffer) {
 			perror("memalign");
 			highwater = buffersize = 0;
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index 4e0c75b..d75bf1c 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -74,12 +74,18 @@ libxfs_device_zero(struct xfs_buftarg *btp, xfs_daddr_t start, uint len)
 	ssize_t		zsize, bytes;
 	char		*z;
 	int		fd;
+	int ret;
 
 	zsize = min(BDSTRAT_SIZE, BBTOB(len));
-	if ((z = memalign(libxfs_device_alignment(), zsize)) == NULL) {
+	ret = posix_memalign(
+						(void **)&z,
+						libxfs_device_alignment(),
+						zsize
+					);
+	if (!z) {
 		fprintf(stderr,
 			_("%s: %s can't memalign %d bytes: %s\n"),
-			progname, __FUNCTION__, (int)zsize, strerror(errno));
+			progname, __FUNCTION__, (int)zsize, strerror(ret));
 		exit(1);
 	}
 	memset(z, 0, zsize);
@@ -409,6 +415,7 @@ static void
 __initbuf(xfs_buf_t *bp, struct xfs_buftarg *btp, xfs_daddr_t bno,
 		unsigned int bytes)
 {
+	int ret;
 	bp->b_flags = 0;
 	bp->b_bn = bno;
 	bp->b_bcount = bytes;
@@ -416,12 +423,16 @@ __initbuf(xfs_buf_t *bp, struct xfs_buftarg *btp, xfs_daddr_t bno,
 	bp->b_target = btp;
 	bp->b_error = 0;
 	if (!bp->b_addr)
-		bp->b_addr = memalign(libxfs_device_alignment(), bytes);
+		ret = posix_memalign(
+							(void**)&(bp->b_addr),
+							libxfs_device_alignment(),
+							bytes
+						);
 	if (!bp->b_addr) {
 		fprintf(stderr,
 			_("%s: %s can't memalign %u bytes: %s\n"),
 			progname, __FUNCTION__, bytes,
-			strerror(errno));
+			strerror(ret));
 		exit(1);
 	}
 	memset(bp->b_addr, 0, bytes);
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 11e9f4b..a0273f7 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -856,7 +856,11 @@ zero_old_xfs_structures(
 	 * read in existing filesystem superblock, use its geometry
 	 * settings and zero the existing secondary superblocks.
 	 */
-	buf = memalign(libxfs_device_alignment(), new_sb->sb_sectsize);
+	posix_memalign(
+				(void**)&buf,
+				libxfs_device_alignment(),
+				new_sb->sb_sectsize
+			);
 	if (!buf) {
 		fprintf(stderr,
 	_("error reading existing superblock -- failed to memalign buffer\n"));
diff --git a/repair/incore.c b/repair/incore.c
index d5ecfd6..57cbeb6 100644
--- a/repair/incore.c
+++ b/repair/incore.c
@@ -224,7 +224,7 @@ init_rt_bmap(
 	rt_bmap_size = roundup(mp->m_sb.sb_rextents / (NBBY / XR_BB),
 			       sizeof(__uint64_t));
 
-	rt_bmap = memalign(sizeof(__uint64_t), rt_bmap_size);
+	posix_memalign((void**)&rt_bmap, sizeof(__uint64_t), rt_bmap_size);
 	if (!rt_bmap) {
 		do_error(
 	_("couldn't allocate realtime block map, size = %" PRIu64 "\n"),
diff --git a/repair/incore_ino.c b/repair/incore_ino.c
index 7e19657..71d6d4c 100644
--- a/repair/incore_ino.c
+++ b/repair/incore_ino.c
@@ -626,8 +626,11 @@ set_inode_parent(
 			irec->ino_un.plist = ptbl;
 
 		ptbl->pmask = 1LL << offset;
-		ptbl->pentries = (xfs_ino_t*)memalign(sizeof(xfs_ino_t),
-							sizeof(xfs_ino_t));
+		posix_memalign(
+					(void**)&(ptbl->pentries),
+					sizeof(xfs_ino_t),
+					sizeof(xfs_ino_t)
+				);
 		if (!ptbl->pentries)
 			do_error(_("couldn't memalign pentries table\n"));
 #ifdef DEBUG
@@ -673,7 +676,11 @@ set_inode_parent(
 #endif
 	ASSERT(cnt >= target);
 
-	tmp = (xfs_ino_t*)memalign(sizeof(xfs_ino_t), (cnt + 1) * sizeof(xfs_ino_t));
+	posix_memalign(
+				(void**)&tmp,
+				sizeof(xfs_ino_t), 
+				(cnt + 1) * sizeof(xfs_ino_t)
+			);
 	if (!tmp)
 		do_error(_("couldn't memalign pentries table\n"));
 
diff --git a/repair/phase1.c b/repair/phase1.c
index bd9adcb..20d7b24 100644
--- a/repair/phase1.c
+++ b/repair/phase1.c
@@ -35,7 +35,7 @@ alloc_ag_buf(int size)
 {
 	char	*bp;
 
-	bp = (char *)memalign(libxfs_device_alignment(), size);
+	posix_memalign((void**)&bp, libxfs_device_alignment(), size);
 	if (!bp)
 		do_error(_("could not allocate ag header buffer (%d bytes)\n"),
 			size);
diff --git a/repair/prefetch.c b/repair/prefetch.c
index 08c0394..2843042 100644
--- a/repair/prefetch.c
+++ b/repair/prefetch.c
@@ -631,10 +631,9 @@ pf_io_worker(
 	void			*param)
 {
 	prefetch_args_t		*args = param;
-	void			*buf = memalign(libxfs_device_alignment(),
-						pf_max_bytes);
-
-	if (buf == NULL)
+	void			*buf;
+	posix_memalign((void**)&buf, libxfs_device_alignment(), pf_max_bytes);
+	if (!buf)
 		return NULL;
 
 	pthread_mutex_lock(&args->lock);
diff --git a/repair/sb.c b/repair/sb.c
index f6a1f15..f2e32aa 100644
--- a/repair/sb.c
+++ b/repair/sb.c
@@ -102,7 +102,7 @@ find_secondary_sb(xfs_sb_t *rsb)
 
 	do_warn(_("\nattempting to find secondary superblock...\n"));
 
-	sb = (xfs_sb_t *)memalign(libxfs_device_alignment(), BSIZE);
+	posix_memalign((void**)&sb, libxfs_device_alignment(), BSIZE);
 	if (!sb) {
 		do_error(
 	_("error finding secondary superblock -- failed to memalign buffer\n"));
@@ -438,8 +438,8 @@ write_primary_sb(xfs_sb_t *sbp, int size)
 	if (no_modify)
 		return;
 
-	buf = memalign(libxfs_device_alignment(), size);
-	if (buf == NULL) {
+	posix_memalign((void**)&buf, libxfs_device_alignment(), size);
+	if (!buf) {
 		do_error(_("failed to memalign superblock buffer\n"));
 		return;
 	}
@@ -472,8 +472,8 @@ get_sb(xfs_sb_t *sbp, xfs_off_t off, int size, xfs_agnumber_t agno)
 	int error, rval;
 	xfs_dsb_t *buf;
 
-	buf = memalign(libxfs_device_alignment(), size);
-	if (buf == NULL) {
+	posix_memalign((void**)&buf, libxfs_device_alignment(), size);
+	if (!buf) {
 		do_error(
 	_("error reading superblock %u -- failed to memalign buffer\n"),
 			agno);
diff --git a/rtcp/xfs_rtcp.c b/rtcp/xfs_rtcp.c
index 7f48060..417b066 100644
--- a/rtcp/xfs_rtcp.c
+++ b/rtcp/xfs_rtcp.c
@@ -327,7 +327,12 @@ rtcp( char *source, char *target, int fextsize)
 	}
 
 	iosz =  dioattr.d_miniosz;
-	fbuf = memalign( dioattr.d_mem, iosz);
+	posix_memalign((void**)&fbuf, dioattr.d_mem, iosz);
+	if (!fbuf) {
+		perror(
+	_("error finding secondary superblock -- failed to memalign buffer\n"));
+		exit(1);
+	}
 	memset(fbuf, 0, iosz);
 
 	/*
-- 
2.4.3

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

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

* [PATCH v2 11/11] xfsprogs: Prefix LIST_... macros to XFS_LIST_...
  2015-08-03 14:39 [PATCH v3 00/11] xfsprogs: OS X partial support Jan Tulak
                   ` (9 preceding siblings ...)
  2015-08-03 14:39 ` [PATCH v3 10/11] xfsprogs: replace obsolete memalign with posix_memalign Jan Tulak
@ 2015-08-03 14:39 ` Jan Tulak
  2015-08-04  9:01   ` [PATCH v4 11/11] xfsprogs: prevent LIST_ macros conflicts Jan Tulak
  10 siblings, 1 reply; 36+ messages in thread
From: Jan Tulak @ 2015-08-03 14:39 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

OS X has two conflicting LIST_ macros:
  - LIST_HEAD
  - LIST_HEAD_INIT

These results in tons of warnings like:

In file included from init.c:22:
In file included from ./libxfs_priv.h:63:
../include/xfs/list.h:32:9: warning: 'LIST_HEAD' macro redefined
[-Wmacro-redefined]
\#define LIST_HEAD(name) \

These macros are included from sys/queue.h through
sys/mount.h and possibly through more system libraries.
So far, I didn't found a way how to prevent the inclusion.

Attempted solution was to avoid including with
-D_SYS_QUEUE_H_ for the compiler, but this resulted in
another error:

In file included from crc32.c:36:
In file included from ../include/xfs/platform_defs.h:79:
In file included from ../include/xfs/darwin.h:26:
In file included from /usr/include/sys/mount.h:76:
In file included from /usr/include/sys/attr.h:42:
/usr/include/sys/ucred.h:90:2: error: type name requires a specifier or
qualifier
TAILQ_ENTRY(ucred)      cr_link; /* never modify this without KAUTH_CRE...

I tried renaming. This works, but it doesn't look like
a good solution. So this patch is still not final.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 include/list.h  | 6 +++---
 repair/phase6.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/list.h b/include/list.h
index 3f087a4..7e9f748 100644
--- a/include/list.h
+++ b/include/list.h
@@ -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)
diff --git a/repair/phase6.c b/repair/phase6.c
index 9a5cba7..87732e1 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
-- 
2.4.3

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

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

* Re: [PATCH v3 03/11] xfsprogs: undefined variable fix
  2015-08-03 14:39 ` [PATCH v3 03/11] xfsprogs: undefined variable fix Jan Tulak
@ 2015-08-04  8:41   ` Christoph Hellwig
  0 siblings, 0 replies; 36+ messages in thread
From: Christoph Hellwig @ 2015-08-04  8:41 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

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

* Re: [PATCH v3 04/11] xfsprogs: Add ifdef dirent checks where it was missing
  2015-08-03 14:39 ` [PATCH v3 04/11] xfsprogs: Add ifdef dirent checks where it was missing Jan Tulak
@ 2015-08-04  8:46   ` Christoph Hellwig
  2015-08-04  9:21     ` Jan Tulak
  2015-08-04  9:25   ` [PATCH v4 " Jan Tulak
  1 sibling, 1 reply; 36+ messages in thread
From: Christoph Hellwig @ 2015-08-04  8:46 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

> diff --git a/io/readdir.c b/io/readdir.c
> index 20b8898..ed8f04d 100644
> --- a/io/readdir.c
> +++ b/io/readdir.c
> @@ -104,12 +104,16 @@ read_directory(
>  		if (!dirent)
>  			break;
>  
> +#ifdef _DIRENT_HAVE_D_RECLEN
>  		*total += dirent->d_reclen;
> +#endif

You probably want to use d_namen + sizeof(*dirent) to approimate
the value if d_reclen doesn't exist.

>  		count++;
>  
>  		if (dump) {
>  			dump_dirent(offset, dirent);
> +#ifdef _DIRENT_HAVE_D_OFF
>  			offset = dirent->d_off;
> +#endif

We're only using the offset for dumping the value, maybe setting
it to 0 and adding a comment explaining it should go into the else
branch here?

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

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

* [PATCH v4 11/11] xfsprogs: prevent LIST_ macros conflicts
  2015-08-03 14:39 ` [PATCH v2 11/11] xfsprogs: Prefix LIST_... macros to XFS_LIST_ Jan Tulak
@ 2015-08-04  9:01   ` Jan Tulak
  2015-08-04 11:22     ` Christoph Hellwig
  0 siblings, 1 reply; 36+ messages in thread
From: Jan Tulak @ 2015-08-04  9:01 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

BSD 4.4 added some LIST_ macros into system header files, which
causes "macro redefined" warnings. To ensure we use our own macros,
undefine the system ones at first.

The conflicting macros are LIST_HEAD and LIST_HEAD_INIT

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 include/list.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/include/list.h b/include/list.h
index 3f087a4..f92faed 100644
--- a/include/list.h
+++ b/include/list.h
@@ -19,6 +19,20 @@
 #define __LIST_H__
 
 /*
+ * This undef is here because BSD 4.4 added some LIST_ macros into system
+ * header file sys/queue.h. This header is included in many other system
+ * headers and thus causes "macro redefined" warnings.
+ *
+ * As OS X is kind of a derivate of BSD, this affects OS X too.
+ *
+ * To use our own LIST_ macros (copied from kernel code), we have to
+ * at first undefine the conflicting system macros.
+ *
+ */
+#undef LIST_HEAD
+#undef LIST_HEAD_INIT
+
+/*
  * Simple, generic doubly-linked list implementation.
  */
 
-- 
2.4.3

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

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

* Re: [PATCH v3 04/11] xfsprogs: Add ifdef dirent checks where it was missing
  2015-08-04  8:46   ` Christoph Hellwig
@ 2015-08-04  9:21     ` Jan Tulak
  0 siblings, 0 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-04  9:21 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs



----- Original Message -----
> From: "Christoph Hellwig" <hch@infradead.org>
> To: "Jan Tulak" <jtulak@redhat.com>
> Cc: hch@infradead.org, xfs@oss.sgi.com
> Sent: Tuesday, August 4, 2015 10:46:25 AM
> Subject: Re: [PATCH v3 04/11] xfsprogs: Add ifdef dirent checks where it was	missing
> 
> > diff --git a/io/readdir.c b/io/readdir.c
> > index 20b8898..ed8f04d 100644
> > --- a/io/readdir.c
> > +++ b/io/readdir.c
> > @@ -104,12 +104,16 @@ read_directory(
> >  		if (!dirent)
> >  			break;
> >  
> > +#ifdef _DIRENT_HAVE_D_RECLEN
> >  		*total += dirent->d_reclen;
> > +#endif
> 
> You probably want to use d_namen + sizeof(*dirent) to approimate
> the value if d_reclen doesn't exist.
> 
> >  		count++;
> >  
> >  		if (dump) {
> >  			dump_dirent(offset, dirent);
> > +#ifdef _DIRENT_HAVE_D_OFF
> >  			offset = dirent->d_off;
> > +#endif
> 
> We're only using the offset for dumping the value, maybe setting
> it to 0 and adding a comment explaining it should go into the else
> branch here?
> 

That sounds reasonable, sending an updated patch.

Thanks. :-)

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] 36+ messages in thread

* [PATCH v4 04/11] xfsprogs: Add ifdef dirent checks where it was missing
  2015-08-03 14:39 ` [PATCH v3 04/11] xfsprogs: Add ifdef dirent checks where it was missing Jan Tulak
  2015-08-04  8:46   ` Christoph Hellwig
@ 2015-08-04  9:25   ` Jan Tulak
  2015-08-04 11:18     ` Christoph Hellwig
  2015-08-05  9:48     ` [PATCH v5 " Jan Tulak
  1 sibling, 2 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-04  9:25 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Add check for _DIRENT_HAVED_RECLEN/_OFF to read_directory().
In dump_dirent() these checks already are used, but they were
missing in read_directory.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 io/readdir.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/io/readdir.c b/io/readdir.c
index 20b8898..ddd62c9 100644
--- a/io/readdir.c
+++ b/io/readdir.c
@@ -104,12 +104,24 @@ read_directory(
 		if (!dirent)
 			break;
 
+#ifdef _DIRENT_HAVE_D_RECLEN
 		*total += dirent->d_reclen;
+#else
+		*total += dirent->d_namlen + sizeof(*dirent);
+#endif
 		count++;
 
 		if (dump) {
 			dump_dirent(offset, dirent);
+#ifdef _DIRENT_HAVE_D_OFF
 			offset = dirent->d_off;
+#else
+			/* Some platforms don't have dirent->d_off, but because it is
+			 * used only for dumping the value, it should be safe to only
+			 * set it to zero in such case.
+			 */
+			offset = 0;
+#endif
 		}
 	}
 
-- 
2.4.3

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

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

* Re: [PATCH v3 05/11] xfsprogs: Change OS X-specific CFLAGS/LDFLAGS
  2015-08-03 14:39 ` [PATCH v3 05/11] xfsprogs: Change OS X-specific CFLAGS/LDFLAGS Jan Tulak
@ 2015-08-04 11:17   ` Christoph Hellwig
  0 siblings, 0 replies; 36+ messages in thread
From: Christoph Hellwig @ 2015-08-04 11:17 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

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

* Re: [PATCH v4 04/11] xfsprogs: Add ifdef dirent checks where it was missing
  2015-08-04  9:25   ` [PATCH v4 " Jan Tulak
@ 2015-08-04 11:18     ` Christoph Hellwig
  2015-08-04 14:19       ` Jan Tulak
  2015-08-05  9:48     ` [PATCH v5 " Jan Tulak
  1 sibling, 1 reply; 36+ messages in thread
From: Christoph Hellwig @ 2015-08-04 11:18 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

On Tue, Aug 04, 2015 at 11:25:14AM +0200, Jan Tulak wrote:
> Add check for _DIRENT_HAVED_RECLEN/_OFF to read_directory().
> In dump_dirent() these checks already are used, but they were
> missing in read_directory.

Needs to be fixed to avoid > 80 char lines.

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

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

* Re: [PATCH v3 06/11] xfsprogs: Add includes required for OS X builds
  2015-08-03 14:39 ` [PATCH v3 06/11] xfsprogs: Add includes required for OS X builds Jan Tulak
@ 2015-08-04 11:18   ` Christoph Hellwig
  2015-08-13 14:07     ` [PATCH " Jan Tulak
  0 siblings, 1 reply; 36+ messages in thread
From: Christoph Hellwig @ 2015-08-04 11:18 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

First hunk looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

Second hunk won't apply now that libdisk is gone.

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

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

* Re: [PATCH v3 08/11] xfsprogs: Add fls check into autoconf
  2015-08-03 14:39 ` [PATCH v3 08/11] xfsprogs: Add fls check into autoconf Jan Tulak
@ 2015-08-04 11:21   ` Christoph Hellwig
  2015-08-04 12:12     ` Jan Tulak
  0 siblings, 1 reply; 36+ messages in thread
From: Christoph Hellwig @ 2015-08-04 11:21 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

Can't you just use something like:

AC_CHECK_DECL([fls],
        [AC_DEFINE([HAVE_FLS_PROTOTYPE], [1],
	 [Define to 1 if have fls prototype])],
	 [],
	 [#include <string.h>])

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

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

* Re: [PATCH v3 09/11] xfsprogs: Add mntent.h check into autoconf
  2015-08-03 14:39 ` [PATCH v3 09/11] xfsprogs: Add mntent.h " Jan Tulak
@ 2015-08-04 11:21   ` Christoph Hellwig
  2015-08-17 15:01     ` [PATCH v4 " Jan Tulak
  0 siblings, 1 reply; 36+ messages in thread
From: Christoph Hellwig @ 2015-08-04 11:21 UTC (permalink / raw)
  To: Jan Tulak; +Cc: xfs

Why not just

AC_CHECK_HEADERS([mntent.h])

?

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

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

* Re: [PATCH v4 11/11] xfsprogs: prevent LIST_ macros conflicts
  2015-08-04  9:01   ` [PATCH v4 11/11] xfsprogs: prevent LIST_ macros conflicts Jan Tulak
@ 2015-08-04 11:22     ` Christoph Hellwig
  0 siblings, 0 replies; 36+ messages in thread
From: Christoph Hellwig @ 2015-08-04 11:22 UTC (permalink / raw)
  To: Jan Tulak; +Cc: xfs

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

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

* Re: [PATCH v3 08/11] xfsprogs: Add fls check into autoconf
  2015-08-04 11:21   ` Christoph Hellwig
@ 2015-08-04 12:12     ` Jan Tulak
  2015-08-14 12:59       ` Jan Tulak
  2015-08-17 15:02       ` [PATCH v4 03/11] " Jan Tulak
  0 siblings, 2 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-04 12:12 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs



----- Original Message -----
> From: "Christoph Hellwig" <hch@infradead.org>
> To: "Jan Tulak" <jtulak@redhat.com>
> Cc: hch@infradead.org, xfs@oss.sgi.com
> Sent: Tuesday, August 4, 2015 1:21:03 PM
> Subject: Re: [PATCH v3 08/11] xfsprogs: Add fls check into autoconf
> 
> Can't you just use something like:
> 
> AC_CHECK_DECL([fls],
>         [AC_DEFINE([HAVE_FLS_PROTOTYPE], [1],
> 	 [Define to 1 if have fls prototype])],
> 	 [],
> 	 [#include <string.h>])
> 

You mean to replace the entire autoconf part of the patch with this? 
I will try it. Autoconf is still a bit of a black magic for me, so I
used the already existing checks. :-)

Cheers,
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] 36+ messages in thread

* Re: [PATCH v4 04/11] xfsprogs: Add ifdef dirent checks where it was missing
  2015-08-04 11:18     ` Christoph Hellwig
@ 2015-08-04 14:19       ` Jan Tulak
  2015-08-04 23:00         ` Dave Chinner
  0 siblings, 1 reply; 36+ messages in thread
From: Jan Tulak @ 2015-08-04 14:19 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

----- Original Message -----
> From: "Christoph Hellwig" <hch@infradead.org>
> 
> Needs to be fixed to avoid > 80 char lines.
> 

I don't see any >80 char line in this patch. O_o
The longest line is 73 in the code and 62 in commit 
message. Though... maybe it can be a tab width issue? 
I use four spaces for a tab...

Cheers,
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] 36+ messages in thread

* Re: [PATCH v4 04/11] xfsprogs: Add ifdef dirent checks where it was missing
  2015-08-04 14:19       ` Jan Tulak
@ 2015-08-04 23:00         ` Dave Chinner
  2015-08-05  9:49           ` Jan Tulak
  0 siblings, 1 reply; 36+ messages in thread
From: Dave Chinner @ 2015-08-04 23:00 UTC (permalink / raw)
  To: Jan Tulak; +Cc: Christoph Hellwig, xfs

On Tue, Aug 04, 2015 at 10:19:40AM -0400, Jan Tulak wrote:
> ----- Original Message -----
> > From: "Christoph Hellwig" <hch@infradead.org>
> > 
> > Needs to be fixed to avoid > 80 char lines.
> > 
> 
> I don't see any >80 char line in this patch. O_o
> The longest line is 73 in the code and 62 in commit 
> message. Though... maybe it can be a tab width issue? 
> I use four spaces for a tab...

8 spaces to a tab, please. Same coding style rules as for writing
kernel code. ;)

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] 36+ messages in thread

* [PATCH v5 04/11] xfsprogs: Add ifdef dirent checks where it was missing
  2015-08-04  9:25   ` [PATCH v4 " Jan Tulak
  2015-08-04 11:18     ` Christoph Hellwig
@ 2015-08-05  9:48     ` Jan Tulak
  1 sibling, 0 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-05  9:48 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

CHANGED: text width fix

Add check for _DIRENT_HAVED_RECLEN/_OFF to read_directory().
In dump_dirent() these checks already are used, but they were
missing in read_directory.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 io/readdir.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/io/readdir.c b/io/readdir.c
index 7b0edbc..151b72e 100644
--- a/io/readdir.c
+++ b/io/readdir.c
@@ -103,12 +103,24 @@ read_directory(
 		if (!dirent)
 			break;
 
+#ifdef _DIRENT_HAVE_D_RECLEN
 		*total += dirent->d_reclen;
+#else
+		*total += dirent->d_namlen + sizeof(*dirent);
+#endif
 		count++;
 
 		if (dump) {
 			dump_dirent(offset, dirent);
+#ifdef _DIRENT_HAVE_D_OFF
 			offset = dirent->d_off;
+#else
+			/* Some platforms don't have dirent->d_off, but because
+			 * it is used only for dumping the value, it should be
+			 * safe to only set it to zero in such case.
+			 */
+			offset = 0;
+#endif
 		}
 	}
 
-- 
2.4.3

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

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

* Re: [PATCH v4 04/11] xfsprogs: Add ifdef dirent checks where it was missing
  2015-08-04 23:00         ` Dave Chinner
@ 2015-08-05  9:49           ` Jan Tulak
  0 siblings, 0 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-05  9:49 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Christoph Hellwig, xfs



----- Original Message -----
> From: "Dave Chinner" <david@fromorbit.com>
> To: "Jan Tulak" <jtulak@redhat.com>
> Cc: "Christoph Hellwig" <hch@infradead.org>, xfs@oss.sgi.com
> Sent: Wednesday, August 5, 2015 1:00:00 AM
> Subject: Re: [PATCH v4 04/11] xfsprogs: Add ifdef dirent checks where it was	missing
> 
> On Tue, Aug 04, 2015 at 10:19:40AM -0400, Jan Tulak wrote:
> > ----- Original Message -----
> > > From: "Christoph Hellwig" <hch@infradead.org>
> > > 
> > > Needs to be fixed to avoid > 80 char lines.
> > > 
> > 
> > I don't see any >80 char line in this patch. O_o
> > The longest line is 73 in the code and 62 in commit
> > message. Though... maybe it can be a tab width issue?
> > I use four spaces for a tab...
> 
> 8 spaces to a tab, please. Same coding style rules as for writing
> kernel code. ;)

All right, fixed patch sent. :-)

Cheers,
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] 36+ messages in thread

* Re: [PATCH v3 10/11] xfsprogs: replace obsolete memalign with posix_memalign
  2015-08-03 14:39 ` [PATCH v3 10/11] xfsprogs: replace obsolete memalign with posix_memalign Jan Tulak
@ 2015-08-05 22:57   ` Dave Chinner
  2015-08-13 14:08     ` [PATCH " Jan Tulak
  0 siblings, 1 reply; 36+ messages in thread
From: Dave Chinner @ 2015-08-05 22:57 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

On Mon, Aug 03, 2015 at 04:39:48PM +0200, Jan Tulak wrote:
> Memalign from <malloc.h> was marked obsolete in favor of a posix
> variant from <stdlib.h>. So replace all calls and remove <malloc.h>
> includes. This also enhances support on other posix platforms,
> which doesn't have <malloc.h>.
> 
> Because posix_memalign returns any error as a return code, not in
> errno, change relevant checks in code (and add a missing one).
....
> @@ -74,12 +74,18 @@ libxfs_device_zero(struct xfs_buftarg *btp, xfs_daddr_t start, uint len)
>  	ssize_t		zsize, bytes;
>  	char		*z;
>  	int		fd;
> +	int ret;
>  
>  	zsize = min(BDSTRAT_SIZE, BBTOB(len));
> -	if ((z = memalign(libxfs_device_alignment(), zsize)) == NULL) {
> +	ret = posix_memalign(
> +						(void **)&z,
> +						libxfs_device_alignment(),
> +						zsize
> +					);

Unusual function call formatting. Please use the form the rest of
the code uses. i.e:

	ret = posix_memalign((void **)&z, libxfs_device_alignment(), zsize);

(same for the rest of the patch).

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] 36+ messages in thread

* [PATCH 06/11] xfsprogs: Add includes required for OS X builds
  2015-08-04 11:18   ` Christoph Hellwig
@ 2015-08-13 14:07     ` Jan Tulak
  0 siblings, 0 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-13 14:07 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

UPDATE: updated for libdisk gone

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 include/darwin.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/darwin.h b/include/darwin.h
index abdf4e3..8b5a661 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -18,12 +18,20 @@
 #ifndef __XFS_DARWIN_H__
 #define __XFS_DARWIN_H__
 
+#include <unistd.h>
+#include <sys/types.h>
+#include <string.h>
 #include <uuid/uuid.h>
 #include <libgen.h>
 #include <sys/vm.h>
 #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 <stdio.h>
 
 #include <machine/endian.h>
 #define __BYTE_ORDER	BYTE_ORDER
-- 
2.4.5

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

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

* [PATCH 10/11] xfsprogs: replace obsolete memalign with posix_memalign
  2015-08-05 22:57   ` Dave Chinner
@ 2015-08-13 14:08     ` Jan Tulak
  0 siblings, 0 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-13 14:08 UTC (permalink / raw)
  To: xfs; +Cc: Jan Tulak

UPDATE: code format

Memalign from <malloc.h> was marked obsolete in favor of a posix
variant from <stdlib.h>. So replace all calls and remove <malloc.h>
includes. This also enhances support on other posix platforms,
which doesn't have <malloc.h>.

Because posix_memalign returns any error as a return code, not in
errno, change relevant checks in code (and add a missing one).

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 copy/xfs_copy.c       |  2 +-
 db/attrset.c          |  2 +-
 fsr/xfs_fsr.c         |  3 ++-
 include/darwin.h      |  1 -
 include/freebsd.h     |  1 -
 include/gnukfreebsd.h |  1 -
 include/linux.h       |  1 -
 io/pread.c            |  4 ++--
 libxfs/rdwr.c         | 12 ++++++++----
 mkfs/xfs_mkfs.c       |  3 ++-
 repair/incore.c       |  2 +-
 repair/incore_ino.c   |  7 ++++---
 repair/phase1.c       |  2 +-
 repair/prefetch.c     |  7 +++----
 repair/sb.c           | 10 +++++-----
 rtcp/xfs_rtcp.c       |  7 ++++++-
 16 files changed, 36 insertions(+), 29 deletions(-)

diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
index e13f468..8109ac5 100644
--- a/copy/xfs_copy.c
+++ b/copy/xfs_copy.c
@@ -333,7 +333,7 @@ wbuf *
 wbuf_init(wbuf *buf, int data_size, int data_align, int min_io_size, int id)
 {
 	ASSERT(data_size % BBSIZE == 0);
-	while ((buf->data = memalign(data_align, data_size)) == NULL) {
+	while (posix_memalign((void**)&(buf->data), data_align, data_size)) {
 		data_size >>= 1;
 		if (data_size < min_io_size)
 			return NULL;
diff --git a/db/attrset.c b/db/attrset.c
index ec9da5a..539765f 100644
--- a/db/attrset.c
+++ b/db/attrset.c
@@ -141,7 +141,7 @@ attr_set_f(
 	name = argv[optind];
 
 	if (valuelen) {
-		value = (char *)memalign(getpagesize(), valuelen);
+		posix_memalign((void**)&value, getpagesize(), valuelen);
 		if (!value) {
 			dbprintf(_("cannot allocate buffer (%d)\n"), valuelen);
 			goto out;
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index 4912b73..ad52990 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -1306,7 +1306,8 @@ packfile(char *fname, char *tname, int fd,
 			dio.d_maxiosz, pagesize);
 	}
 
-	if (!(fbuf = (char *)memalign(dio.d_mem, blksz_dio))) {
+	posix_memalign((void **)&fbuf, dio.d_mem, blksz_dio);
+	if (!fbuf) {
 		fsrprintf(_("could not allocate buf: %s\n"), tname);
 		goto out;
 	}
diff --git a/include/darwin.h b/include/darwin.h
index 775dfc8..e3ec863 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -141,7 +141,6 @@ typedef int64_t		xfs_daddr_t;
 #define pwrite64	pwrite
 #define ftruncate64	ftruncate
 #define fdatasync	fsync
-#define memalign(a,sz)	valloc(sz)
 
 #define O_LARGEFILE     0
 #ifndef O_DIRECT
diff --git a/include/freebsd.h b/include/freebsd.h
index 902b940..7289159 100644
--- a/include/freebsd.h
+++ b/include/freebsd.h
@@ -40,7 +40,6 @@
 #define pwrite64	pwrite
 #define pread64		pread
 #define fdatasync	fsync
-#define memalign(a,sz)	valloc(sz)
 
 #define constpp	char * const *
 
diff --git a/include/gnukfreebsd.h b/include/gnukfreebsd.h
index 95c4c13..4605234 100644
--- a/include/gnukfreebsd.h
+++ b/include/gnukfreebsd.h
@@ -22,7 +22,6 @@
 #include <sys/vfs.h>
 #include <sys/ioctl.h>
 #include <sys/sysmacros.h>
-#include <malloc.h>
 #include <getopt.h>
 #include <endian.h>
 #include <sys/stat.h>
diff --git a/include/linux.h b/include/linux.h
index 8804c2d..7493b76 100644
--- a/include/linux.h
+++ b/include/linux.h
@@ -24,7 +24,6 @@
 #include <sys/sysmacros.h>
 #include <sys/stat.h>
 #include <inttypes.h>
-#include <malloc.h>
 #include <getopt.h>
 #include <errno.h>
 #include <endian.h>
diff --git a/io/pread.c b/io/pread.c
index 1c77c41..74ba47e 100644
--- a/io/pread.c
+++ b/io/pread.c
@@ -77,7 +77,7 @@ alloc_iovec(
 
 	buffersize = 0;
 	for (i = 0; i < vectors; i++) {
-		iov[i].iov_base = memalign(pagesize, bsize);
+		posix_memalign((void**)&(iov[i].iov_base), pagesize, bsize);
 		if (!iov[i].iov_base) {
 			perror("memalign");
 			goto unwind;
@@ -108,7 +108,7 @@ alloc_buffer(
 	if (bsize > highwater) {
 		if (buffer)
 			free(buffer);
-		buffer = memalign(pagesize, bsize);
+		posix_memalign((void**)&buffer, pagesize, bsize);
 		if (!buffer) {
 			perror("memalign");
 			highwater = buffersize = 0;
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index 4f8212f..7884cf8 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -74,12 +74,14 @@ libxfs_device_zero(struct xfs_buftarg *btp, xfs_daddr_t start, uint len)
 	ssize_t		zsize, bytes;
 	char		*z;
 	int		fd;
+	int ret;
 
 	zsize = min(BDSTRAT_SIZE, BBTOB(len));
-	if ((z = memalign(libxfs_device_alignment(), zsize)) == NULL) {
+	ret = posix_memalign((void **)&z, libxfs_device_alignment(), zsize);
+	if (!z) {
 		fprintf(stderr,
 			_("%s: %s can't memalign %d bytes: %s\n"),
-			progname, __FUNCTION__, (int)zsize, strerror(errno));
+			progname, __FUNCTION__, (int)zsize, strerror(ret));
 		exit(1);
 	}
 	memset(z, 0, zsize);
@@ -409,6 +411,7 @@ static void
 __initbuf(xfs_buf_t *bp, struct xfs_buftarg *btp, xfs_daddr_t bno,
 		unsigned int bytes)
 {
+	int ret;
 	bp->b_flags = 0;
 	bp->b_bn = bno;
 	bp->b_bcount = bytes;
@@ -416,12 +419,13 @@ __initbuf(xfs_buf_t *bp, struct xfs_buftarg *btp, xfs_daddr_t bno,
 	bp->b_target = btp;
 	bp->b_error = 0;
 	if (!bp->b_addr)
-		bp->b_addr = memalign(libxfs_device_alignment(), bytes);
+		ret = posix_memalign((void**)&(bp->b_addr),
+					libxfs_device_alignment(), bytes);
 	if (!bp->b_addr) {
 		fprintf(stderr,
 			_("%s: %s can't memalign %u bytes: %s\n"),
 			progname, __FUNCTION__, bytes,
-			strerror(errno));
+			strerror(ret));
 		exit(1);
 	}
 	memset(bp->b_addr, 0, bytes);
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 69d61c7..d349b4f 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -770,7 +770,8 @@ zero_old_xfs_structures(
 	 * read in existing filesystem superblock, use its geometry
 	 * settings and zero the existing secondary superblocks.
 	 */
-	buf = memalign(libxfs_device_alignment(), new_sb->sb_sectsize);
+	posix_memalign((void**)&buf, libxfs_device_alignment(),
+		       new_sb->sb_sectsize);
 	if (!buf) {
 		fprintf(stderr,
 	_("error reading existing superblock -- failed to memalign buffer\n"));
diff --git a/repair/incore.c b/repair/incore.c
index cb57316..81d3b8c 100644
--- a/repair/incore.c
+++ b/repair/incore.c
@@ -224,7 +224,7 @@ init_rt_bmap(
 	rt_bmap_size = roundup(mp->m_sb.sb_rextents / (NBBY / XR_BB),
 			       sizeof(__uint64_t));
 
-	rt_bmap = memalign(sizeof(__uint64_t), rt_bmap_size);
+	posix_memalign((void**)&rt_bmap, sizeof(__uint64_t), rt_bmap_size);
 	if (!rt_bmap) {
 		do_error(
 	_("couldn't allocate realtime block map, size = %" PRIu64 "\n"),
diff --git a/repair/incore_ino.c b/repair/incore_ino.c
index 32d7678..dd95996 100644
--- a/repair/incore_ino.c
+++ b/repair/incore_ino.c
@@ -626,8 +626,8 @@ set_inode_parent(
 			irec->ino_un.plist = ptbl;
 
 		ptbl->pmask = 1LL << offset;
-		ptbl->pentries = (xfs_ino_t*)memalign(sizeof(xfs_ino_t),
-							sizeof(xfs_ino_t));
+		posix_memalign((void**)&(ptbl->pentries),sizeof(xfs_ino_t),
+				sizeof(xfs_ino_t));
 		if (!ptbl->pentries)
 			do_error(_("couldn't memalign pentries table\n"));
 #ifdef DEBUG
@@ -673,7 +673,8 @@ set_inode_parent(
 #endif
 	ASSERT(cnt >= target);
 
-	tmp = (xfs_ino_t*)memalign(sizeof(xfs_ino_t), (cnt + 1) * sizeof(xfs_ino_t));
+	posix_memalign((void**)&tmp, sizeof(xfs_ino_t),
+		       (cnt + 1) * sizeof(xfs_ino_t));
 	if (!tmp)
 		do_error(_("couldn't memalign pentries table\n"));
 
diff --git a/repair/phase1.c b/repair/phase1.c
index 126d0b3..7a1fc7d 100644
--- a/repair/phase1.c
+++ b/repair/phase1.c
@@ -35,7 +35,7 @@ alloc_ag_buf(int size)
 {
 	char	*bp;
 
-	bp = (char *)memalign(libxfs_device_alignment(), size);
+	posix_memalign((void**)&bp, libxfs_device_alignment(), size);
 	if (!bp)
 		do_error(_("could not allocate ag header buffer (%d bytes)\n"),
 			size);
diff --git a/repair/prefetch.c b/repair/prefetch.c
index 8b261ae..c6c9450 100644
--- a/repair/prefetch.c
+++ b/repair/prefetch.c
@@ -631,10 +631,9 @@ pf_io_worker(
 	void			*param)
 {
 	prefetch_args_t		*args = param;
-	void			*buf = memalign(libxfs_device_alignment(),
-						pf_max_bytes);
-
-	if (buf == NULL)
+	void			*buf;
+	posix_memalign((void**)&buf, libxfs_device_alignment(), pf_max_bytes);
+	if (!buf)
 		return NULL;
 
 	pthread_mutex_lock(&args->lock);
diff --git a/repair/sb.c b/repair/sb.c
index 4eef14a..cf1ea8b 100644
--- a/repair/sb.c
+++ b/repair/sb.c
@@ -102,7 +102,7 @@ find_secondary_sb(xfs_sb_t *rsb)
 
 	do_warn(_("\nattempting to find secondary superblock...\n"));
 
-	sb = (xfs_sb_t *)memalign(libxfs_device_alignment(), BSIZE);
+	posix_memalign((void**)&sb, libxfs_device_alignment(), BSIZE);
 	if (!sb) {
 		do_error(
 	_("error finding secondary superblock -- failed to memalign buffer\n"));
@@ -438,8 +438,8 @@ write_primary_sb(xfs_sb_t *sbp, int size)
 	if (no_modify)
 		return;
 
-	buf = memalign(libxfs_device_alignment(), size);
-	if (buf == NULL) {
+	posix_memalign((void**)&buf, libxfs_device_alignment(), size);
+	if (!buf) {
 		do_error(_("failed to memalign superblock buffer\n"));
 		return;
 	}
@@ -472,8 +472,8 @@ get_sb(xfs_sb_t *sbp, xfs_off_t off, int size, xfs_agnumber_t agno)
 	int error, rval;
 	xfs_dsb_t *buf;
 
-	buf = memalign(libxfs_device_alignment(), size);
-	if (buf == NULL) {
+	posix_memalign((void**)&buf, libxfs_device_alignment(), size);
+	if (!buf) {
 		do_error(
 	_("error reading superblock %u -- failed to memalign buffer\n"),
 			agno);
diff --git a/rtcp/xfs_rtcp.c b/rtcp/xfs_rtcp.c
index f604b46..e2e3ece 100644
--- a/rtcp/xfs_rtcp.c
+++ b/rtcp/xfs_rtcp.c
@@ -327,7 +327,12 @@ rtcp( char *source, char *target, int fextsize)
 	}
 
 	iosz =  dioattr.d_miniosz;
-	fbuf = memalign( dioattr.d_mem, iosz);
+	posix_memalign((void**)&fbuf, dioattr.d_mem, iosz);
+	if (!fbuf) {
+		perror(
+	_("error finding secondary superblock -- failed to memalign buffer\n"));
+		exit(1);
+	}
 	memset(fbuf, 0, iosz);
 
 	/*
-- 
2.4.5

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

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

* Re: [PATCH v3 08/11] xfsprogs: Add fls check into autoconf
  2015-08-04 12:12     ` Jan Tulak
@ 2015-08-14 12:59       ` Jan Tulak
  2015-08-17 15:02       ` [PATCH v4 03/11] " Jan Tulak
  1 sibling, 0 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-14 12:59 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs-oss


[-- Attachment #1.1: Type: text/plain, Size: 1129 bytes --]

On Tue, Aug 4, 2015 at 2:12 PM, Jan Tulak <jtulak@redhat.com> wrote:

>
>
> ----- Original Message -----
> > From: "Christoph Hellwig" <hch@infradead.org>
> > To: "Jan Tulak" <jtulak@redhat.com>
> > Cc: hch@infradead.org, xfs@oss.sgi.com
> > Sent: Tuesday, August 4, 2015 1:21:03 PM
> > Subject: Re: [PATCH v3 08/11] xfsprogs: Add fls check into autoconf
> >
> > Can't you just use something like:
> >
> > AC_CHECK_DECL([fls],
> >         [AC_DEFINE([HAVE_FLS_PROTOTYPE], [1],
> >        [Define to 1 if have fls prototype])],
> >        [],
> >        [#include <string.h>])
> >
>
> You mean to replace the entire autoconf part of the patch with this?
> I will try it. Autoconf is still a bit of a black magic for me, so I
> used the already existing checks. :-)
>

Hi Chris,
did you want the result to be this? (I didn't get any clarification of what
you mean, so I'm asking again. :-) )

#
# Check if we have a flc call (Mac OS X)
#
AC_DEFUN([AC_HAVE_FLS],
  [ AC_CHECK_DECL([fls],
       have_fls=yes,
       [],
       [#include <string.h>]
       )
    AC_SUBST(have_fls)
  ])

Cheers,
Jan

-- 
Jan Tulak
jtulak@redhat.com

[-- Attachment #1.2: Type: text/html, Size: 2171 bytes --]

[-- Attachment #2: Type: text/plain, Size: 121 bytes --]

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

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

* [PATCH v4 09/11] xfsprogs: Add mntent.h check into autoconf
  2015-08-04 11:21   ` Christoph Hellwig
@ 2015-08-17 15:01     ` Jan Tulak
  2015-08-17 15:04       ` Christoph Hellwig
  0 siblings, 1 reply; 36+ messages in thread
From: Jan Tulak @ 2015-08-17 15:01 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

UPDATE: Autoconf change. Hopefully this is what Chris meant.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 configure.ac          | 1 +
 fsr/xfs_fsr.c         | 6 +++---
 include/builddefs.in  | 4 ++++
 m4/package_libcdev.m4 | 8 ++++++++
 4 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 530650b..0aba90c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -115,6 +115,7 @@ AC_HAVE_FALLOCATE
 AC_HAVE_FIEMAP
 AC_HAVE_PREADV
 AC_HAVE_SYNC_FILE_RANGE
+AC_HAVE_MNTENT
 AC_HAVE_BLKID_TOPO
 AC_HAVE_READDIR
 
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index b4ff136..4912b73 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -25,16 +25,16 @@
 
 #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>
 
+#ifdef HAVE_MNTENT
+#  include <mntent.h>
+#endif
 
 #ifndef XFS_XFLAG_NODEFRAG
 #define XFS_XFLAG_NODEFRAG 0x00002000 /* src dependancy, remove later */
diff --git a/include/builddefs.in b/include/builddefs.in
index c644a17..e522243 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -103,6 +103,7 @@ HAVE_FIEMAP = @have_fiemap@
 HAVE_PREADV = @have_preadv@
 HAVE_SYNC_FILE_RANGE = @have_sync_file_range@
 HAVE_READDIR = @have_readdir@
+HAVE_MNTENT = @have_mntent@
 
 GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall 
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
@@ -130,6 +131,9 @@ PLDLIBS = -L/usr/local/lib -lintl
 PCFLAGS = -I/usr/local/include $(GCCFLAGS)
 DEPENDFLAGS = -D__FreeBSD__
 endif
+ifeq ($(HAVE_MNTENT),yes)
+PCFLAGS+= -DHAVE_MNTENT
+endif
 
 GCFLAGS = $(OPTIMIZER) $(DEBUG) \
 	  -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\"  \
diff --git a/m4/package_libcdev.m4 b/m4/package_libcdev.m4
index 919ae0a..75aa61e 100644
--- a/m4/package_libcdev.m4
+++ b/m4/package_libcdev.m4
@@ -202,3 +202,11 @@ AC_DEFUN([AC_HAVE_READDIR],
     AC_SUBST(have_readdir)
   ])
 
+#
+# Check if there is mntent.h
+#
+AC_DEFUN([AC_HAVE_MNTENT],
+  [ AC_CHECK_HEADERS(mntent.h,
+    have_mntent=yes)
+    AC_SUBST(have_mntent)
+  ])
-- 
2.4.3

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

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

* [PATCH v4 03/11] xfsprogs: Add fls check into autoconf
  2015-08-04 12:12     ` Jan Tulak
  2015-08-14 12:59       ` Jan Tulak
@ 2015-08-17 15:02       ` Jan Tulak
  1 sibling, 0 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-17 15:02 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

UPDATE: Autoconf change. Hopefully this is what Chris meant.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 configure.ac          |  1 +
 include/bitops.h      |  2 ++
 include/builddefs.in  |  4 ++++
 m4/package_libcdev.m4 | 12 ++++++++++++
 4 files changed, 19 insertions(+)

diff --git a/configure.ac b/configure.ac
index 0aba90c..abb7904 100644
--- a/configure.ac
+++ b/configure.ac
@@ -116,6 +116,7 @@ AC_HAVE_FIEMAP
 AC_HAVE_PREADV
 AC_HAVE_SYNC_FILE_RANGE
 AC_HAVE_MNTENT
+AC_HAVE_FLS
 AC_HAVE_BLKID_TOPO
 AC_HAVE_READDIR
 
diff --git a/include/bitops.h b/include/bitops.h
index 930f64a..44599a7 100644
--- a/include/bitops.h
+++ b/include/bitops.h
@@ -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)
 {
diff --git a/include/builddefs.in b/include/builddefs.in
index e522243..8851956 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -104,6 +104,7 @@ HAVE_PREADV = @have_preadv@
 HAVE_SYNC_FILE_RANGE = @have_sync_file_range@
 HAVE_READDIR = @have_readdir@
 HAVE_MNTENT = @have_mntent@
+HAVE_FLS = @have_fls@
 
 GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall 
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
@@ -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
 ifeq ($(HAVE_MNTENT),yes)
 PCFLAGS+= -DHAVE_MNTENT
 endif
diff --git a/m4/package_libcdev.m4 b/m4/package_libcdev.m4
index 75aa61e..4a96374 100644
--- a/m4/package_libcdev.m4
+++ b/m4/package_libcdev.m4
@@ -203,6 +203,18 @@ AC_DEFUN([AC_HAVE_READDIR],
   ])
 
 #
+# Check if we have a flc call (Mac OS X)
+#
+AC_DEFUN([AC_HAVE_FLS],
+  [ AC_CHECK_DECL([fls],
+       have_fls=yes,
+       [],
+       [#include <string.h>]
+       )
+    AC_SUBST(have_fls)
+  ])
+
+#
 # Check if there is mntent.h
 #
 AC_DEFUN([AC_HAVE_MNTENT],
-- 
2.4.3

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

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

* Re: [PATCH v4 09/11] xfsprogs: Add mntent.h check into autoconf
  2015-08-17 15:01     ` [PATCH v4 " Jan Tulak
@ 2015-08-17 15:04       ` Christoph Hellwig
  2015-08-17 15:15         ` Jan Tulak
  0 siblings, 1 reply; 36+ messages in thread
From: Christoph Hellwig @ 2015-08-17 15:04 UTC (permalink / raw)
  To: Jan Tulak; +Cc: xfs

This looks mostly fine.  I think you could just add the
AC_CHECK_HEADERS directly to configure.ac, but otherwise it's exactly
what I though.

Can you please resend all your pending patches in a single series,
and move the UPDATES: lines and other internal changelogs to the
cover letter instead of the patch descriptions?

Thanks for doing this work!

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

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

* Re: [PATCH v4 09/11] xfsprogs: Add mntent.h check into autoconf
  2015-08-17 15:04       ` Christoph Hellwig
@ 2015-08-17 15:15         ` Jan Tulak
  0 siblings, 0 replies; 36+ messages in thread
From: Jan Tulak @ 2015-08-17 15:15 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs-oss


[-- Attachment #1.1: Type: text/plain, Size: 774 bytes --]

On Mon, Aug 17, 2015 at 5:04 PM, Christoph Hellwig <hch@infradead.org>
wrote:

> This looks mostly fine.  I think you could just add the
> AC_CHECK_HEADERS directly to configure.ac, but otherwise it's exactly
> what I though.
>

In configure.ac, there are no direct checks for headers, just calls of all
the various
AC_HAVE_*. I'm not sure it is a good idea to mix now. Unless you think that
all
the functions should be moved into configure.ac from the m4/ directory.



> Can you please resend all your pending patches in a single series,
> and move the UPDATES: lines and other internal changelogs to the
> cover letter instead of the patch descriptions?
>
> Thanks for doing this work!
>

Sure, I'll send it again as a whole. And np. :-)

-- 
Jan Tulak
jtulak@redhat.com

[-- Attachment #1.2: Type: text/html, Size: 1582 bytes --]

[-- Attachment #2: Type: text/plain, Size: 121 bytes --]

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

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

end of thread, other threads:[~2015-08-17 15:15 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-03 14:39 [PATCH v3 00/11] xfsprogs: OS X partial support Jan Tulak
2015-08-03 14:39 ` [PATCH v2 01/11] xfsprogs: Don't Make .po files with gettext disabled Jan Tulak
2015-08-03 14:39 ` [PATCH v2 02/11] xfsprogs: Use glibtoolize on osx Jan Tulak
2015-08-03 14:39 ` [PATCH v3 03/11] xfsprogs: undefined variable fix Jan Tulak
2015-08-04  8:41   ` Christoph Hellwig
2015-08-03 14:39 ` [PATCH v3 04/11] xfsprogs: Add ifdef dirent checks where it was missing Jan Tulak
2015-08-04  8:46   ` Christoph Hellwig
2015-08-04  9:21     ` Jan Tulak
2015-08-04  9:25   ` [PATCH v4 " Jan Tulak
2015-08-04 11:18     ` Christoph Hellwig
2015-08-04 14:19       ` Jan Tulak
2015-08-04 23:00         ` Dave Chinner
2015-08-05  9:49           ` Jan Tulak
2015-08-05  9:48     ` [PATCH v5 " Jan Tulak
2015-08-03 14:39 ` [PATCH v3 05/11] xfsprogs: Change OS X-specific CFLAGS/LDFLAGS Jan Tulak
2015-08-04 11:17   ` Christoph Hellwig
2015-08-03 14:39 ` [PATCH v3 06/11] xfsprogs: Add includes required for OS X builds Jan Tulak
2015-08-04 11:18   ` Christoph Hellwig
2015-08-13 14:07     ` [PATCH " Jan Tulak
2015-08-03 14:39 ` [PATCH v3 07/11] xfsprogs: missing and dummy calls for OS X support Jan Tulak
2015-08-03 14:39 ` [PATCH v3 08/11] xfsprogs: Add fls check into autoconf Jan Tulak
2015-08-04 11:21   ` Christoph Hellwig
2015-08-04 12:12     ` Jan Tulak
2015-08-14 12:59       ` Jan Tulak
2015-08-17 15:02       ` [PATCH v4 03/11] " Jan Tulak
2015-08-03 14:39 ` [PATCH v3 09/11] xfsprogs: Add mntent.h " Jan Tulak
2015-08-04 11:21   ` Christoph Hellwig
2015-08-17 15:01     ` [PATCH v4 " Jan Tulak
2015-08-17 15:04       ` Christoph Hellwig
2015-08-17 15:15         ` Jan Tulak
2015-08-03 14:39 ` [PATCH v3 10/11] xfsprogs: replace obsolete memalign with posix_memalign Jan Tulak
2015-08-05 22:57   ` Dave Chinner
2015-08-13 14:08     ` [PATCH " Jan Tulak
2015-08-03 14:39 ` [PATCH v2 11/11] xfsprogs: Prefix LIST_... macros to XFS_LIST_ Jan Tulak
2015-08-04  9:01   ` [PATCH v4 11/11] xfsprogs: prevent LIST_ macros conflicts Jan Tulak
2015-08-04 11:22     ` Christoph Hellwig

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