All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11 v4] xfsprogs: Partial OSX support
@ 2015-08-26 12:00 Jan Tulak
  2015-08-26 12:02 ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Jan Tulak
  0 siblings, 1 reply; 45+ messages in thread
From: Jan Tulak @ 2015-08-26 12:00 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Fourth iteration. Most of the patches in this set are from splitting
one patch in the previous iteration.

Specifically, only patch 1 is from the previous set as it wasn't
in a good shape yet. Patch 3 is a delta for an older version which was
merged accidentaly instead of the newest one.

All the other patches in this set originate from
[PATCH 05/11] xfsprogs: missing and dummy calls for OS X support.

FSR is still compiled, even if it requires empty functions. There is
no drawback from this for other platforms. Some of the calls can be made
working. However, for example the mntent calls are not usefull anywhere
else, and as fsr can't work without a mounted system, there is no way
how to use and test the alternative implementation.

If in futre xfs can be mounted on OS X, then at least the empty functions
are clear as "TODO". If there is an untested code, they will most likely
need to be debugged and possibly even rewritten to respect future changes
in OS X. So in short, I see implementing them as a waste of time.

Stopping the FSR build is, with the current target audience of this port
between developers, unnecessary.

Cheers,
Jan

CHANGELOG:

v4:
- added #warning message (patch 1) 
- use dummy blkid_get_topology instead of #ifdefs (patch 1)
- fix autoconf (wasn't passing -DENABLE_BLKID flag, lost during
  patch cleaning.) (patch 1)
- remove dependency on linux XATTR_ constants (patch 2)
- add autoconf detection for fsetxattr (patch 4)
- use uuid_t instead of unsigned char (patch 5)
- add a basic timer functionality (patch 8)
- mremap replacement now returns MAP_FAILED (patch 11)



Version 3:
- better commit messages (patch 1)
- formatting fixes (patch 2, 8)
- autoconf updates (patch 6, 7)
- changed default behaviour if BLKID is disabled such that mkfs -f
  is required (patch 11)

Jan Tulak (11):
  xfsprogs: Add a way to compile without blkid
  xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX
  xfsprogs: Add includes required for OS X builds (delta)
  xfsprogs: Add autoconf check for fsetxattr call
  xfsprogs: uuid changes for OS X
  xfsprogs: Remove conflicting define for OS X
  xfsprogs: add nftw64 translation for OS X
  xfsprogs: Add a timer implementation for OS X
  xfsprogs: Add statvfs64 for osx
  xfsprogs: add dummy mntent for OS X
  xfsprogs: add dummy mremap for OS X

 configure.ac             |  11 +++-
 fsr/xfs_fsr.c            |   8 +++
 include/builddefs.in     |  11 +++-
 include/darwin.h         | 157 ++++++++++++++++++++++++++++++++++++++++++-----
 libhandle/handle.c       |   6 +-
 libhandle/jdm.c          |   6 +-
 libxfs/xfs_attr_remote.c |   2 +-
 libxfs/xfs_format.h      |  11 +++-
 m4/package_libcdev.m4    |  13 ++++
 mkfs/xfs_mkfs.c          |  37 ++++++++++-
 repair/progress.c        |  16 ++++-
 11 files changed, 251 insertions(+), 27 deletions(-)

-- 
2.4.5

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

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

* [PATCH 01/11] xfsprogs: Add a way to compile without blkid
  2015-08-26 12:00 [PATCH 00/11 v4] xfsprogs: Partial OSX support Jan Tulak
@ 2015-08-26 12:02 ` Jan Tulak
  2015-08-26 12:02   ` [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX Jan Tulak
                     ` (10 more replies)
  0 siblings, 11 replies; 45+ messages in thread
From: Jan Tulak @ 2015-08-26 12:02 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Because not all platforms have up-to-date blkid with required
functions, allow at least partial functionality by adding
--enable-blkid=yes/no optional configure argument.

When blkid is disabled, signature detection and device geometry
detection doesn't work.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 configure.ac         | 10 +++++++++-
 include/builddefs.in |  5 +++++
 mkfs/xfs_mkfs.c      | 37 ++++++++++++++++++++++++++++++++++++-
 3 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 665b65f..0446620 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,6 +26,11 @@ AC_ARG_ENABLE(gettext,
 	enable_gettext=yes)
 AC_SUBST(enable_gettext)
 
+AC_ARG_ENABLE(blkid,
+[ --enable-blkid=[yes/no] Enable use of block device id library [default=yes]],,
+	enable_blkid=yes)
+AC_SUBST(enable_blkid)
+
 AC_ARG_ENABLE(readline,
 [ --enable-readline=[yes/no] Enable readline command editing [default=no]],
 	test $enable_readline = yes && libreadline="-lreadline",
@@ -117,9 +122,12 @@ AC_HAVE_PREADV
 AC_HAVE_SYNC_FILE_RANGE
 AC_HAVE_MNTENT
 AC_HAVE_FLS
-AC_HAVE_BLKID_TOPO
 AC_HAVE_READDIR
 
+if test "$enable_blkid" = yes; then
+AC_HAVE_BLKID_TOPO
+fi
+
 AC_CHECK_SIZEOF([long])
 AC_CHECK_SIZEOF([char *])
 AC_TYPE_UMODE_T
diff --git a/include/builddefs.in b/include/builddefs.in
index 8851956..6c16a65 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -89,6 +89,7 @@ ENABLE_SHARED	= @enable_shared@
 ENABLE_GETTEXT	= @enable_gettext@
 ENABLE_EDITLINE	= @enable_editline@
 ENABLE_READLINE	= @enable_readline@
+ENABLE_BLKID	= @enable_blkid@
 
 HAVE_ZIPPED_MANPAGES = @have_zipped_manpages@
 
@@ -138,6 +139,10 @@ endif
 ifeq ($(HAVE_MNTENT),yes)
 PCFLAGS+= -DHAVE_MNTENT
 endif
+ifeq ($(ENABLE_BLKID),yes)
+PCFLAGS+= -DENABLE_BLKID
+endif
+
 
 GCFLAGS = $(OPTIMIZER) $(DEBUG) \
 	  -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\"  \
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index d993fc0..5964eaf 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -18,7 +18,9 @@
 
 #include "libxfs.h"
 #include <ctype.h>
-#include <blkid/blkid.h>
+#ifdef ENABLE_BLKID
+#  include <blkid/blkid.h>
+#endif /* ENABLE_BLKID */
 #include "xfs_mkfs.h"
 
 /*
@@ -298,6 +300,7 @@ calc_stripe_factors(
  *	 0 for nothing found
  *	-1 for internal error
  */
+#ifdef ENABLE_BLKID
 static int
 check_overwrite(
 	char		*device)
@@ -451,6 +454,38 @@ out_free_probe:
 		_("warning: unable to probe device topology for device %s\n"),
 		device);
 }
+#else /* ifdef ENABLE_BLKID */
+/*
+ * Without blkid, we can't do a good check for signatures.
+ * So instead of some messy attempts, just disable any checks
+ * and always return 'nothing found'.
+ */
+#  warning BLKID is disabled, so signature detection and block device\
+ access are not working!
+static int
+check_overwrite(
+	char		*device)
+{
+	return 1;
+}
+
+static void blkid_get_topology(
+	const char	*device,
+	int		*sunit,
+	int		*swidth,
+	int		*lsectorsize,
+	int		*psectorsize,
+	int		force_overwrite)
+{
+	/*
+	 * Shouldn't make any difference (no blkid = no block device access),
+	 * but make sure this dummy replacement returns with at least some
+	 * sanity.
+	 */
+	*lsectorsize = *psectorsize = 512;
+}
+
+#endif /* ENABLE_BLKID */
 
 static void get_topology(
 	libxfs_init_t		*xi,
-- 
2.4.5

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

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

* [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX
  2015-08-26 12:02 ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Jan Tulak
@ 2015-08-26 12:02   ` Jan Tulak
  2015-08-26 22:01     ` Dave Chinner
                       ` (2 more replies)
  2015-08-26 12:02   ` [PATCH 03/11] xfsprogs: Add includes required for OS X builds (delta) Jan Tulak
                     ` (9 subsequent siblings)
  10 siblings, 3 replies; 45+ messages in thread
From: Jan Tulak @ 2015-08-26 12:02 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 libhandle/handle.c       |  6 ++++--
 libhandle/jdm.c          |  6 ++++--
 libxfs/xfs_attr_remote.c |  2 +-
 libxfs/xfs_format.h      | 11 ++++++++++-
 4 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/libhandle/handle.c b/libhandle/handle.c
index b1c0c10..d532f44 100644
--- a/libhandle/handle.c
+++ b/libhandle/handle.c
@@ -21,6 +21,8 @@
 #include "xfs.h"
 #include "handle.h"
 #include "parent.h"
+#include "xfs/xfs_arch.h"
+#include "xfs/xfs_format.h"
 
 /* just pick a value we know is more than big enough */
 #define	MAXHANSIZ	64
@@ -397,8 +399,8 @@ attr_list_by_handle(
 	alhreq.buffer = buf;
 	alhreq.buflen = bufsize;
 	/* prevent needless EINVAL from the kernel */
-	if (alhreq.buflen > XATTR_LIST_MAX)
-		alhreq.buflen = XATTR_LIST_MAX;
+	if (alhreq.buflen > XFS_XATTR_LIST_MAX)
+		alhreq.buflen = XFS_XATTR_LIST_MAX;
 
 	error = xfsctl(path, fd, XFS_IOC_ATTRLIST_BY_HANDLE, &alhreq);
 
diff --git a/libhandle/jdm.c b/libhandle/jdm.c
index d804423..db7d1fe 100644
--- a/libhandle/jdm.c
+++ b/libhandle/jdm.c
@@ -21,6 +21,8 @@
 #include "handle.h"
 #include "jdm.h"
 #include "parent.h"
+#include "xfs/xfs_arch.h"
+#include "xfs/xfs_format.h"
 
 /* internal fshandle - typecast to a void for external use */
 #define FSHANDLE_SZ		8
@@ -168,8 +170,8 @@ jdm_attr_list(	jdm_fshandle_t *fshp,
 	int rval;
 
 	/* prevent needless EINVAL from the kernel */
-	if (bufsz > XATTR_LIST_MAX)
-		bufsz = XATTR_LIST_MAX;
+	if (bufsz > XFS_XATTR_LIST_MAX)
+		bufsz = XFS_XATTR_LIST_MAX;
 
 	jdm_fill_filehandle( &filehandle, fshandlep, statp );
 	rval = attr_list_by_handle (( void * )&filehandle,
diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c
index 5feaf55..98893e2 100644
--- a/libxfs/xfs_attr_remote.c
+++ b/libxfs/xfs_attr_remote.c
@@ -102,7 +102,7 @@ xfs_attr3_rmt_verify(
 	if (be32_to_cpu(rmt->rm_bytes) > fsbsize - sizeof(*rmt))
 		return false;
 	if (be32_to_cpu(rmt->rm_offset) +
-				be32_to_cpu(rmt->rm_bytes) > XATTR_SIZE_MAX)
+				be32_to_cpu(rmt->rm_bytes) > XFS_XATTR_SIZE_MAX)
 		return false;
 	if (rmt->rm_owner == 0)
 		return false;
diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h
index bb7cc04..2380084 100644
--- a/libxfs/xfs_format.h
+++ b/libxfs/xfs_format.h
@@ -60,6 +60,14 @@ struct xfs_ifork;
 #define	XFS_SB_VERSION_MOREBITSBIT	0x8000
 
 /*
+ * Avoid dependency on linux values of XATTR.
+ * It has to be on the beginning of this file, because we use these Values
+ * later in this header file.
+ */
+#define XFS_XATTR_SIZE_MAX 65536    /* size of an extended attribute value (64k) */
+#define XFS_XATTR_LIST_MAX 65536    /* size of extended attribute namelist (64k) */
+
+/*
  * Supported feature bit list is just all bits in the versionnum field because
  * we've used them all up and understand them all. Except, of course, for the
  * shared superblock bit, which nobody knows what it does and so is unsupported.
@@ -1483,7 +1491,7 @@ struct xfs_acl {
  */
 #define XFS_ACL_MAX_ENTRIES(mp)	\
 	(xfs_sb_version_hascrc(&mp->m_sb) \
-		?  (XATTR_SIZE_MAX - sizeof(struct xfs_acl)) / \
+		?  (XFS_XATTR_SIZE_MAX - sizeof(struct xfs_acl)) / \
 						sizeof(struct xfs_acl_entry) \
 		: 25)
 
@@ -1497,4 +1505,5 @@ struct xfs_acl {
 #define SGI_ACL_FILE_SIZE	(sizeof(SGI_ACL_FILE)-1)
 #define SGI_ACL_DEFAULT_SIZE	(sizeof(SGI_ACL_DEFAULT)-1)
 
+
 #endif /* __XFS_FORMAT_H__ */
-- 
2.4.5

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

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

* [PATCH 03/11] xfsprogs: Add includes required for OS X builds (delta)
  2015-08-26 12:02 ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Jan Tulak
  2015-08-26 12:02   ` [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX Jan Tulak
@ 2015-08-26 12:02   ` Jan Tulak
  2015-08-31 18:58     ` Christoph Hellwig
  2015-08-26 12:02   ` [PATCH 04/11] xfsprogs: Add autoconf check for fsetxattr call Jan Tulak
                     ` (8 subsequent siblings)
  10 siblings, 1 reply; 45+ messages in thread
From: Jan Tulak @ 2015-08-26 12:02 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Delta patch, an older version missing 3 includes was merged
into 4.2.0-rc2.

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

diff --git a/include/darwin.h b/include/darwin.h
index b904898..8b5a661 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -18,6 +18,9 @@
 #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>
-- 
2.4.5

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

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

* [PATCH 04/11] xfsprogs: Add autoconf check for fsetxattr call
  2015-08-26 12:02 ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Jan Tulak
  2015-08-26 12:02   ` [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX Jan Tulak
  2015-08-26 12:02   ` [PATCH 03/11] xfsprogs: Add includes required for OS X builds (delta) Jan Tulak
@ 2015-08-26 12:02   ` Jan Tulak
  2015-08-31 18:59     ` Christoph Hellwig
  2015-08-26 12:02   ` [PATCH 05/11] xfsprogs: uuid changes for OS X Jan Tulak
                     ` (7 subsequent siblings)
  10 siblings, 1 reply; 45+ messages in thread
From: Jan Tulak @ 2015-08-26 12:02 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

OS X has fsetxattr() in another header and with different arguments.
For now, check for the Linux variant and if not available, skip
the code using the call.

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

diff --git a/configure.ac b/configure.ac
index 0446620..13aa308 100644
--- a/configure.ac
+++ b/configure.ac
@@ -123,6 +123,7 @@ AC_HAVE_SYNC_FILE_RANGE
 AC_HAVE_MNTENT
 AC_HAVE_FLS
 AC_HAVE_READDIR
+AC_HAVE_FSETXATTR
 
 if test "$enable_blkid" = yes; then
 AC_HAVE_BLKID_TOPO
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index b673761..e1b7bd6 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -1025,6 +1025,7 @@ fsr_setup_attr_fork(
 	int		tfd,
 	xfs_bstat_t	*bstatp)
 {
+#ifdef HAVE_FSETXATTR
 	struct stat64	tstatbuf;
 	int		i;
 	int		diff = 0;
@@ -1199,6 +1200,7 @@ out:
 	if (dflag && diff)
 		fsrprintf(_("failed to match fork offset\n"));;
 
+#endif /* HAVE_FSETXATTR */
 	return 0;
 }
 
diff --git a/include/builddefs.in b/include/builddefs.in
index 6c16a65..25b8816 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -106,6 +106,7 @@ HAVE_SYNC_FILE_RANGE = @have_sync_file_range@
 HAVE_READDIR = @have_readdir@
 HAVE_MNTENT = @have_mntent@
 HAVE_FLS = @have_fls@
+HAVE_FSETXATTR = @have_fsetxattr@
 
 GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall 
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
@@ -139,6 +140,9 @@ endif
 ifeq ($(HAVE_MNTENT),yes)
 PCFLAGS+= -DHAVE_MNTENT
 endif
+ifeq ($(HAVE_FSETXATTR),yes)
+PCFLAGS+= -DHAVE_FSETXATTR
+endif
 ifeq ($(ENABLE_BLKID),yes)
 PCFLAGS+= -DENABLE_BLKID
 endif
diff --git a/m4/package_libcdev.m4 b/m4/package_libcdev.m4
index 4a96374..5e900ab 100644
--- a/m4/package_libcdev.m4
+++ b/m4/package_libcdev.m4
@@ -215,6 +215,19 @@ AC_DEFUN([AC_HAVE_FLS],
   ])
 
 #
+# Check if we have a fsetxattr call (Mac OS X)
+#
+AC_DEFUN([AC_HAVE_FSETXATTR],
+  [ AC_CHECK_DECL([fsetxattr],
+       have_fsetxattr=yes,
+       [],
+       [#include <sys/types.h>
+        #include <attr/xattr.h>]
+       )
+    AC_SUBST(have_fsetxattr)
+  ])
+
+#
 # Check if there is mntent.h
 #
 AC_DEFUN([AC_HAVE_MNTENT],
-- 
2.4.5

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

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

* [PATCH 05/11] xfsprogs: uuid changes for OS X
  2015-08-26 12:02 ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Jan Tulak
                     ` (2 preceding siblings ...)
  2015-08-26 12:02   ` [PATCH 04/11] xfsprogs: Add autoconf check for fsetxattr call Jan Tulak
@ 2015-08-26 12:02   ` Jan Tulak
  2015-08-31 18:59     ` Christoph Hellwig
  2015-08-26 12:02   ` [PATCH 06/11] xfsprogs: Remove conflicting define " Jan Tulak
                     ` (6 subsequent siblings)
  10 siblings, 1 reply; 45+ messages in thread
From: Jan Tulak @ 2015-08-26 12:02 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

UUID API changed in OS X in last few years, so fix the platform_ calls.

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

diff --git a/include/darwin.h b/include/darwin.h
index 8b5a661..82ccf04 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -76,45 +76,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(*uu1, *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);
 }
 
 typedef unsigned char		__u8;
-- 
2.4.5

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

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

* [PATCH 06/11] xfsprogs: Remove conflicting define for OS X
  2015-08-26 12:02 ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Jan Tulak
                     ` (3 preceding siblings ...)
  2015-08-26 12:02   ` [PATCH 05/11] xfsprogs: uuid changes for OS X Jan Tulak
@ 2015-08-26 12:02   ` Jan Tulak
  2015-08-31 18:59     ` Christoph Hellwig
  2015-08-26 12:02   ` [PATCH 07/11] xfsprogs: add nftw64 translation " Jan Tulak
                     ` (5 subsequent siblings)
  10 siblings, 1 reply; 45+ messages in thread
From: Jan Tulak @ 2015-08-26 12:02 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

ENOATTR already exists in OS X.

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

diff --git a/include/darwin.h b/include/darwin.h
index 82ccf04..72d9c1d 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -151,7 +151,6 @@ 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 *
-- 
2.4.5

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

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

* [PATCH 07/11] xfsprogs: add nftw64 translation for OS X
  2015-08-26 12:02 ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Jan Tulak
                     ` (4 preceding siblings ...)
  2015-08-26 12:02   ` [PATCH 06/11] xfsprogs: Remove conflicting define " Jan Tulak
@ 2015-08-26 12:02   ` Jan Tulak
  2015-08-31 18:59     ` Christoph Hellwig
  2015-09-03 10:39     ` [PATCH v2 07/11] xfsprogs: change nftw64 to nftw Jan Tulak
  2015-08-26 12:02   ` [PATCH 08/11] xfsprogs: Add a timer implementation for OS X Jan Tulak
                     ` (4 subsequent siblings)
  10 siblings, 2 replies; 45+ messages in thread
From: Jan Tulak @ 2015-08-26 12:02 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

OS X has only nftw variant - not the 64 suffix used in xfs.

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

diff --git a/include/darwin.h b/include/darwin.h
index 72d9c1d..94e7551 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -163,4 +163,10 @@ platform_discard_blocks(int fd, uint64_t start, uint64_t len)
 	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);
+}
+
 #endif	/* __XFS_DARWIN_H__ */
-- 
2.4.5

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

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

* [PATCH 08/11] xfsprogs: Add a timer implementation for OS X
  2015-08-26 12:02 ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Jan Tulak
                     ` (5 preceding siblings ...)
  2015-08-26 12:02   ` [PATCH 07/11] xfsprogs: add nftw64 translation " Jan Tulak
@ 2015-08-26 12:02   ` Jan Tulak
  2015-08-31 19:00     ` Christoph Hellwig
  2015-08-26 12:02   ` [PATCH 09/11] xfsprogs: Add statvfs64 for osx Jan Tulak
                     ` (3 subsequent siblings)
  10 siblings, 1 reply; 45+ messages in thread
From: Jan Tulak @ 2015-08-26 12:02 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

OS X does not have the timer used in xfs_repair.
Add a simple implementation providing the required
capabilities.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 include/darwin.h  | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 repair/progress.c | 16 ++++++++++++++--
 2 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/include/darwin.h b/include/darwin.h
index 94e7551..f5f28df 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -28,6 +28,7 @@
 #include <sys/ioctl.h>
 #include <sys/mount.h>
 #include <sys/types.h>
+#include <sys/time.h>
 #include <ftw.h>
 #include <mach/mach_time.h>
 #include <inttypes.h>
@@ -169,4 +170,51 @@ static inline int nftw64(const char *path, int (*fn)(const char *, const struct
 	return nftw(path, fn, depth, flags);
 }
 
+/*
+ * POSIX timer replacement.
+ * It really just do the minimum we need for xfs_repair.
+ * Also, as setitimer can't create multiple timers,
+ * the timerid things are useless - we have only one ITIMER_REAL
+ * timer.
+ */
+#define CLOCK_REALTIME ITIMER_REAL
+#define itimerspec itimerval
+typedef uint64_t timer_t;
+typedef double   timer_c;
+typedef clock_id_t clockid_t;
+
+
+static inline int timer_create (clockid_t __clock_id,
+                         struct sigevent *__restrict __evp,
+                         timer_t *__restrict timer)
+{
+	// set something, to initialize the variable, just in case
+	*timer = 0;
+	return 0;
+}
+
+static inline int timer_settime (timer_t timerid, int flags,
+                          const struct itimerspec *__restrict timerspec,
+                          struct itimerspec *__restrict ovalue)
+{
+	return setitimer(ITIMER_REAL, timerspec, ovalue);
+}
+
+static inline int timer_delete (timer_t timerid)
+{
+	struct itimerspec timespec;
+
+	timespec.it_interval.tv_sec=0;
+	timespec.it_interval.tv_usec=0;
+	timespec.it_value.tv_sec=0;
+	timespec.it_value.tv_usec=0;
+
+	return setitimer(ITIMER_REAL, &timespec, NULL);
+}
+
+static inline int timer_gettime (timer_t timerid, struct itimerspec *value)
+{
+	return getitimer(ITIMER_REAL, value);
+}
+
 #endif	/* __XFS_DARWIN_H__ */
diff --git a/repair/progress.c b/repair/progress.c
index 27cbaef..0fee7dc 100644
--- a/repair/progress.c
+++ b/repair/progress.c
@@ -184,10 +184,22 @@ progress_rpt_thread (void *p)
 	 */
 
 	timespec.it_value.tv_sec = msgp->interval;
-	timespec.it_value.tv_nsec = 0;
 	timespec.it_interval.tv_sec = msgp->interval;
+	/*
+	 * On some platforms (like OS X), timers and time things are slightly
+	 * different: itimerspec is replaced with itimerval and timeval struct
+	 * has no tv_nsec, but just tv_usec member.
+	 * For compatibility, itimerspec is a macro defined to the existing
+	 * itimerval on these platforms, and in such case, use usec instead
+	 * of nsec.
+	 */
+#ifndef itimerspec
+	timespec.it_value.tv_nsec = 0;
 	timespec.it_interval.tv_nsec = 0;
-
+#else
+	timespec.it_value.tv_usec = 0;
+	timespec.it_interval.tv_usec = 0;
+#endif
 	if (timer_create (CLOCK_REALTIME, NULL, &timerid))
 		do_error(_("progress_rpt: cannot create timer\n"));
 
-- 
2.4.5

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

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

* [PATCH 09/11] xfsprogs: Add statvfs64 for osx
  2015-08-26 12:02 ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Jan Tulak
                     ` (6 preceding siblings ...)
  2015-08-26 12:02   ` [PATCH 08/11] xfsprogs: Add a timer implementation for OS X Jan Tulak
@ 2015-08-26 12:02   ` Jan Tulak
  2015-09-08 14:24     ` [PATCH 09/11 v2] " Jan Tulak
  2015-08-26 12:02   ` [PATCH 10/11] xfsprogs: add dummy mntent for OS X Jan Tulak
                     ` (2 subsequent siblings)
  10 siblings, 1 reply; 45+ messages in thread
From: Jan Tulak @ 2015-08-26 12:02 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Use dummy stuff. It is used only in xfs_fsr, so it is not a big issue.
However, there is a part of an attempted solution to translate it to
OS X variant - statfs.

OS X statfs is missing f_frsize member in the struct, so its use would
require some #ifdef in fsr code. Because of this, the dummy stuff is used.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 fsr/xfs_fsr.c        |  6 ++++++
 include/builddefs.in |  2 +-
 include/darwin.h     | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index e1b7bd6..b7ac1b2 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -36,6 +36,12 @@
 #  include <mntent.h>
 #endif
 
+#ifdef __APPLE__
+//#  define statvfs64 statfs;
+#  include <sys/param.h>
+#  include <sys/mount.h>
+#endif
+
 #ifndef XFS_XFLAG_NODEFRAG
 #define XFS_XFLAG_NODEFRAG 0x00002000 /* src dependancy, remove later */
 #endif
diff --git a/include/builddefs.in b/include/builddefs.in
index 25b8816..31e21ba 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -123,7 +123,7 @@ PCFLAGS = -D_GNU_SOURCE $(GCCFLAGS)
 endif
 ifeq ($(PKG_PLATFORM),darwin)
 PCFLAGS = $(GCCFLAGS)
-DEPENDFLAGS = -D__APPLE__
+DEPENDFLAGS = -D__APPLE__ -D_DARWIN_FEATURE_64_BIT_INODE
 endif
 ifeq ($(PKG_PLATFORM),irix)
 PLDLIBS = -ldisk -lgen
diff --git a/include/darwin.h b/include/darwin.h
index f5f28df..c8fcb3c 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -217,4 +217,37 @@ static inline int timer_gettime (timer_t timerid, struct itimerspec *value)
 	return getitimer(ITIMER_REAL, value);
 }
 
+/* FSR */
+
+//#define statvfs64 statfs
+#define		_PATH_MOUNTED   "/etc/mtab"
+
+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];
+};
+
+static inline int statvfs64 (const char *__restrict __file,
+							 struct statfs *__restrict __buf)
+{
+	return 0;
+}
+
 #endif	/* __XFS_DARWIN_H__ */
-- 
2.4.5

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

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

* [PATCH 10/11] xfsprogs: add dummy mntent for OS X
  2015-08-26 12:02 ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Jan Tulak
                     ` (7 preceding siblings ...)
  2015-08-26 12:02   ` [PATCH 09/11] xfsprogs: Add statvfs64 for osx Jan Tulak
@ 2015-08-26 12:02   ` Jan Tulak
  2015-08-31 19:01     ` Christoph Hellwig
  2015-09-08 14:23     ` [PATCH 10/11 v2] xfsprogs: make fsr use mntinfo when there is no mntent Jan Tulak
  2015-08-26 12:02   ` [PATCH 11/11] xfsprogs: add dummy mremap for OS X Jan Tulak
  2015-08-31 18:57   ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Christoph Hellwig
  10 siblings, 2 replies; 45+ messages in thread
From: Jan Tulak @ 2015-08-26 12:02 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Because these calls are used only by xfs_fsr, which can't
work on OS X unless a way how to mount XFS is found,
there is not use in implementing these calls.

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

diff --git a/include/darwin.h b/include/darwin.h
index c8fcb3c..d47c96c 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -244,6 +244,41 @@ struct statvfs64
 	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 statfs *__restrict __buf)
 {
-- 
2.4.5

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

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

* [PATCH 11/11] xfsprogs: add dummy mremap for OS X
  2015-08-26 12:02 ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Jan Tulak
                     ` (8 preceding siblings ...)
  2015-08-26 12:02   ` [PATCH 10/11] xfsprogs: add dummy mntent for OS X Jan Tulak
@ 2015-08-26 12:02   ` Jan Tulak
  2015-08-31 19:01     ` Christoph Hellwig
  2015-09-03 10:35     ` [PATCH v2] xfsprogs: Make mremap conditional Jan Tulak
  2015-08-31 18:57   ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Christoph Hellwig
  10 siblings, 2 replies; 45+ messages in thread
From: Jan Tulak @ 2015-08-26 12:02 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

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

diff --git a/include/darwin.h b/include/darwin.h
index d47c96c..2e16f65 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -33,6 +33,7 @@
 #include <mach/mach_time.h>
 #include <inttypes.h>
 #include <stdio.h>
+#include <sys/mman.h>
 
 #include <machine/endian.h>
 #define __BYTE_ORDER	BYTE_ORDER
@@ -217,6 +218,14 @@ static inline int timer_gettime (timer_t timerid, struct itimerspec *value)
 	return getitimer(ITIMER_REAL, value);
 }
 
+#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, ...)
+{
+	return MAP_FAILED;
+}
+
 /* FSR */
 
 //#define statvfs64 statfs
-- 
2.4.5

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

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

* Re: [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX
  2015-08-26 12:02   ` [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX Jan Tulak
@ 2015-08-26 22:01     ` Dave Chinner
  2015-08-27  6:06       ` Jan Tulak
  2015-08-27  6:02     ` Jan Tulak
  2015-08-31 18:58     ` [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX Christoph Hellwig
  2 siblings, 1 reply; 45+ messages in thread
From: Dave Chinner @ 2015-08-26 22:01 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

On Wed, Aug 26, 2015 at 02:02:26PM +0200, Jan Tulak wrote:
> Signed-off-by: Jan Tulak <jtulak@redhat.com>

Explanation of the change?

> ---
>  libhandle/handle.c       |  6 ++++--
>  libhandle/jdm.c          |  6 ++++--
>  libxfs/xfs_attr_remote.c |  2 +-
>  libxfs/xfs_format.h      | 11 ++++++++++-
>  4 files changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/libhandle/handle.c b/libhandle/handle.c
> index b1c0c10..d532f44 100644
> --- a/libhandle/handle.c
> +++ b/libhandle/handle.c
....
> diff --git a/libhandle/jdm.c b/libhandle/jdm.c
> index d804423..db7d1fe 100644
> --- a/libhandle/jdm.c
> +++ b/libhandle/jdm.c
> @@ -21,6 +21,8 @@
>  #include "handle.h"
>  #include "jdm.h"
>  #include "parent.h"
> +#include "xfs/xfs_arch.h"
> +#include "xfs/xfs_format.h"

I don't think you need the xfs/ prefix now.

> diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h
> index bb7cc04..2380084 100644
> --- a/libxfs/xfs_format.h
> +++ b/libxfs/xfs_format.h
> @@ -60,6 +60,14 @@ struct xfs_ifork;
>  #define	XFS_SB_VERSION_MOREBITSBIT	0x8000
>  
>  /*
> + * Avoid dependency on linux values of XATTR.
> + * It has to be on the beginning of this file, because we use these Values
> + * later in this header file.
> + */

This is an explanation of why the change is being made, not what
the definitions are for. This belongs in the commit message, not
the code.

> +#define XFS_XATTR_SIZE_MAX 65536    /* size of an extended attribute value (64k) */

We try to avoid comments like these for defines (they tend only to
be added to structure definitions now).

/*
 * The size of a single extended attribute on disk is limited by
 * the size of index values within the attribute entries themselves.
 * These are be16 fields, so we can only support attribute data
 * sizes up to 2^16 bytes in length.
 */
#define XFS_XATTR_SIZE_MAX	(1 << 16)


> +#define XFS_XATTR_LIST_MAX 65536    /* size of extended attribute namelist (64k) */

XATTR_LIST_MAX is not an on-disk format definition - it's a syscall
buffer size limit and is defined by the OS. This belongs in the
platform headers, such as:

#ifndef XATTR_LIST_MAX
#define XATTR_LIST_MAX	65536
#endif

And so in a common header (e.g. include/xfs.h after including the
platform headers):

#define XFS_XATTR_LIST_MAX	XATTR_LIST_MAX

IOWs, this is really two separate patches - one for the
XFS_XATTR_SIZE_MAX change (which also needs to go back to the
kernel) and one for XFS_XATTR_LIST_MAX (which is purely userspace).

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

* [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX
  2015-08-26 12:02   ` [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX Jan Tulak
  2015-08-26 22:01     ` Dave Chinner
@ 2015-08-27  6:02     ` Jan Tulak
  2015-09-03 10:33       ` [PATCH 02a/11] xfsprogs: Add XATTR_LIST_MAX to OS X headers Jan Tulak
  2015-08-31 18:58     ` [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX Christoph Hellwig
  2 siblings, 1 reply; 45+ messages in thread
From: Jan Tulak @ 2015-08-27  6:02 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Currently, we depends on Linux XATTR values for on disk
definitions. Which causes trouble on other platforms and
maybe also if these values were to change.

Fix it by creating a custom definition independent from
those in Linux (although with the same values).

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 libhandle/handle.c       |  6 ++++--
 libhandle/jdm.c          |  6 ++++--
 libxfs/xfs_attr_remote.c |  2 +-
 libxfs/xfs_format.h      | 11 ++++++++++-
 4 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/libhandle/handle.c b/libhandle/handle.c
index b1c0c10..d532f44 100644
--- a/libhandle/handle.c
+++ b/libhandle/handle.c
@@ -21,6 +21,8 @@
 #include "xfs.h"
 #include "handle.h"
 #include "parent.h"
+#include "xfs/xfs_arch.h"
+#include "xfs/xfs_format.h"
 
 /* just pick a value we know is more than big enough */
 #define	MAXHANSIZ	64
@@ -397,8 +399,8 @@ attr_list_by_handle(
 	alhreq.buffer = buf;
 	alhreq.buflen = bufsize;
 	/* prevent needless EINVAL from the kernel */
-	if (alhreq.buflen > XATTR_LIST_MAX)
-		alhreq.buflen = XATTR_LIST_MAX;
+	if (alhreq.buflen > XFS_XATTR_LIST_MAX)
+		alhreq.buflen = XFS_XATTR_LIST_MAX;
 
 	error = xfsctl(path, fd, XFS_IOC_ATTRLIST_BY_HANDLE, &alhreq);
 
diff --git a/libhandle/jdm.c b/libhandle/jdm.c
index d804423..db7d1fe 100644
--- a/libhandle/jdm.c
+++ b/libhandle/jdm.c
@@ -21,6 +21,8 @@
 #include "handle.h"
 #include "jdm.h"
 #include "parent.h"
+#include "xfs/xfs_arch.h"
+#include "xfs/xfs_format.h"
 
 /* internal fshandle - typecast to a void for external use */
 #define FSHANDLE_SZ		8
@@ -168,8 +170,8 @@ jdm_attr_list(	jdm_fshandle_t *fshp,
 	int rval;
 
 	/* prevent needless EINVAL from the kernel */
-	if (bufsz > XATTR_LIST_MAX)
-		bufsz = XATTR_LIST_MAX;
+	if (bufsz > XFS_XATTR_LIST_MAX)
+		bufsz = XFS_XATTR_LIST_MAX;
 
 	jdm_fill_filehandle( &filehandle, fshandlep, statp );
 	rval = attr_list_by_handle (( void * )&filehandle,
diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c
index 5feaf55..98893e2 100644
--- a/libxfs/xfs_attr_remote.c
+++ b/libxfs/xfs_attr_remote.c
@@ -102,7 +102,7 @@ xfs_attr3_rmt_verify(
 	if (be32_to_cpu(rmt->rm_bytes) > fsbsize - sizeof(*rmt))
 		return false;
 	if (be32_to_cpu(rmt->rm_offset) +
-				be32_to_cpu(rmt->rm_bytes) > XATTR_SIZE_MAX)
+				be32_to_cpu(rmt->rm_bytes) > XFS_XATTR_SIZE_MAX)
 		return false;
 	if (rmt->rm_owner == 0)
 		return false;
diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h
index bb7cc04..2380084 100644
--- a/libxfs/xfs_format.h
+++ b/libxfs/xfs_format.h
@@ -60,6 +60,14 @@ struct xfs_ifork;
 #define	XFS_SB_VERSION_MOREBITSBIT	0x8000
 
 /*
+ * Avoid dependency on linux values of XATTR.
+ * It has to be on the beginning of this file, because we use these Values
+ * later in this header file.
+ */
+#define XFS_XATTR_SIZE_MAX 65536    /* size of an extended attribute value (64k) */
+#define XFS_XATTR_LIST_MAX 65536    /* size of extended attribute namelist (64k) */
+
+/*
  * Supported feature bit list is just all bits in the versionnum field because
  * we've used them all up and understand them all. Except, of course, for the
  * shared superblock bit, which nobody knows what it does and so is unsupported.
@@ -1483,7 +1491,7 @@ struct xfs_acl {
  */
 #define XFS_ACL_MAX_ENTRIES(mp)	\
 	(xfs_sb_version_hascrc(&mp->m_sb) \
-		?  (XATTR_SIZE_MAX - sizeof(struct xfs_acl)) / \
+		?  (XFS_XATTR_SIZE_MAX - sizeof(struct xfs_acl)) / \
 						sizeof(struct xfs_acl_entry) \
 		: 25)
 
@@ -1497,4 +1505,5 @@ struct xfs_acl {
 #define SGI_ACL_FILE_SIZE	(sizeof(SGI_ACL_FILE)-1)
 #define SGI_ACL_DEFAULT_SIZE	(sizeof(SGI_ACL_DEFAULT)-1)
 
+
 #endif /* __XFS_FORMAT_H__ */
-- 
2.4.5

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

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

* Re: [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX
  2015-08-26 22:01     ` Dave Chinner
@ 2015-08-27  6:06       ` Jan Tulak
  0 siblings, 0 replies; 45+ messages in thread
From: Jan Tulak @ 2015-08-27  6:06 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Christoph Hellwig, xfs-oss


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

On Thu, Aug 27, 2015 at 12:01 AM, Dave Chinner <david@fromorbit.com> wrote:

> On Wed, Aug 26, 2015 at 02:02:26PM +0200, Jan Tulak wrote:
> > Signed-off-by: Jan Tulak <jtulak@redhat.com>
>
> Explanation of the change?
>

Submitted. And sorry, I realized I didn't add v2 to the patch the moment
I sent it.
​ ​
:-( Though only the commit message is changed.

​Cheers,
Jan​

--
Jan Tulak
jtulak@redhat.com / jan@tulak.me

[-- Attachment #1.2: Type: text/html, Size: 1440 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] 45+ messages in thread

* Re: [PATCH 01/11] xfsprogs: Add a way to compile without blkid
  2015-08-26 12:02 ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Jan Tulak
                     ` (9 preceding siblings ...)
  2015-08-26 12:02   ` [PATCH 11/11] xfsprogs: add dummy mremap for OS X Jan Tulak
@ 2015-08-31 18:57   ` Christoph Hellwig
  10 siblings, 0 replies; 45+ messages in thread
From: Christoph Hellwig @ 2015-08-31 18:57 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

On Wed, Aug 26, 2015 at 02:02:25PM +0200, Jan Tulak wrote:
> Because not all platforms have up-to-date blkid with required
> functions, allow at least partial functionality by adding
> --enable-blkid=yes/no optional configure argument.
> 
> When blkid is disabled, signature detection and device geometry
> detection doesn't work.

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

* Re: [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX
  2015-08-26 12:02   ` [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX Jan Tulak
  2015-08-26 22:01     ` Dave Chinner
  2015-08-27  6:02     ` Jan Tulak
@ 2015-08-31 18:58     ` Christoph Hellwig
  2015-09-01  8:13       ` Jan Tulak
  2 siblings, 1 reply; 45+ messages in thread
From: Christoph Hellwig @ 2015-08-31 18:58 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

> index b1c0c10..d532f44 100644
> --- a/libhandle/handle.c
> +++ b/libhandle/handle.c
> @@ -21,6 +21,8 @@
>  #include "xfs.h"
>  #include "handle.h"
>  #include "parent.h"
> +#include "xfs/xfs_arch.h"
> +#include "xfs/xfs_format.h"

These headers should not be used in libhandle.  As mentioned last time I
think libhandle should get it's own LIBHANDLE_XATTR_LIST_MAX define,
separate frome the one for the on disk format.

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

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

* Re: [PATCH 03/11] xfsprogs: Add includes required for OS X builds (delta)
  2015-08-26 12:02   ` [PATCH 03/11] xfsprogs: Add includes required for OS X builds (delta) Jan Tulak
@ 2015-08-31 18:58     ` Christoph Hellwig
  0 siblings, 0 replies; 45+ messages in thread
From: Christoph Hellwig @ 2015-08-31 18:58 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, 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] 45+ messages in thread

* Re: [PATCH 04/11] xfsprogs: Add autoconf check for fsetxattr call
  2015-08-26 12:02   ` [PATCH 04/11] xfsprogs: Add autoconf check for fsetxattr call Jan Tulak
@ 2015-08-31 18:59     ` Christoph Hellwig
  0 siblings, 0 replies; 45+ messages in thread
From: Christoph Hellwig @ 2015-08-31 18:59 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

Looks ok,

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

* Re: [PATCH 05/11] xfsprogs: uuid changes for OS X
  2015-08-26 12:02   ` [PATCH 05/11] xfsprogs: uuid changes for OS X Jan Tulak
@ 2015-08-31 18:59     ` Christoph Hellwig
  0 siblings, 0 replies; 45+ messages in thread
From: Christoph Hellwig @ 2015-08-31 18:59 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] 45+ messages in thread

* Re: [PATCH 06/11] xfsprogs: Remove conflicting define for OS X
  2015-08-26 12:02   ` [PATCH 06/11] xfsprogs: Remove conflicting define " Jan Tulak
@ 2015-08-31 18:59     ` Christoph Hellwig
  0 siblings, 0 replies; 45+ messages in thread
From: Christoph Hellwig @ 2015-08-31 18:59 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] 45+ messages in thread

* Re: [PATCH 07/11] xfsprogs: add nftw64 translation for OS X
  2015-08-26 12:02   ` [PATCH 07/11] xfsprogs: add nftw64 translation " Jan Tulak
@ 2015-08-31 18:59     ` Christoph Hellwig
  2015-09-01  7:49       ` Jan Tulak
  2015-09-01  8:04       ` [PATCH v2] " Jan Tulak
  2015-09-03 10:39     ` [PATCH v2 07/11] xfsprogs: change nftw64 to nftw Jan Tulak
  1 sibling, 2 replies; 45+ messages in thread
From: Christoph Hellwig @ 2015-08-31 18:59 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

On Wed, Aug 26, 2015 at 02:02:31PM +0200, Jan Tulak wrote:
> OS X has only nftw variant - not the 64 suffix used in xfs.

Can you just use a #define?

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

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

* Re: [PATCH 08/11] xfsprogs: Add a timer implementation for OS X
  2015-08-26 12:02   ` [PATCH 08/11] xfsprogs: Add a timer implementation for OS X Jan Tulak
@ 2015-08-31 19:00     ` Christoph Hellwig
  2015-09-02 10:54       ` Jan Tulak
  0 siblings, 1 reply; 45+ messages in thread
From: Christoph Hellwig @ 2015-08-31 19:00 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

On Wed, Aug 26, 2015 at 02:02:32PM +0200, Jan Tulak wrote:
> OS X does not have the timer used in xfs_repair.
> Add a simple implementation providing the required
> capabilities.

This doesn't look like it would actually work.

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

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

* Re: [PATCH 10/11] xfsprogs: add dummy mntent for OS X
  2015-08-26 12:02   ` [PATCH 10/11] xfsprogs: add dummy mntent for OS X Jan Tulak
@ 2015-08-31 19:01     ` Christoph Hellwig
  2015-09-03  9:01       ` Jan Tulak
  2015-09-08 14:23     ` [PATCH 10/11 v2] xfsprogs: make fsr use mntinfo when there is no mntent Jan Tulak
  1 sibling, 1 reply; 45+ messages in thread
From: Christoph Hellwig @ 2015-08-31 19:01 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

On Wed, Aug 26, 2015 at 02:02:34PM +0200, Jan Tulak wrote:
> Because these calls are used only by xfs_fsr, which can't
> work on OS X unless a way how to mount XFS is found,
> there is not use in implementing these calls.

Take a look at the quota code for the BSD alternative to mntent.
That code should be moved into a common location and used by fsr.

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

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

* Re: [PATCH 11/11] xfsprogs: add dummy mremap for OS X
  2015-08-26 12:02   ` [PATCH 11/11] xfsprogs: add dummy mremap for OS X Jan Tulak
@ 2015-08-31 19:01     ` Christoph Hellwig
  2015-09-03 10:35     ` [PATCH v2] xfsprogs: Make mremap conditional Jan Tulak
  1 sibling, 0 replies; 45+ messages in thread
From: Christoph Hellwig @ 2015-08-31 19:01 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

NAK - just don't compile the mremap support in xfs_io if support
for it is missing in the OS.

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

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

* Re: [PATCH 07/11] xfsprogs: add nftw64 translation for OS X
  2015-08-31 18:59     ` Christoph Hellwig
@ 2015-09-01  7:49       ` Jan Tulak
  2015-09-01  8:04       ` [PATCH v2] " Jan Tulak
  1 sibling, 0 replies; 45+ messages in thread
From: Jan Tulak @ 2015-09-01  7:49 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs-oss


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

On Mon, Aug 31, 2015 at 8:59 PM, Christoph Hellwig <hch@infradead.org>
wrote:

> On Wed, Aug 26, 2015 at 02:02:31PM +0200, Jan Tulak wrote:
> > OS X has only nftw variant - not the 64 suffix used in xfs.
>
> Can you just use a #define?
>
>
​Yes, indeed I can. Changed... :-)

Jan

-- 
Jan Tulak
jtulak@redhat.com / jan@tulak.me

[-- Attachment #1.2: Type: text/html, Size: 1431 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] 45+ messages in thread

* [PATCH v2] xfsprogs: add nftw64 translation for OS X
  2015-08-31 18:59     ` Christoph Hellwig
  2015-09-01  7:49       ` Jan Tulak
@ 2015-09-01  8:04       ` Jan Tulak
  2015-09-01 16:31         ` Darrick J. Wong
  1 sibling, 1 reply; 45+ messages in thread
From: Jan Tulak @ 2015-09-01  8:04 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

UPDATE: changed to #define

OS X has only nftw variant - not the 64 suffix used in xfs.

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

diff --git a/include/darwin.h b/include/darwin.h
index 72d9c1d..f0f05b3 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -157,6 +157,8 @@ typedef int64_t		xfs_daddr_t;
 
 #define HAVE_FID	1
 
+#define nftw64 nftw
+
 static __inline__ int
 platform_discard_blocks(int fd, uint64_t start, uint64_t len)
 {
-- 
2.4.3

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

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

* Re: [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX
  2015-08-31 18:58     ` [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX Christoph Hellwig
@ 2015-09-01  8:13       ` Jan Tulak
  2015-09-01  8:35         ` Jan Tulak
  0 siblings, 1 reply; 45+ messages in thread
From: Jan Tulak @ 2015-09-01  8:13 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs-oss


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

On Mon, Aug 31, 2015 at 8:58 PM, Christoph Hellwig <hch@infradead.org>
wrote:

> > index b1c0c10..d532f44 100644
> > --- a/libhandle/handle.c
> > +++ b/libhandle/handle.c
> > @@ -21,6 +21,8 @@
> >  #include "xfs.h"
> >  #include "handle.h"
> >  #include "parent.h"
> > +#include "xfs/xfs_arch.h"
> > +#include "xfs/xfs_format.h"
>
> These headers should not be used in libhandle.  As mentioned last time I
> think libhandle should get it's own LIBHANDLE_XATTR_LIST_MAX define,
> separate frome the one for the on disk format.
>

​Well, you wrote about adding it into xfs_format.h. I don't recall (and
can't find) anything else regarding XATTR_SIZE...

> Eww, looks like we depend on these Linux values in the on disk
> defintion.  I think we need to add new XFS_XATTR_SIZE_MAX and
> XFS_XATTR_LIST_MAX defintions to xfs_format.h and use them where
> we currently use these.

So ​

​the XFS_ defines in xfs_format​.h should be there, I just need to add
another LIBHANDLE_ variant so we don't include the headers, right?

​Cheers,
Jan​




-- 
Jan Tulak
jtulak@redhat.com / jan@tulak.me

[-- Attachment #1.2: Type: text/html, Size: 3480 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] 45+ messages in thread

* Re: [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX
  2015-09-01  8:13       ` Jan Tulak
@ 2015-09-01  8:35         ` Jan Tulak
  0 siblings, 0 replies; 45+ messages in thread
From: Jan Tulak @ 2015-09-01  8:35 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs-oss


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

Ah, never mind, I noticed I didn't read the last part of Dave's email. It
looks clear now.

Jan

On Tue, Sep 1, 2015 at 10:13 AM, Jan Tulak <jtulak@redhat.com> wrote:

> On Mon, Aug 31, 2015 at 8:58 PM, Christoph Hellwig <hch@infradead.org>
> wrote:
>
>> > index b1c0c10..d532f44 100644
>> > --- a/libhandle/handle.c
>> > +++ b/libhandle/handle.c
>> > @@ -21,6 +21,8 @@
>> >  #include "xfs.h"
>> >  #include "handle.h"
>> >  #include "parent.h"
>> > +#include "xfs/xfs_arch.h"
>> > +#include "xfs/xfs_format.h"
>>
>> These headers should not be used in libhandle.  As mentioned last time I
>> think libhandle should get it's own LIBHANDLE_XATTR_LIST_MAX define,
>> separate frome the one for the on disk format.
>>
>
> ​Well, you wrote about adding it into xfs_format.h. I don't recall (and
> can't find) anything else regarding XATTR_SIZE...
>
> > Eww, looks like we depend on these Linux values in the on disk
> > defintion.  I think we need to add new XFS_XATTR_SIZE_MAX and
> > XFS_XATTR_LIST_MAX defintions to xfs_format.h and use them where
> > we currently use these.
>
> So ​
>
> ​the XFS_ defines in xfs_format​.h should be there, I just need to add
> another LIBHANDLE_ variant so we don't include the headers, right?
>
> ​Cheers,
> Jan​
>
>
>
>
> --
> Jan Tulak
> jtulak@redhat.com / jan@tulak.me
>



-- 
Jan Tulak
jtulak@redhat.com / jan@tulak.me

[-- Attachment #1.2: Type: text/html, Size: 4535 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] 45+ messages in thread

* Re: [PATCH v2] xfsprogs: add nftw64 translation for OS X
  2015-09-01  8:04       ` [PATCH v2] " Jan Tulak
@ 2015-09-01 16:31         ` Darrick J. Wong
  2015-09-01 17:24           ` Christoph Hellwig
  2015-09-02  7:12           ` Jan Tulak
  0 siblings, 2 replies; 45+ messages in thread
From: Darrick J. Wong @ 2015-09-01 16:31 UTC (permalink / raw)
  To: Jan Tulak; +Cc: hch, xfs

On Tue, Sep 01, 2015 at 10:04:32AM +0200, Jan Tulak wrote:
> UPDATE: changed to #define
> 
> OS X has only nftw variant - not the 64 suffix used in xfs.
> 
> Signed-off-by: Jan Tulak <jtulak@redhat.com>
> ---
>  include/darwin.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/darwin.h b/include/darwin.h
> index 72d9c1d..f0f05b3 100644
> --- a/include/darwin.h
> +++ b/include/darwin.h
> @@ -157,6 +157,8 @@ typedef int64_t		xfs_daddr_t;
>  
>  #define HAVE_FID	1
>  
> +#define nftw64 nftw
> +

Sorry for chiming in late, but there's only one caller of nftw64 and several
callers of nftw; why not just change it to use nftw?

<shrug> There could be other reasons why xfs_estimate requires the -64
variant, but I don't know. :)

--D

>  static __inline__ int
>  platform_discard_blocks(int fd, uint64_t start, uint64_t len)
>  {
> -- 
> 2.4.3
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

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

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

* Re: [PATCH v2] xfsprogs: add nftw64 translation for OS X
  2015-09-01 16:31         ` Darrick J. Wong
@ 2015-09-01 17:24           ` Christoph Hellwig
  2015-09-02  7:12           ` Jan Tulak
  1 sibling, 0 replies; 45+ messages in thread
From: Christoph Hellwig @ 2015-09-01 17:24 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: hch, xfs, Jan Tulak

On Tue, Sep 01, 2015 at 09:31:20AM -0700, Darrick J. Wong wrote:
> Sorry for chiming in late, but there's only one caller of nftw64 and several
> callers of nftw; why not just change it to use nftw?

That sounds even better.

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

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

* Re: [PATCH v2] xfsprogs: add nftw64 translation for OS X
  2015-09-01 16:31         ` Darrick J. Wong
  2015-09-01 17:24           ` Christoph Hellwig
@ 2015-09-02  7:12           ` Jan Tulak
  1 sibling, 0 replies; 45+ messages in thread
From: Jan Tulak @ 2015-09-02  7:12 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Christoph Hellwig, xfs-oss


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

On Tue, Sep 1, 2015 at 6:31 PM, Darrick J. Wong <darrick.wong@oracle.com>
wrote:

> On Tue, Sep 01, 2015 at 10:04:32AM +0200, Jan Tulak wrote:
> > UPDATE: changed to #define
> >
> > OS X has only nftw variant - not the 64 suffix used in xfs.
> >
> > Signed-off-by: Jan Tulak <jtulak@redhat.com>
> > ---
> >  include/darwin.h | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/include/darwin.h b/include/darwin.h
> > index 72d9c1d..f0f05b3 100644
> > --- a/include/darwin.h
> > +++ b/include/darwin.h
> > @@ -157,6 +157,8 @@ typedef int64_t           xfs_daddr_t;
> >
> >  #define HAVE_FID     1
> >
> > +#define nftw64 nftw
> > +
>
> Sorry for chiming in late, but there's only one caller of nftw64 and
> several
> callers of nftw; why not just change it to use nftw?
>
> <shrug> There could be other reasons why xfs_estimate requires the -64
> variant, but I don't know. :)
>

​Good idea. I'll run tests after the change​

​and if nothing bad happens, I send
it here.
​
-- 
Jan Tulak
jtulak@redhat.com / jan@tulak.me

[-- Attachment #1.2: Type: text/html, Size: 2284 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] 45+ messages in thread

* Re: [PATCH 08/11] xfsprogs: Add a timer implementation for OS X
  2015-08-31 19:00     ` Christoph Hellwig
@ 2015-09-02 10:54       ` Jan Tulak
  0 siblings, 0 replies; 45+ messages in thread
From: Jan Tulak @ 2015-09-02 10:54 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs-oss


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

On Mon, Aug 31, 2015 at 9:00 PM, Christoph Hellwig <hch@infradead.org>
wrote:

> On Wed, Aug 26, 2015 at 02:02:32PM +0200, Jan Tulak wrote:
> > OS X does not have the timer used in xfs_repair.
> > Add a simple implementation providing the required
> > capabilities.
>
> This doesn't look like it would actually work.
>

​As I understand the timer usage, it should periodically send a signal. The
timer code I posted really does this, at least when I take the timer_*
functions "as it is" outside and test them, calling them in the same order
as in the repair code. I tested that before sending the patch.

I have to try it in xfs_repair yet - this is limited by having small
storage space for a filesystem, where the reporting interval would be
noticeable. The best thing for this I have now is an old USB2 8 GB flash
drive, filled with multiple copies of installed Debian. However, even on a
raspberry pi, it still runs quickly. I guess few hundreds of GB would do
it, but I need to dig out an old USB2-sata reduction somewhere and a HDD...
(And I didn't noticed any difference in output.)

So in meantime, why do you think this won't work?

Cheers,
Jan

-- 
Jan Tulak
jtulak@redhat.com / jan@tulak.me

[-- Attachment #1.2: Type: text/html, Size: 3183 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] 45+ messages in thread

* Re: [PATCH 10/11] xfsprogs: add dummy mntent for OS X
  2015-08-31 19:01     ` Christoph Hellwig
@ 2015-09-03  9:01       ` Jan Tulak
  2015-09-03 10:33         ` Dave Chinner
  0 siblings, 1 reply; 45+ messages in thread
From: Jan Tulak @ 2015-09-03  9:01 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs-oss


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

On Mon, Aug 31, 2015 at 9:01 PM, Christoph Hellwig <hch@infradead.org>
wrote:

> On Wed, Aug 26, 2015 at 02:02:34PM +0200, Jan Tulak wrote:
> > Because these calls are used only by xfs_fsr, which can't
> > work on OS X unless a way how to mount XFS is found,
> > there is not use in implementing these calls.
>
> Take a look at the quota code for the BSD alternative to mntent.
> That code should be moved into a common location and used by fsr.
>

​I tried to find it, but didn't found... Could you point me where it is?
Quota/freebsd.h has just few lines with one definition with errno =
-ENOSYS, and in other files in quota/, I didn't saw anything BSD specific.

Thanks,
Jan


-- 
Jan Tulak
jtulak@redhat.com / jan@tulak.me

[-- Attachment #1.2: Type: text/html, Size: 1811 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] 45+ messages in thread

* [PATCH 02a/11] xfsprogs: Add XATTR_LIST_MAX to OS X headers
  2015-08-27  6:02     ` Jan Tulak
@ 2015-09-03 10:33       ` Jan Tulak
  2015-09-03 10:33         ` [PATCH 02b/11] xfsprogs: avoid dependency on Linux XATTR_SIZE_MAX Jan Tulak
  2015-09-03 10:33         ` [PATCH 02c/11] xfsprogs: prefix XATTR_LIST_MAX with XFS_ Jan Tulak
  0 siblings, 2 replies; 45+ messages in thread
From: Jan Tulak @ 2015-09-03 10:33 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

OS X has no XATTR_LIST_MAX value. So add it to the platform header.

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

diff --git a/include/darwin.h b/include/darwin.h
index b904898..4b7ba3a 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -39,6 +39,11 @@
 # ifndef SYS_fsctl
 #  define SYS_fsctl	242
 # endif
+
+#ifndef XATTR_LIST_MAX
+#define XATTR_LIST_MAX  65536
+#endif
+
 static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p)
 {
 	return syscall(SYS_fsctl, path, cmd, p, 0);
-- 
2.4.5

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

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

* [PATCH 02b/11] xfsprogs: avoid dependency on Linux XATTR_SIZE_MAX
  2015-09-03 10:33       ` [PATCH 02a/11] xfsprogs: Add XATTR_LIST_MAX to OS X headers Jan Tulak
@ 2015-09-03 10:33         ` Jan Tulak
  2015-09-03 10:33         ` [PATCH 02c/11] xfsprogs: prefix XATTR_LIST_MAX with XFS_ Jan Tulak
  1 sibling, 0 replies; 45+ messages in thread
From: Jan Tulak @ 2015-09-03 10:33 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Currently, we depends on Linux XATTR value for on disk
definitions. Which causes trouble on other platforms and
maybe also if this value was to change.

Fix it by creating a custom definition independent from
those in Linux (although with the same values), so it is OK
with the be16 fields used for holding these attributes.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 libxfs/xfs_attr_remote.c |  2 +-
 libxfs/xfs_format.h      | 10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c
index 5feaf55..98893e2 100644
--- a/libxfs/xfs_attr_remote.c
+++ b/libxfs/xfs_attr_remote.c
@@ -102,7 +102,7 @@ xfs_attr3_rmt_verify(
 	if (be32_to_cpu(rmt->rm_bytes) > fsbsize - sizeof(*rmt))
 		return false;
 	if (be32_to_cpu(rmt->rm_offset) +
-				be32_to_cpu(rmt->rm_bytes) > XATTR_SIZE_MAX)
+				be32_to_cpu(rmt->rm_bytes) > XFS_XATTR_SIZE_MAX)
 		return false;
 	if (rmt->rm_owner == 0)
 		return false;
diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h
index bb7cc04..046b20f 100644
--- a/libxfs/xfs_format.h
+++ b/libxfs/xfs_format.h
@@ -60,6 +60,14 @@ struct xfs_ifork;
 #define	XFS_SB_VERSION_MOREBITSBIT	0x8000
 
 /*
+ * The size of a single extended attribute on disk is limited by
+ * the size of index values within the attribute entries themselves.
+ * These are be16 fields, so we can only support attribute data
+ * sizes up to 2^16 bytes in length.
+ */
+#define XFS_XATTR_SIZE_MAX (1 << 16)
+
+/*
  * Supported feature bit list is just all bits in the versionnum field because
  * we've used them all up and understand them all. Except, of course, for the
  * shared superblock bit, which nobody knows what it does and so is unsupported.
@@ -1483,7 +1491,7 @@ struct xfs_acl {
  */
 #define XFS_ACL_MAX_ENTRIES(mp)	\
 	(xfs_sb_version_hascrc(&mp->m_sb) \
-		?  (XATTR_SIZE_MAX - sizeof(struct xfs_acl)) / \
+		?  (XFS_XATTR_SIZE_MAX - sizeof(struct xfs_acl)) / \
 						sizeof(struct xfs_acl_entry) \
 		: 25)
 
-- 
2.4.5

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

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

* [PATCH 02c/11] xfsprogs: prefix XATTR_LIST_MAX with XFS_
  2015-09-03 10:33       ` [PATCH 02a/11] xfsprogs: Add XATTR_LIST_MAX to OS X headers Jan Tulak
  2015-09-03 10:33         ` [PATCH 02b/11] xfsprogs: avoid dependency on Linux XATTR_SIZE_MAX Jan Tulak
@ 2015-09-03 10:33         ` Jan Tulak
  1 sibling, 0 replies; 45+ messages in thread
From: Jan Tulak @ 2015-09-03 10:33 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

WILL CHANGE THE COMMIT MESSAGE.

All right, I make the renaming with define - though I'm not sure
that with the ifdef for OS X and SIZE_MAX moved to a standalone patch
we need it - shouldn't be this change rather dropped?

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 include/xfs.h      | 2 ++
 libhandle/handle.c | 4 ++--
 libhandle/jdm.c    | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/xfs.h b/include/xfs.h
index bc94068..8ee0106 100644
--- a/include/xfs.h
+++ b/include/xfs.h
@@ -53,6 +53,8 @@
 # define ASSERT(EX)	((void) 0)
 #endif
 
+#define XFS_XATTR_LIST_MAX XATTR_LIST_MAX
+
 /*
  * sparse kernel source annotations
  */
diff --git a/libhandle/handle.c b/libhandle/handle.c
index b1c0c10..7207186 100644
--- a/libhandle/handle.c
+++ b/libhandle/handle.c
@@ -397,8 +397,8 @@ attr_list_by_handle(
 	alhreq.buffer = buf;
 	alhreq.buflen = bufsize;
 	/* prevent needless EINVAL from the kernel */
-	if (alhreq.buflen > XATTR_LIST_MAX)
-		alhreq.buflen = XATTR_LIST_MAX;
+	if (alhreq.buflen > XFS_XATTR_LIST_MAX)
+		alhreq.buflen = XFS_XATTR_LIST_MAX;
 
 	error = xfsctl(path, fd, XFS_IOC_ATTRLIST_BY_HANDLE, &alhreq);
 
diff --git a/libhandle/jdm.c b/libhandle/jdm.c
index d804423..e52f5d8 100644
--- a/libhandle/jdm.c
+++ b/libhandle/jdm.c
@@ -168,8 +168,8 @@ jdm_attr_list(	jdm_fshandle_t *fshp,
 	int rval;
 
 	/* prevent needless EINVAL from the kernel */
-	if (bufsz > XATTR_LIST_MAX)
-		bufsz = XATTR_LIST_MAX;
+	if (bufsz > XFS_XATTR_LIST_MAX)
+		bufsz = XFS_XATTR_LIST_MAX;
 
 	jdm_fill_filehandle( &filehandle, fshandlep, statp );
 	rval = attr_list_by_handle (( void * )&filehandle,
-- 
2.4.5

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

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

* Re: [PATCH 10/11] xfsprogs: add dummy mntent for OS X
  2015-09-03  9:01       ` Jan Tulak
@ 2015-09-03 10:33         ` Dave Chinner
  2015-09-03 10:37           ` Jan Tulak
  0 siblings, 1 reply; 45+ messages in thread
From: Dave Chinner @ 2015-09-03 10:33 UTC (permalink / raw)
  To: Jan Tulak; +Cc: Christoph Hellwig, xfs-oss

On Thu, Sep 03, 2015 at 11:01:44AM +0200, Jan Tulak wrote:
> On Mon, Aug 31, 2015 at 9:01 PM, Christoph Hellwig <hch@infradead.org>
> wrote:
> 
> > On Wed, Aug 26, 2015 at 02:02:34PM +0200, Jan Tulak wrote:
> > > Because these calls are used only by xfs_fsr, which can't
> > > work on OS X unless a way how to mount XFS is found,
> > > there is not use in implementing these calls.
> >
> > Take a look at the quota code for the BSD alternative to mntent.
> > That code should be moved into a common location and used by fsr.
> >
> 
> ​I tried to find it, but didn't found... Could you point me where it is?
> Quota/freebsd.h has just few lines with one definition with errno =
> -ENOSYS, and in other files in quota/, I didn't saw anything BSD specific.

I think Christoph is refering to the code in libxcmd/paths.c:

#if defined(HAVE_GETMNTENT)
....
#elif defined(HAVE_GETMNTINFO)
....
#else
# error "How do I extract info about mounted filesystems on this platform?"
#endif
#

HAVE_GETMNTINFO is for BSD systems, IIRC.

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

* [PATCH v2] xfsprogs: Make mremap conditional
  2015-08-26 12:02   ` [PATCH 11/11] xfsprogs: add dummy mremap for OS X Jan Tulak
  2015-08-31 19:01     ` Christoph Hellwig
@ 2015-09-03 10:35     ` Jan Tulak
  1 sibling, 0 replies; 45+ messages in thread
From: Jan Tulak @ 2015-09-03 10:35 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Don't build mremap (in xfs_io) on platforms where it has no support.

CHANGELOG:
 - subject was xfsprogs: add dummy mremap for OS X

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 configure.ac          |  1 +
 include/builddefs.in  |  1 +
 include/darwin.h      |  1 +
 io/mmap.c             |  8 ++++++++
 m4/package_libcdev.m4 | 13 +++++++++++++
 5 files changed, 24 insertions(+)

diff --git a/configure.ac b/configure.ac
index 13aa308..01dd1a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -124,6 +124,7 @@ AC_HAVE_MNTENT
 AC_HAVE_FLS
 AC_HAVE_READDIR
 AC_HAVE_FSETXATTR
+AC_HAVE_MREMAP
 
 if test "$enable_blkid" = yes; then
 AC_HAVE_BLKID_TOPO
diff --git a/include/builddefs.in b/include/builddefs.in
index 31e21ba..c1797fd 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -107,6 +107,7 @@ HAVE_READDIR = @have_readdir@
 HAVE_MNTENT = @have_mntent@
 HAVE_FLS = @have_fls@
 HAVE_FSETXATTR = @have_fsetxattr@
+HAVE_MREMAP = @have_mremap@
 
 GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall 
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
diff --git a/include/darwin.h b/include/darwin.h
index af76f31..9f7a00b 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -33,6 +33,7 @@
 #include <mach/mach_time.h>
 #include <inttypes.h>
 #include <stdio.h>
+#include <sys/mman.h>
 
 #include <machine/endian.h>
 #define __BYTE_ORDER	BYTE_ORDER
diff --git a/io/mmap.c b/io/mmap.c
index f26276e..7093650 100644
--- a/io/mmap.c
+++ b/io/mmap.c
@@ -28,7 +28,9 @@ static cmdinfo_t mread_cmd;
 static cmdinfo_t msync_cmd;
 static cmdinfo_t munmap_cmd;
 static cmdinfo_t mwrite_cmd;
+#ifdef HAVE_MREMAP
 static cmdinfo_t mremap_cmd;
+#endif /* HAVE_MREMAP */
 
 mmap_region_t	*maptable;
 int		mapcount;
@@ -574,6 +576,7 @@ mwrite_f(
 	return 0;
 }
 
+#ifdef HAVE_MREMAP
 static void
 mremap_help(void)
 {
@@ -633,6 +636,7 @@ mremap_f(
 
 	return 0;
 }
+#endif /* HAVE_MREMAP */
 
 void
 mmap_init(void)
@@ -688,6 +692,7 @@ mmap_init(void)
 		_("writes data into a region in the current memory mapping");
 	mwrite_cmd.help = mwrite_help;
 
+#ifdef HAVE_MREMAP
 	mremap_cmd.name = "mremap";
 	mremap_cmd.altname = "mrm";
 	mremap_cmd.cfunc = mremap_f;
@@ -698,11 +703,14 @@ mmap_init(void)
 	mremap_cmd.oneline =
 		_("alters the size of the current memory mapping");
 	mremap_cmd.help = mremap_help;
+#endif /* HAVE_MREMAP */
 
 	add_command(&mmap_cmd);
 	add_command(&mread_cmd);
 	add_command(&msync_cmd);
 	add_command(&munmap_cmd);
 	add_command(&mwrite_cmd);
+#ifdef HAVE_MREMAP
 	add_command(&mremap_cmd);
+#endif /* HAVE_MREMAP */
 }
diff --git a/m4/package_libcdev.m4 b/m4/package_libcdev.m4
index 5e900ab..b6a7a54 100644
--- a/m4/package_libcdev.m4
+++ b/m4/package_libcdev.m4
@@ -235,3 +235,16 @@ AC_DEFUN([AC_HAVE_MNTENT],
     have_mntent=yes)
     AC_SUBST(have_mntent)
   ])
+
+#
+# Check if we have a mremap call (not on Mac OS X)
+#
+AC_DEFUN([AC_HAVE_MREMAP],
+  [ AC_CHECK_DECL([mremap],
+       have_mremap=yes,
+       [],
+       [#define _GNU_SOURCE
+        #include <sys/mman.h>]
+       )
+    AC_SUBST(have_mremap)
+  ])
-- 
2.4.5

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

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

* Re: [PATCH 10/11] xfsprogs: add dummy mntent for OS X
  2015-09-03 10:33         ` Dave Chinner
@ 2015-09-03 10:37           ` Jan Tulak
  0 siblings, 0 replies; 45+ messages in thread
From: Jan Tulak @ 2015-09-03 10:37 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Christoph Hellwig, xfs-oss


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

On Thu, Sep 3, 2015 at 12:33 PM, Dave Chinner <david@fromorbit.com> wrote:

> On Thu, Sep 03, 2015 at 11:01:44AM +0200, Jan Tulak wrote:
> > On Mon, Aug 31, 2015 at 9:01 PM, Christoph Hellwig <hch@infradead.org>
> > wrote:
> >
> > > On Wed, Aug 26, 2015 at 02:02:34PM +0200, Jan Tulak wrote:
> > > > Because these calls are used only by xfs_fsr, which can't
> > > > work on OS X unless a way how to mount XFS is found,
> > > > there is not use in implementing these calls.
> > >
> > > Take a look at the quota code for the BSD alternative to mntent.
> > > That code should be moved into a common location and used by fsr.
> > >
> >
> > ​I tried to find it, but didn't found... Could you point me where it is?
> > Quota/freebsd.h has just few lines with one definition with errno =
> > -ENOSYS, and in other files in quota/, I didn't saw anything BSD
> specific.
>
> I think Christoph is refering to the code in libxcmd/paths.c:
>
> #if defined(HAVE_GETMNTENT)
> ....
> #elif defined(HAVE_GETMNTINFO)
> ....
> #else
> # error "How do I extract info about mounted filesystems on this platform?"
> #endif
> #
>
> HAVE_GETMNTINFO is for BSD systems, IIRC.
>
>
​All right, I will look on this. Thanks. :-)

Cheers,
Jan​


-- 
Jan Tulak
jtulak@redhat.com / jan@tulak.me

[-- Attachment #1.2: Type: text/html, Size: 2567 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] 45+ messages in thread

* [PATCH v2 07/11] xfsprogs: change nftw64 to nftw
  2015-08-26 12:02   ` [PATCH 07/11] xfsprogs: add nftw64 translation " Jan Tulak
  2015-08-31 18:59     ` Christoph Hellwig
@ 2015-09-03 10:39     ` Jan Tulak
  2015-09-09 10:11       ` Jan Tulak
  2015-09-09 10:14       ` [PATCH v3 " Jan Tulak
  1 sibling, 2 replies; 45+ messages in thread
From: Jan Tulak @ 2015-09-03 10:39 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Changelog:
 - Subject was "add nftw64 translation for OS X"
 - Changed from #define to renaming

There is only one usage of nftw64 in entire xfsprogs, but
multiple usages of nftw. It seems the 64 variant has no reason,
and causes difficulties with some other platforms which has
only nftw call.

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

diff --git a/estimate/xfs_estimate.c b/estimate/xfs_estimate.c
index 65b7168..632e4ec 100644
--- a/estimate/xfs_estimate.c
+++ b/estimate/xfs_estimate.c
@@ -168,7 +168,7 @@ main(int argc, char **argv)
 		ndirs=0LL;		/* number of directories */
 		nspecial=0LL;		/* number of special files */
 
-		nftw64(argv[optind], ffn, 40, FTW_PHYS | FTW_MOUNT);
+		nftw(argv[optind], ffn, 40, FTW_PHYS | FTW_MOUNT);
 
 		if (__debug) {
 			printf(_("dirsize=%llu\n"), dirsize);
-- 
2.4.5

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

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

* [PATCH 10/11 v2] xfsprogs: make fsr use mntinfo when there is no mntent
  2015-08-26 12:02   ` [PATCH 10/11] xfsprogs: add dummy mntent for OS X Jan Tulak
  2015-08-31 19:01     ` Christoph Hellwig
@ 2015-09-08 14:23     ` Jan Tulak
  1 sibling, 0 replies; 45+ messages in thread
From: Jan Tulak @ 2015-09-08 14:23 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak


For what fsr needs, mntinfo can be used instead of mntent.
Custom mntent struct is used to avoid too big ifdefs:
We only change few lines and the rest of the code can still
use mntent as before.

CHANGE
- subject was: "add dummy mntent for OS X"
- reduced the stuby code.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 fsr/Makefile     |  8 +++++++
 fsr/xfs_fsr.c    | 69 ++++++++++++++++++++++++++++++++++++++++++++++++--------
 include/darwin.h | 20 ++++++++++++++++
 3 files changed, 87 insertions(+), 10 deletions(-)

diff --git a/fsr/Makefile b/fsr/Makefile
index a9d1bf6..d3521b2 100644
--- a/fsr/Makefile
+++ b/fsr/Makefile
@@ -9,6 +9,14 @@ LTCOMMAND = xfs_fsr
 CFILES = xfs_fsr.c
 LLDLIBS = $(LIBHANDLE)
 
+ifeq ($(HAVE_GETMNTENT),yes)
+LCFLAGS += -DHAVE_GETMNTENT
+endif
+
+ifeq ($(HAVE_GETMNTINFO),yes)
+LCFLAGS += -DHAVE_GETMNTINFO
+endif
+
 default: depend $(LTCOMMAND)
 
 include $(BUILDRULES)
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index 5f95cdc..ff791d3 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -32,8 +32,10 @@
 #include <sys/statvfs.h>
 #include <sys/xattr.h>
 
-#ifdef HAVE_MNTENT
+#if defined(HAVE_GETMNTENT)
 #  include <mntent.h>
+#elif defined(HAVE_GETMNTINFO)
+#  include <sys/mount.h>
 #endif
 
 #ifdef __APPLE__
@@ -191,9 +193,10 @@ find_mountpoint(char *mtab, char *argname, struct stat64 *sb)
 {
 	struct mntent *t;
 	struct stat64 ms;
-	FILE *mtabp;
 	char *mntp = NULL;
 
+#if defined(HAVE_GETMNTENT)
+	FILE *mtabp;
 	mtabp = setmntent(mtab, "r");
 	if (!mtabp) {
 		fprintf(stderr, _("%s: cannot read %s\n"),
@@ -202,6 +205,27 @@ find_mountpoint(char *mtab, char *argname, struct stat64 *sb)
 	}
 
 	while ((t = getmntent(mtabp))) {
+#elif defined(HAVE_GETMNTINFO)
+	struct statfs	*stats;
+	int error, i, count;
+	// because "t" is a pointer, but we don't need to use
+	// malloc for this usage
+	struct mntent t_tmp;
+	t = &t_tmp;
+
+		
+	error = 0;
+	if ((count = getmntinfo(&stats, 0)) < 0) {
+		fprintf(stderr, _("%s: getmntinfo() failed: %s\n"),
+				progname, strerror(errno));
+		return 0;
+	}
+
+	for (i = 0; i < count; i++) {
+		mntinfo2mntent(&stats[i], t);
+#else
+# error "How do I extract info about mounted filesystems on this platform?"
+#endif
 		if (S_ISDIR(sb->st_mode)) {		/* mount point */
 			if (stat64(t->mnt_dir, &ms) < 0)
 				continue;
@@ -233,10 +257,11 @@ find_mountpoint(char *mtab, char *argname, struct stat64 *sb)
 		break;
 	}
 
+#if defined(HAVE_GETMNTENT)
 	endmntent(mtabp);
+#endif
 	return mntp;
 }
-
 int
 main(int argc, char **argv)
 {
@@ -411,18 +436,11 @@ usage(int ret)
 static void
 initallfs(char *mtab)
 {
-	FILE *fp;
 	struct mntent *mp;
 	int mi;
 	char *cp;
 	struct stat64 sb;
 
-	fp = setmntent(mtab, "r");
-	if (fp == NULL) {
-		fsrprintf(_("could not open mtab file: %s\n"), mtab);
-		exit(1);
-	}
-
 	/* malloc a number of descriptors, increased later if needed */
 	if (!(fsbase = (fsdesc_t *)malloc(fsbufsize * sizeof(fsdesc_t)))) {
 		fsrprintf(_("out of memory: %s\n"), strerror(errno));
@@ -433,7 +451,36 @@ initallfs(char *mtab)
 	/* find all rw xfs file systems */
 	mi = 0;
 	fs = fsbase;
+
+#if defined(HAVE_GETMNTENT)
+	FILE *fp;
+	fp = setmntent(mtab, "r");
+	if (fp == NULL) {
+		fsrprintf(_("could not open mtab file: %s\n"), mtab);
+		exit(1);
+	}
+
 	while ((mp = getmntent(fp))) {
+#elif defined(HAVE_GETMNTINFO)
+	struct statfs	*stats;
+	int error, i, count;
+	// because "t" is a pointer, but we don't need to use
+	// malloc for this usage
+	struct mntent mp_tmp;
+	mp = &mp_tmp;
+	error = 0;
+	if ((count = getmntinfo(&stats, 0)) < 0) {
+		fprintf(stderr, _("%s: getmntinfo() failed: %s\n"),
+				progname, strerror(errno));
+		exit(1);
+	}
+
+	for (i = 0; i < count; i++) {
+		mntinfo2mntent(&stats[i], mp);
+#else
+# error "How do I extract info about mounted filesystems on this platform?"
+#endif
+
 		int rw = 0;
 
 		if (strcmp(mp->mnt_type, MNTTYPE_XFS ) != 0 ||
@@ -485,7 +532,9 @@ initallfs(char *mtab)
 	}
 	numfs = mi;
 	fsend = (fsbase + numfs);
+#if defined(HAVE_GETMNTENT)
 	endmntent(fp);
+#endif
 	if (numfs == 0) {
 		fsrprintf(_("no rw xfs file systems in mtab: %s\n"), mtab);
 		exit(0);
diff --git a/include/darwin.h b/include/darwin.h
index 288ad1f..0313f46 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -218,7 +218,27 @@ static inline int timer_gettime (timer_t timerid, struct itimerspec *value)
 
 /* FSR */
 
+#  include <sys/mount.h>
+#  include <sys/param.h>
+#include <sys/ucred.h>
+#include <errno.h>
 #define statvfs64 statfs
 #define		_PATH_MOUNTED   "/etc/mtab"
 
+struct mntent
+{
+	char *mnt_fsname;
+	char *mnt_dir;
+	char *mnt_type;
+	char *mnt_opts;
+	int mnt_freq;
+	int mnt_passno;
+};
+
+static inline void mntinfo2mntent (struct statfs * stats, struct mntent * mnt) {
+	mnt->mnt_fsname = stats->f_mntfromname;
+	mnt->mnt_dir = stats->f_mntonname;
+	mnt->mnt_type = stats->f_fstypename;
+}
+
 #endif	/* __XFS_DARWIN_H__ */
-- 
2.4.5

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

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

* [PATCH 09/11 v2] xfsprogs: Add statvfs64 for osx
  2015-08-26 12:02   ` [PATCH 09/11] xfsprogs: Add statvfs64 for osx Jan Tulak
@ 2015-09-08 14:24     ` Jan Tulak
  0 siblings, 0 replies; 45+ messages in thread
From: Jan Tulak @ 2015-09-08 14:24 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Simply rename statvfs64 to statfs with a #define.

CHANGE:
remove dummy code, add rename

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 fsr/xfs_fsr.c        | 14 ++++++++++++++
 include/builddefs.in |  2 +-
 include/darwin.h     |  5 +++++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index e1b7bd6..5f95cdc 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -36,6 +36,12 @@
 #  include <mntent.h>
 #endif
 
+#ifdef __APPLE__
+//#  define statvfs64 statfs;
+#  include <sys/param.h>
+#  include <sys/mount.h>
+#endif
+
 #ifndef XFS_XFLAG_NODEFRAG
 #define XFS_XFLAG_NODEFRAG 0x00002000 /* src dependancy, remove later */
 #endif
@@ -948,7 +954,11 @@ fsrfile_common(
 			fname, strerror(errno));
 		return -1;
 	}
+#ifndef statvfs64
 	bsize = vfss.f_frsize ? vfss.f_frsize : vfss.f_bsize;
+#else
+	bsize = vfss.f_bsize;
+#endif
 	if (statp->bs_blksize * statp->bs_blocks >
 	    vfss.f_bfree * bsize - minimumfree) {
 		fsrprintf(_("insufficient freespace for: %s: "
@@ -1728,7 +1738,11 @@ xfs_getrt(int fd, struct statvfs64 *sfbp)
 		close(fd);
 		return -1;
 	}
+#ifndef statvfs64
 	bsize = (sfbp->f_frsize ? sfbp->f_frsize : sfbp->f_bsize);
+#else
+	bsize = sfbp->f_bsize;
+#endif
 	factor = fsgeom.blocksize / bsize;         /* currently this is == 1 */
 	sfbp->f_bfree = (cnt.freertx * fsgeom.rtextsize) * factor;
 	return 0;
diff --git a/include/builddefs.in b/include/builddefs.in
index 25b8816..31e21ba 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -123,7 +123,7 @@ PCFLAGS = -D_GNU_SOURCE $(GCCFLAGS)
 endif
 ifeq ($(PKG_PLATFORM),darwin)
 PCFLAGS = $(GCCFLAGS)
-DEPENDFLAGS = -D__APPLE__
+DEPENDFLAGS = -D__APPLE__ -D_DARWIN_FEATURE_64_BIT_INODE
 endif
 ifeq ($(PKG_PLATFORM),irix)
 PLDLIBS = -ldisk -lgen
diff --git a/include/darwin.h b/include/darwin.h
index 0d2f175..288ad1f 100644
--- a/include/darwin.h
+++ b/include/darwin.h
@@ -216,4 +216,9 @@ static inline int timer_gettime (timer_t timerid, struct itimerspec *value)
 	return getitimer(ITIMER_REAL, value);
 }
 
+/* FSR */
+
+#define statvfs64 statfs
+#define		_PATH_MOUNTED   "/etc/mtab"
+
 #endif	/* __XFS_DARWIN_H__ */
-- 
2.4.5

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

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

* Re: [PATCH v2 07/11] xfsprogs: change nftw64 to nftw
  2015-09-03 10:39     ` [PATCH v2 07/11] xfsprogs: change nftw64 to nftw Jan Tulak
@ 2015-09-09 10:11       ` Jan Tulak
  2015-09-09 10:14       ` [PATCH v3 " Jan Tulak
  1 sibling, 0 replies; 45+ messages in thread
From: Jan Tulak @ 2015-09-09 10:11 UTC (permalink / raw)
  To: xfs-oss; +Cc: Christoph Hellwig, Jan Tulak


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

>
> --- a/estimate/xfs_estimate.c
> +++ b/estimate/xfs_estimate.c
> @@ -168,7 +168,7 @@ main(int argc, char **argv)
>                 ndirs=0LL;              /* number of directories */
>                 nspecial=0LL;           /* number of special files */
>
> -               nftw64(argv[optind], ffn, 40, FTW_PHYS | FTW_MOUNT);
> +               nftw(argv[optind], ffn, 40, FTW_PHYS | FTW_MOUNT);
>
>                 if (__debug) {
>                         printf(_("dirsize=%llu\n"), dirsize);
> --
> 2.4.5
>
>
​Now I noticed this causes a warning:
xfs_estimate.c:171:3: warning: passing argument 2 of ‘nftw’ from
incompatible pointer type

>From ftw.h, the difference is in __nftw_func_t and __nftw64_func_t as a
second argument. However, what we pass in the code is "
int
​ ​
ffn(
​..., struct stat64 *stb, ...)". ​If I change this to struct stat, it works
and xfstests -g quick gives the same result as with 64bit variant. So I'm
sending an updated patch.

Cheers,
Jan





-- 
Jan Tulak
jtulak@redhat.com / jan@tulak.me

[-- Attachment #1.2: Type: text/html, Size: 3567 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] 45+ messages in thread

* [PATCH v3 07/11] xfsprogs: change nftw64 to nftw
  2015-09-03 10:39     ` [PATCH v2 07/11] xfsprogs: change nftw64 to nftw Jan Tulak
  2015-09-09 10:11       ` Jan Tulak
@ 2015-09-09 10:14       ` Jan Tulak
  1 sibling, 0 replies; 45+ messages in thread
From: Jan Tulak @ 2015-09-09 10:14 UTC (permalink / raw)
  To: xfs; +Cc: hch, Jan Tulak

Changelog:
 - changed ffn argument from stat64 to stat
 - Subject was "add nftw64 translation for OS X"
 - Changed from #define to renaming

There is only one usage of nftw64 in entire xfsprogs, but
multiple usages of nftw. It seems the 64 variant has no reason,
and causes difficulties with some other platforms which has
only nftw call.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 estimate/xfs_estimate.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/estimate/xfs_estimate.c b/estimate/xfs_estimate.c
index 65b7168..323137c 100644
--- a/estimate/xfs_estimate.c
+++ b/estimate/xfs_estimate.c
@@ -45,7 +45,7 @@ cvtnum(char *s)
 	return 0LL;
 }
 
-int ffn(const char *, const struct stat64 *, int, struct FTW *);
+int ffn(const char *, const struct stat *, int, struct FTW *);
 
 #define BLOCKSIZE	4096
 #define INODESIZE	256
@@ -168,7 +168,7 @@ main(int argc, char **argv)
 		ndirs=0LL;		/* number of directories */
 		nspecial=0LL;		/* number of special files */
 
-		nftw64(argv[optind], ffn, 40, FTW_PHYS | FTW_MOUNT);
+		nftw(argv[optind], ffn, 40, FTW_PHYS | FTW_MOUNT);
 
 		if (__debug) {
 			printf(_("dirsize=%llu\n"), dirsize);
@@ -214,7 +214,7 @@ main(int argc, char **argv)
 }
 
 int
-ffn(const char *path, const struct stat64 *stb, int flags, struct FTW *f)
+ffn(const char *path, const struct stat *stb, int flags, struct FTW *f)
 {
 	/* cases are in most-encountered to least-encountered order */
 	dirsize+=PERDIRENTRY+strlen(path);
-- 
2.4.5

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

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

end of thread, other threads:[~2015-09-09 10:14 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-26 12:00 [PATCH 00/11 v4] xfsprogs: Partial OSX support Jan Tulak
2015-08-26 12:02 ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Jan Tulak
2015-08-26 12:02   ` [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX Jan Tulak
2015-08-26 22:01     ` Dave Chinner
2015-08-27  6:06       ` Jan Tulak
2015-08-27  6:02     ` Jan Tulak
2015-09-03 10:33       ` [PATCH 02a/11] xfsprogs: Add XATTR_LIST_MAX to OS X headers Jan Tulak
2015-09-03 10:33         ` [PATCH 02b/11] xfsprogs: avoid dependency on Linux XATTR_SIZE_MAX Jan Tulak
2015-09-03 10:33         ` [PATCH 02c/11] xfsprogs: prefix XATTR_LIST_MAX with XFS_ Jan Tulak
2015-08-31 18:58     ` [PATCH 02/11] xfsprogs: avoid dependency on linux XATTR_SIZE/LIST_MAX Christoph Hellwig
2015-09-01  8:13       ` Jan Tulak
2015-09-01  8:35         ` Jan Tulak
2015-08-26 12:02   ` [PATCH 03/11] xfsprogs: Add includes required for OS X builds (delta) Jan Tulak
2015-08-31 18:58     ` Christoph Hellwig
2015-08-26 12:02   ` [PATCH 04/11] xfsprogs: Add autoconf check for fsetxattr call Jan Tulak
2015-08-31 18:59     ` Christoph Hellwig
2015-08-26 12:02   ` [PATCH 05/11] xfsprogs: uuid changes for OS X Jan Tulak
2015-08-31 18:59     ` Christoph Hellwig
2015-08-26 12:02   ` [PATCH 06/11] xfsprogs: Remove conflicting define " Jan Tulak
2015-08-31 18:59     ` Christoph Hellwig
2015-08-26 12:02   ` [PATCH 07/11] xfsprogs: add nftw64 translation " Jan Tulak
2015-08-31 18:59     ` Christoph Hellwig
2015-09-01  7:49       ` Jan Tulak
2015-09-01  8:04       ` [PATCH v2] " Jan Tulak
2015-09-01 16:31         ` Darrick J. Wong
2015-09-01 17:24           ` Christoph Hellwig
2015-09-02  7:12           ` Jan Tulak
2015-09-03 10:39     ` [PATCH v2 07/11] xfsprogs: change nftw64 to nftw Jan Tulak
2015-09-09 10:11       ` Jan Tulak
2015-09-09 10:14       ` [PATCH v3 " Jan Tulak
2015-08-26 12:02   ` [PATCH 08/11] xfsprogs: Add a timer implementation for OS X Jan Tulak
2015-08-31 19:00     ` Christoph Hellwig
2015-09-02 10:54       ` Jan Tulak
2015-08-26 12:02   ` [PATCH 09/11] xfsprogs: Add statvfs64 for osx Jan Tulak
2015-09-08 14:24     ` [PATCH 09/11 v2] " Jan Tulak
2015-08-26 12:02   ` [PATCH 10/11] xfsprogs: add dummy mntent for OS X Jan Tulak
2015-08-31 19:01     ` Christoph Hellwig
2015-09-03  9:01       ` Jan Tulak
2015-09-03 10:33         ` Dave Chinner
2015-09-03 10:37           ` Jan Tulak
2015-09-08 14:23     ` [PATCH 10/11 v2] xfsprogs: make fsr use mntinfo when there is no mntent Jan Tulak
2015-08-26 12:02   ` [PATCH 11/11] xfsprogs: add dummy mremap for OS X Jan Tulak
2015-08-31 19:01     ` Christoph Hellwig
2015-09-03 10:35     ` [PATCH v2] xfsprogs: Make mremap conditional Jan Tulak
2015-08-31 18:57   ` [PATCH 01/11] xfsprogs: Add a way to compile without blkid Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.