All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] xfsprogs: more misc fixes
@ 2018-03-20  3:08 Darrick J. Wong
  2018-03-20  3:08 ` [PATCH 1/4] xfs_repair: implement custom ifork verifiers Darrick J. Wong
                   ` (6 more replies)
  0 siblings, 7 replies; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-20  3:08 UTC (permalink / raw)
  To: sandeen, darrick.wong; +Cc: linux-xfs

Hi all,

Here's a bunch more patches for xfsprogs 4.16.

The first patch implements a custom ifork verifier for repair phase 6
so that we can mark directories with invalid parents and later _iget
them so that we can reattach them to whatever parent we find (or
lost+found).

The next couple of patches fix some mountpoint finding bugs so that
users can pass "/home" or "/home/" to programs that take file paths.

The fourth patch enables sparse inodes by default in mkfs.

This probably won't eat your data, and the branch[1] should apply
against for-next.  More patches tomorrow.

--D

[1] https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=djwong-devel

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

* [PATCH 1/4] xfs_repair: implement custom ifork verifiers
  2018-03-20  3:08 [PATCH 0/4] xfsprogs: more misc fixes Darrick J. Wong
@ 2018-03-20  3:08 ` Darrick J. Wong
  2018-03-20 19:54   ` Eric Sandeen
                     ` (2 more replies)
  2018-03-20  3:08 ` [PATCH 2/4] libfrog: fs_table_lookup_mount should realpath the argument Darrick J. Wong
                   ` (5 subsequent siblings)
  6 siblings, 3 replies; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-20  3:08 UTC (permalink / raw)
  To: sandeen, darrick.wong; +Cc: linux-xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

There are a few cases where an early stage of xfs_repair will write an
invalid inode fork buffer to signal to a later stage that it needs to
correct the value.  This happens in phase 4 when we detect an inline
format directory with an invalid .. pointer.  To avoid triggering the
ifork verifiers on this, inject a custom verifier for phase 6 that lets
this pass for now.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/libxfs_api_defs.h |    2 +
 repair/phase6.c          |   66 +++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 67 insertions(+), 1 deletion(-)


diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
index 5d56340..78daca0 100644
--- a/libxfs/libxfs_api_defs.h
+++ b/libxfs/libxfs_api_defs.h
@@ -150,5 +150,7 @@
 #define xfs_rmap_lookup_le_range	libxfs_rmap_lookup_le_range
 #define xfs_refc_block			libxfs_refc_block
 #define xfs_rmap_compare		libxfs_rmap_compare
+#define xfs_dir_get_ops			libxfs_dir_get_ops
+#define xfs_default_ifork_ops		libxfs_default_ifork_ops
 
 #endif /* __LIBXFS_API_DEFS_H__ */
diff --git a/repair/phase6.c b/repair/phase6.c
index aff83bc..e9189af 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -39,6 +39,70 @@ static struct xfs_name		xfs_name_dot = {(unsigned char *)".",
 						XFS_DIR3_FT_DIR};
 
 /*
+ * When we're checking directory inodes, we're allowed to set a directory's
+ * dotdot entry to zero to signal that the parent needs to be reconnected
+ * during phase 6.  The ifork verifiers would normally fail that, but we'll
+ * accept this canary so that we can fix the dir.
+ */
+static xfs_failaddr_t
+phase6_verify_dir(
+	struct xfs_inode		*ip)
+{
+	struct xfs_mount		*mp = ip->i_mount;
+	const struct xfs_dir_ops	*dops;
+	struct xfs_ifork		*ifp;
+	struct xfs_dir2_sf_hdr		*sfp;
+	xfs_failaddr_t			fa;
+	xfs_ino_t			old_parent;
+	bool				parent_bypass = false;
+	int				size;
+
+	dops = libxfs_dir_get_ops(mp, NULL);
+
+	ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
+	sfp = (struct xfs_dir2_sf_hdr *)ifp->if_u1.if_data;
+	size = ifp->if_bytes;
+
+	/* Don't let the NULLFSINO .. entry blow everything up. */
+	if (size > offsetof(struct xfs_dir2_sf_hdr, parent) &&
+	    size >= xfs_dir2_sf_hdr_size(sfp->i8count)) {
+		old_parent = dops->sf_get_parent_ino(sfp);
+		if (old_parent == 0) {
+			dops->sf_put_parent_ino(sfp, mp->m_sb.sb_rootino);
+			parent_bypass = true;
+		}
+	}
+
+	fa = libxfs_default_ifork_ops.verify_dir(ip);
+
+	/* Put it back. */
+	if (parent_bypass)
+		dops->sf_put_parent_ino(sfp, old_parent);
+
+	return fa;
+}
+
+static xfs_failaddr_t
+phase6_verify_attr(
+	struct xfs_inode		*ip)
+{
+	return libxfs_default_ifork_ops.verify_attr(ip);
+}
+
+static xfs_failaddr_t
+phase6_verify_symlink(
+	struct xfs_inode		*ip)
+{
+	return libxfs_default_ifork_ops.verify_symlink(ip);
+}
+
+struct xfs_ifork_ops phase6_default_ifork_ops = {
+	.verify_attr	= phase6_verify_attr,
+	.verify_dir	= phase6_verify_dir,
+	.verify_symlink	= phase6_verify_symlink,
+};
+
+/*
  * Data structures used to keep track of directories where the ".."
  * entries are updated. These must be rebuilt after the initial pass
  */
@@ -2833,7 +2897,7 @@ process_dir_inode(
 
 	ASSERT(!is_inode_refchecked(irec, ino_offset) || dotdot_update);
 
-	error = -libxfs_iget(mp, NULL, ino, 0, &ip, NULL);
+	error = -libxfs_iget(mp, NULL, ino, 0, &ip, &phase6_default_ifork_ops);
 	if (error) {
 		if (!no_modify)
 			do_error(


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

* [PATCH 2/4] libfrog: fs_table_lookup_mount should realpath the argument
  2018-03-20  3:08 [PATCH 0/4] xfsprogs: more misc fixes Darrick J. Wong
  2018-03-20  3:08 ` [PATCH 1/4] xfs_repair: implement custom ifork verifiers Darrick J. Wong
@ 2018-03-20  3:08 ` Darrick J. Wong
  2018-03-20 19:55   ` Eric Sandeen
  2018-03-20  3:08 ` [PATCH 3/4] xfs_fsr: refactor mountpoint finding to use libfrog paths functions Darrick J. Wong
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-20  3:08 UTC (permalink / raw)
  To: sandeen, darrick.wong; +Cc: linux-xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

Call realpath on the dir argument so that we're comparing canonical
paths when looking for the mountpoint.  This fixes the problem where
'/home/' doesn't match '/home' even though they refer to the same thing.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libfrog/paths.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)


diff --git a/libfrog/paths.c b/libfrog/paths.c
index 62b4eda..19ee1ea 100644
--- a/libfrog/paths.c
+++ b/libfrog/paths.c
@@ -102,16 +102,19 @@ fs_table_lookup_mount(
 	uint		i;
 	dev_t		dev = 0;
 	char		rpath[PATH_MAX];
+	char		dpath[PATH_MAX];
 
 	if (fs_device_number(dir, &dev))
 		return NULL;
+	if (!realpath(dir, dpath))
+		return NULL;
 
 	for (i = 0; i < fs_count; i++) {
 		if (fs_table[i].fs_flags != FS_MOUNT_POINT)
 			continue;
 		if (!realpath(fs_table[i].fs_dir, rpath))
 			continue;
-		if (strcmp(rpath, dir) == 0)
+		if (strcmp(rpath, dpath) == 0)
 			return &fs_table[i];
 	}
 	return NULL;


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

* [PATCH 3/4] xfs_fsr: refactor mountpoint finding to use libfrog paths functions
  2018-03-20  3:08 [PATCH 0/4] xfsprogs: more misc fixes Darrick J. Wong
  2018-03-20  3:08 ` [PATCH 1/4] xfs_repair: implement custom ifork verifiers Darrick J. Wong
  2018-03-20  3:08 ` [PATCH 2/4] libfrog: fs_table_lookup_mount should realpath the argument Darrick J. Wong
@ 2018-03-20  3:08 ` Darrick J. Wong
  2018-03-20 23:14   ` Darrick J. Wong
  2018-03-21  3:19   ` [PATCH v2 " Darrick J. Wong
  2018-03-20  3:08 ` [PATCH 4/4] mkfs: enable sparse inodes by default Darrick J. Wong
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-20  3:08 UTC (permalink / raw)
  To: sandeen, darrick.wong; +Cc: linux-xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

Refactor the mount-point finding code in fsr to use the libfrog helpers
instead of open-coding yet another routine.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fsr/Makefile    |    4 ++-
 fsr/xfs_fsr.c   |   71 +++++--------------------------------------------------
 include/path.h  |    1 +
 libfrog/paths.c |   47 ++++++++++++++++++++++++++++--------
 4 files changed, 47 insertions(+), 76 deletions(-)


diff --git a/fsr/Makefile b/fsr/Makefile
index d3521b2..fc1c33b 100644
--- a/fsr/Makefile
+++ b/fsr/Makefile
@@ -7,7 +7,9 @@ include $(TOPDIR)/include/builddefs
 
 LTCOMMAND = xfs_fsr
 CFILES = xfs_fsr.c
-LLDLIBS = $(LIBHANDLE)
+LLDLIBS = $(LIBHANDLE) $(LIBFROG)
+LTDEPENDENCIES = $(LIBFROG)
+LLDFLAGS = -static-libtool-libs
 
 ifeq ($(HAVE_GETMNTENT),yes)
 LCFLAGS += -DHAVE_GETMNTENT
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index 2a18ce0..ef6a68f 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -22,6 +22,7 @@
 #include "jdm.h"
 #include "xfs_bmap_btree.h"
 #include "xfs_attr_sf.h"
+#include "path.h"
 
 #include <fcntl.h>
 #include <errno.h>
@@ -167,73 +168,13 @@ aborter(int unused)
 	exit(1);
 }
 
-/*
- * Check if the argument is either the device name or mountpoint of an XFS
- * filesystem.  Note that we do not care about bind mounted regular files
- * here - the code that handles defragmentation of invidual files takes care
- * of that.
- */
-static char *
-find_mountpoint_check(struct stat *sb, struct mntent *t)
-{
-	struct stat ms;
-
-	if (S_ISDIR(sb->st_mode)) {		/* mount point */
-		if (stat(t->mnt_dir, &ms) < 0)
-			return NULL;
-		if (sb->st_ino != ms.st_ino)
-			return NULL;
-		if (sb->st_dev != ms.st_dev)
-			return NULL;
-		if (strcmp(t->mnt_type, MNTTYPE_XFS) != 0)
-			return NULL;
-	} else {				/* device */
-		if (stat(t->mnt_fsname, &ms) < 0)
-			return NULL;
-		if (sb->st_rdev != ms.st_rdev)
-			return NULL;
-		if (strcmp(t->mnt_type, MNTTYPE_XFS) != 0)
-			return NULL;
-		/*
-		 * Make sure the mountpoint given by mtab is accessible
-		 * before using it.
-		 */
-		if (stat(t->mnt_dir, &ms) < 0)
-			return NULL;
-	}
-
-	return t->mnt_dir;
-}
-
-static char *
-find_mountpoint(char *mtab, char *argname, struct stat *sb)
-{
-	struct mntent_cursor cursor;
-	struct mntent *t = NULL;
-	char *mntp = NULL;
-
-	if (platform_mntent_open(&cursor, mtab) != 0){
-		fprintf(stderr, "Error: can't get mntent entries.\n");
-		exit(1);
-	}
-
-	while ((t = platform_mntent_next(&cursor)) != NULL) {
-		mntp = find_mountpoint_check(sb, t);
-		if (mntp == NULL)
-			continue;
-		break;
-	}
-	platform_mntent_close(&cursor);
-	return mntp;
-}
-
 int
 main(int argc, char **argv)
 {
 	struct stat sb;
 	char *argname;
 	int c;
-	char *mntp;
+	struct fs_path	*fsp;
 	char *mtab = NULL;
 
 	setlinebuf(stdout);
@@ -343,9 +284,11 @@ main(int argc, char **argv)
 				sb = sb2;
 			}
 
-			mntp = find_mountpoint(mtab, argname, &sb);
-			if (mntp != NULL) {
-				fsrfs(mntp, 0, 100);
+			fsp = fs_table_lookup_mount(argname);
+			if (!fsp)
+				fsp = fs_table_lookup_blkdev(argname);
+			if (fsp != NULL) {
+				fsrfs(fsp->fs_dir, 0, 100);
 			} else if (S_ISCHR(sb.st_mode)) {
 				fprintf(stderr, _(
 					"%s: char special not supported: %s\n"),
diff --git a/include/path.h b/include/path.h
index 1d3a902..88dc44b 100644
--- a/include/path.h
+++ b/include/path.h
@@ -57,6 +57,7 @@ extern void fs_table_insert_project_path(char *__dir, uint __projid);
 
 extern fs_path_t *fs_table_lookup(const char *__dir, uint __flags);
 extern fs_path_t *fs_table_lookup_mount(const char *__dir);
+extern fs_path_t *fs_table_lookup_blkdev(const char *bdev);
 
 typedef struct fs_cursor {
 	uint		count;		/* total count of mount entries	*/
diff --git a/libfrog/paths.c b/libfrog/paths.c
index 19ee1ea..a80a30b 100644
--- a/libfrog/paths.c
+++ b/libfrog/paths.c
@@ -89,15 +89,10 @@ fs_table_lookup(
 	return NULL;
 }
 
-/*
- * Find the FS table entry describing an actual mount for the given path.
- * Unlike fs_table_lookup(), fs_table_lookup_mount() compares the "dir"
- * argument to actual mount point entries in the table. Accordingly, it
- * will find matches only if the "dir" argument is indeed mounted.
- */
-struct fs_path *
-fs_table_lookup_mount(
-	const char	*dir)
+static struct fs_path *
+__fs_table_lookup_mount(
+	const char	*dir,
+	const char	*blkdev)
 {
 	uint		i;
 	dev_t		dev = 0;
@@ -106,13 +101,17 @@ fs_table_lookup_mount(
 
 	if (fs_device_number(dir, &dev))
 		return NULL;
-	if (!realpath(dir, dpath))
+	if (dir && !realpath(dir, dpath))
+		return NULL;
+	if (blkdev && !realpath(blkdev, dpath))
 		return NULL;
 
 	for (i = 0; i < fs_count; i++) {
 		if (fs_table[i].fs_flags != FS_MOUNT_POINT)
 			continue;
-		if (!realpath(fs_table[i].fs_dir, rpath))
+		if (dir && !realpath(fs_table[i].fs_dir, rpath))
+			continue;
+		if (blkdev && !realpath(fs_table[i].fs_name, rpath))
 			continue;
 		if (strcmp(rpath, dpath) == 0)
 			return &fs_table[i];
@@ -120,6 +119,32 @@ fs_table_lookup_mount(
 	return NULL;
 }
 
+/*
+ * Find the FS table entry describing an actual mount for the given path.
+ * Unlike fs_table_lookup(), fs_table_lookup_mount() compares the "dir"
+ * argument to actual mount point entries in the table. Accordingly, it
+ * will find matches only if the "dir" argument is indeed mounted.
+ */
+struct fs_path *
+fs_table_lookup_mount(
+	const char	*dir)
+{
+	return __fs_table_lookup_mount(dir, NULL);
+}
+
+/*
+ * Find the FS table entry describing an actual mount for the block device.
+ * Unlike fs_table_lookup(), fs_table_lookup_blkdev() compares the "bdev"
+ * argument to actual mount point names in the table. Accordingly, it
+ * will find matches only if the "bdev" argument is indeed mounted.
+ */
+struct fs_path *
+fs_table_lookup_blkdev(
+	const char	*bdev)
+{
+	return __fs_table_lookup_mount(NULL, bdev);
+}
+
 static int
 fs_table_insert(
 	char		*dir,


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

* [PATCH 4/4] mkfs: enable sparse inodes by default
  2018-03-20  3:08 [PATCH 0/4] xfsprogs: more misc fixes Darrick J. Wong
                   ` (2 preceding siblings ...)
  2018-03-20  3:08 ` [PATCH 3/4] xfs_fsr: refactor mountpoint finding to use libfrog paths functions Darrick J. Wong
@ 2018-03-20  3:08 ` Darrick J. Wong
  2018-03-20 21:16   ` Eric Sandeen
  2018-03-21  3:19 ` [PATCH 5/4] misc: remove darwin, irix, and freebsd support Darrick J. Wong
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-20  3:08 UTC (permalink / raw)
  To: sandeen, darrick.wong; +Cc: linux-xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

Enable the sparse inode feature by default.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 mkfs/xfs_mkfs.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 1ca6a2d..78d0ce5 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1996,7 +1996,7 @@ _("finobt not supported without CRC support\n"));
 		}
 		cli->sb_feat.finobt = false;
 
-		if (cli->sb_feat.spinodes) {
+		if (cli->sb_feat.spinodes && cli_opt_set(&iopts, I_SPINODES)) {
 			fprintf(stderr,
 _("sparse inodes not supported without CRC support\n"));
 			usage();
@@ -3811,7 +3811,7 @@ main(
 			.crcs_enabled = true,
 			.dirftype = true,
 			.finobt = true,
-			.spinodes = false,
+			.spinodes = true,
 			.rmapbt = false,
 			.reflink = false,
 			.parent_pointers = false,


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

* Re: [PATCH 1/4] xfs_repair: implement custom ifork verifiers
  2018-03-20  3:08 ` [PATCH 1/4] xfs_repair: implement custom ifork verifiers Darrick J. Wong
@ 2018-03-20 19:54   ` Eric Sandeen
  2018-03-20 21:19     ` Darrick J. Wong
  2018-03-20 21:47   ` [PATCH v2 " Darrick J. Wong
  2018-03-22 19:35   ` [PATCH 1.5/4] xfs_repair: use custom ifork verifier in mv_orphanage Eric Sandeen
  2 siblings, 1 reply; 27+ messages in thread
From: Eric Sandeen @ 2018-03-20 19:54 UTC (permalink / raw)
  To: Darrick J. Wong, sandeen; +Cc: linux-xfs

On 3/19/18 10:08 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> There are a few cases where an early stage of xfs_repair will write an
> invalid inode fork buffer to signal to a later stage that it needs to
> correct the value.  This happens in phase 4 when we detect an inline
> format directory with an invalid .. pointer.  To avoid triggering the
> ifork verifiers on this, inject a custom verifier for phase 6 that lets
> this pass for now.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  libxfs/libxfs_api_defs.h |    2 +
>  repair/phase6.c          |   66 +++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 67 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
> index 5d56340..78daca0 100644
> --- a/libxfs/libxfs_api_defs.h
> +++ b/libxfs/libxfs_api_defs.h
> @@ -150,5 +150,7 @@
>  #define xfs_rmap_lookup_le_range	libxfs_rmap_lookup_le_range
>  #define xfs_refc_block			libxfs_refc_block
>  #define xfs_rmap_compare		libxfs_rmap_compare
> +#define xfs_dir_get_ops			libxfs_dir_get_ops
> +#define xfs_default_ifork_ops		libxfs_default_ifork_ops
>  
>  #endif /* __LIBXFS_API_DEFS_H__ */
> diff --git a/repair/phase6.c b/repair/phase6.c
> index aff83bc..e9189af 100644
> --- a/repair/phase6.c
> +++ b/repair/phase6.c
> @@ -39,6 +39,70 @@ static struct xfs_name		xfs_name_dot = {(unsigned char *)".",
>  						XFS_DIR3_FT_DIR};
>  
>  /*
> + * When we're checking directory inodes, we're allowed to set a directory's

(a shortform directory only?)

> + * dotdot entry to zero to signal that the parent needs to be reconnected
> + * during phase 6.  The ifork verifiers would normally fail that, but we'll
> + * accept this canary so that we can fix the dir.

hm we actually just replace it temporarily, potato/potahto?

> + */
> +static xfs_failaddr_t
> +phase6_verify_dir(
> +	struct xfs_inode		*ip)
> +{
> +	struct xfs_mount		*mp = ip->i_mount;
> +	const struct xfs_dir_ops	*dops;
> +	struct xfs_ifork		*ifp;
> +	struct xfs_dir2_sf_hdr		*sfp;
> +	xfs_failaddr_t			fa;
> +	xfs_ino_t			old_parent;
> +	bool				parent_bypass = false;
> +	int				size;
> +
> +	dops = libxfs_dir_get_ops(mp, NULL);
> +
> +	ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
> +	sfp = (struct xfs_dir2_sf_hdr *)ifp->if_u1.if_data;
> +	size = ifp->if_bytes;
> +
> +	/* Don't let the NULLFSINO .. entry blow everything up. */

NULLFSINO is ((xfs_ino_t)-1) not zero, so is this comment accurate?

Maybe an explicit comment here about this being for shortform dirs?

	/*
	 * If this is a shortform directory, phase4 may have set the parent
	 * inode to zero to indicate that it must be fixed.  Temporarily
	 * set a valid parent so that the directory verifier will pass.
	 */

> +	if (size > offsetof(struct xfs_dir2_sf_hdr, parent) &&
> +	    size >= xfs_dir2_sf_hdr_size(sfp->i8count)) {
> +		old_parent = dops->sf_get_parent_ino(sfp);
> +		if (old_parent == 0) {
> +			dops->sf_put_parent_ino(sfp, mp->m_sb.sb_rootino);
> +			parent_bypass = true;
> +		}
> +	}
> +
> +	fa = libxfs_default_ifork_ops.verify_dir(ip);
> +
> +	/* Put it back. */

	/* Put the special parent == 0 back in place */

> +	if (parent_bypass)
> +		dops->sf_put_parent_ino(sfp, old_parent);
> +
> +	return fa;
> +}
> +
> +static xfs_failaddr_t
> +phase6_verify_attr(
> +	struct xfs_inode		*ip)
> +{
> +	return libxfs_default_ifork_ops.verify_attr(ip);
> +}

Is there a reason for these wrappers vs. just populating the
custom ifork_ops with xfs_attr_shortform_verify and
xfs_symlink_shortform_verify?

> +
> +static xfs_failaddr_t
> +phase6_verify_symlink(
> +	struct xfs_inode		*ip)
> +{
> +	return libxfs_default_ifork_ops.verify_symlink(ip);
> +}
> +
> +struct xfs_ifork_ops phase6_default_ifork_ops = {

Naming a "custom" verifier "default" seems counterintuitive,
is there a reason for the "default" semantics I'm missing?  Not
a huge deal, just makes me go "hmmm...."

> +	.verify_attr	= phase6_verify_attr,
> +	.verify_dir	= phase6_verify_dir,
> +	.verify_symlink	= phase6_verify_symlink,
> +};
> +
> +/*
>   * Data structures used to keep track of directories where the ".."
>   * entries are updated. These must be rebuilt after the initial pass
>   */
> @@ -2833,7 +2897,7 @@ process_dir_inode(
>  
>  	ASSERT(!is_inode_refchecked(irec, ino_offset) || dotdot_update);
>  
> -	error = -libxfs_iget(mp, NULL, ino, 0, &ip, NULL);
> +	error = -libxfs_iget(mp, NULL, ino, 0, &ip, &phase6_default_ifork_ops);
>  	if (error) {
>  		if (!no_modify)
>  			do_error(
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH 2/4] libfrog: fs_table_lookup_mount should realpath the argument
  2018-03-20  3:08 ` [PATCH 2/4] libfrog: fs_table_lookup_mount should realpath the argument Darrick J. Wong
@ 2018-03-20 19:55   ` Eric Sandeen
  0 siblings, 0 replies; 27+ messages in thread
From: Eric Sandeen @ 2018-03-20 19:55 UTC (permalink / raw)
  To: Darrick J. Wong, sandeen; +Cc: linux-xfs

On 3/19/18 10:08 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Call realpath on the dir argument so that we're comparing canonical
> paths when looking for the mountpoint.  This fixes the problem where
> '/home/' doesn't match '/home' even though they refer to the same thing.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Yeah, not sure why this wasn't done.  This stuff always seems fiddly
but I can't see anything wrong with doing this, soooo

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  libfrog/paths.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/libfrog/paths.c b/libfrog/paths.c
> index 62b4eda..19ee1ea 100644
> --- a/libfrog/paths.c
> +++ b/libfrog/paths.c
> @@ -102,16 +102,19 @@ fs_table_lookup_mount(
>  	uint		i;
>  	dev_t		dev = 0;
>  	char		rpath[PATH_MAX];
> +	char		dpath[PATH_MAX];
>  
>  	if (fs_device_number(dir, &dev))
>  		return NULL;
> +	if (!realpath(dir, dpath))
> +		return NULL;
>  
>  	for (i = 0; i < fs_count; i++) {
>  		if (fs_table[i].fs_flags != FS_MOUNT_POINT)
>  			continue;
>  		if (!realpath(fs_table[i].fs_dir, rpath))
>  			continue;
> -		if (strcmp(rpath, dir) == 0)
> +		if (strcmp(rpath, dpath) == 0)
>  			return &fs_table[i];
>  	}
>  	return NULL;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH 4/4] mkfs: enable sparse inodes by default
  2018-03-20  3:08 ` [PATCH 4/4] mkfs: enable sparse inodes by default Darrick J. Wong
@ 2018-03-20 21:16   ` Eric Sandeen
  0 siblings, 0 replies; 27+ messages in thread
From: Eric Sandeen @ 2018-03-20 21:16 UTC (permalink / raw)
  To: Darrick J. Wong, sandeen; +Cc: linux-xfs

On 3/19/18 10:08 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Enable the sparse inode feature by default.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

OK - the cli_opt_set stuff feels clunky but I know it's just the pattern
right now...

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  mkfs/xfs_mkfs.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 1ca6a2d..78d0ce5 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -1996,7 +1996,7 @@ _("finobt not supported without CRC support\n"));
>  		}
>  		cli->sb_feat.finobt = false;
>  
> -		if (cli->sb_feat.spinodes) {
> +		if (cli->sb_feat.spinodes && cli_opt_set(&iopts, I_SPINODES)) {
>  			fprintf(stderr,
>  _("sparse inodes not supported without CRC support\n"));
>  			usage();
> @@ -3811,7 +3811,7 @@ main(
>  			.crcs_enabled = true,
>  			.dirftype = true,
>  			.finobt = true,
> -			.spinodes = false,
> +			.spinodes = true,
>  			.rmapbt = false,
>  			.reflink = false,
>  			.parent_pointers = false,
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH 1/4] xfs_repair: implement custom ifork verifiers
  2018-03-20 19:54   ` Eric Sandeen
@ 2018-03-20 21:19     ` Darrick J. Wong
  0 siblings, 0 replies; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-20 21:19 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: sandeen, linux-xfs

On Tue, Mar 20, 2018 at 02:54:30PM -0500, Eric Sandeen wrote:
> On 3/19/18 10:08 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > There are a few cases where an early stage of xfs_repair will write an
> > invalid inode fork buffer to signal to a later stage that it needs to
> > correct the value.  This happens in phase 4 when we detect an inline
> > format directory with an invalid .. pointer.  To avoid triggering the
> > ifork verifiers on this, inject a custom verifier for phase 6 that lets
> > this pass for now.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  libxfs/libxfs_api_defs.h |    2 +
> >  repair/phase6.c          |   66 +++++++++++++++++++++++++++++++++++++++++++++-
> >  2 files changed, 67 insertions(+), 1 deletion(-)
> > 
> > 
> > diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
> > index 5d56340..78daca0 100644
> > --- a/libxfs/libxfs_api_defs.h
> > +++ b/libxfs/libxfs_api_defs.h
> > @@ -150,5 +150,7 @@
> >  #define xfs_rmap_lookup_le_range	libxfs_rmap_lookup_le_range
> >  #define xfs_refc_block			libxfs_refc_block
> >  #define xfs_rmap_compare		libxfs_rmap_compare
> > +#define xfs_dir_get_ops			libxfs_dir_get_ops
> > +#define xfs_default_ifork_ops		libxfs_default_ifork_ops
> >  
> >  #endif /* __LIBXFS_API_DEFS_H__ */
> > diff --git a/repair/phase6.c b/repair/phase6.c
> > index aff83bc..e9189af 100644
> > --- a/repair/phase6.c
> > +++ b/repair/phase6.c
> > @@ -39,6 +39,70 @@ static struct xfs_name		xfs_name_dot = {(unsigned char *)".",
> >  						XFS_DIR3_FT_DIR};
> >  
> >  /*
> > + * When we're checking directory inodes, we're allowed to set a directory's
> 
> (a shortform directory only?)

I think we do it for any directory, but it's only the shortform dirs
that require this fix.

> > + * dotdot entry to zero to signal that the parent needs to be reconnected
> > + * during phase 6.  The ifork verifiers would normally fail that, but we'll
> > + * accept this canary so that we can fix the dir.
> 
> hm we actually just replace it temporarily, potato/potahto?
> 
> > + */
> > +static xfs_failaddr_t
> > +phase6_verify_dir(
> > +	struct xfs_inode		*ip)
> > +{
> > +	struct xfs_mount		*mp = ip->i_mount;
> > +	const struct xfs_dir_ops	*dops;
> > +	struct xfs_ifork		*ifp;
> > +	struct xfs_dir2_sf_hdr		*sfp;
> > +	xfs_failaddr_t			fa;
> > +	xfs_ino_t			old_parent;
> > +	bool				parent_bypass = false;
> > +	int				size;
> > +
> > +	dops = libxfs_dir_get_ops(mp, NULL);
> > +
> > +	ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
> > +	sfp = (struct xfs_dir2_sf_hdr *)ifp->if_u1.if_data;
> > +	size = ifp->if_bytes;
> > +
> > +	/* Don't let the NULLFSINO .. entry blow everything up. */
> 
> NULLFSINO is ((xfs_ino_t)-1) not zero, so is this comment accurate?

Oops. :)

> Maybe an explicit comment here about this being for shortform dirs?
> 
> 	/*
> 	 * If this is a shortform directory, phase4 may have set the parent
> 	 * inode to zero to indicate that it must be fixed.  Temporarily
> 	 * set a valid parent so that the directory verifier will pass.
> 	 */

Much better comment, let's go with that.

> > +	if (size > offsetof(struct xfs_dir2_sf_hdr, parent) &&
> > +	    size >= xfs_dir2_sf_hdr_size(sfp->i8count)) {
> > +		old_parent = dops->sf_get_parent_ino(sfp);
> > +		if (old_parent == 0) {
> > +			dops->sf_put_parent_ino(sfp, mp->m_sb.sb_rootino);
> > +			parent_bypass = true;
> > +		}
> > +	}
> > +
> > +	fa = libxfs_default_ifork_ops.verify_dir(ip);
> > +
> > +	/* Put it back. */
> 
> 	/* Put the special parent == 0 back in place */
> 
> > +	if (parent_bypass)
> > +		dops->sf_put_parent_ino(sfp, old_parent);
> > +
> > +	return fa;
> > +}
> > +
> > +static xfs_failaddr_t
> > +phase6_verify_attr(
> > +	struct xfs_inode		*ip)
> > +{
> > +	return libxfs_default_ifork_ops.verify_attr(ip);
> > +}
> 
> Is there a reason for these wrappers vs. just populating the
> custom ifork_ops with xfs_attr_shortform_verify and
> xfs_symlink_shortform_verify?

gcc whines about non-const expressions.  I tried adding const to
everything that touches an ifork_ops but it still wouldn't compile.

> > +
> > +static xfs_failaddr_t
> > +phase6_verify_symlink(
> > +	struct xfs_inode		*ip)
> > +{
> > +	return libxfs_default_ifork_ops.verify_symlink(ip);
> > +}
> > +
> > +struct xfs_ifork_ops phase6_default_ifork_ops = {
> 
> Naming a "custom" verifier "default" seems counterintuitive,
> is there a reason for the "default" semantics I'm missing?  Not
> a huge deal, just makes me go "hmmm...."

-EBADNAME

phase6_ifork_ops, much better.

--D

> > +	.verify_attr	= phase6_verify_attr,
> > +	.verify_dir	= phase6_verify_dir,
> > +	.verify_symlink	= phase6_verify_symlink,
> > +};
> > +
> > +/*
> >   * Data structures used to keep track of directories where the ".."
> >   * entries are updated. These must be rebuilt after the initial pass
> >   */
> > @@ -2833,7 +2897,7 @@ process_dir_inode(
> >  
> >  	ASSERT(!is_inode_refchecked(irec, ino_offset) || dotdot_update);
> >  
> > -	error = -libxfs_iget(mp, NULL, ino, 0, &ip, NULL);
> > +	error = -libxfs_iget(mp, NULL, ino, 0, &ip, &phase6_default_ifork_ops);
> >  	if (error) {
> >  		if (!no_modify)
> >  			do_error(
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 1/4] xfs_repair: implement custom ifork verifiers
  2018-03-20  3:08 ` [PATCH 1/4] xfs_repair: implement custom ifork verifiers Darrick J. Wong
  2018-03-20 19:54   ` Eric Sandeen
@ 2018-03-20 21:47   ` Darrick J. Wong
  2018-03-21 18:37     ` Eric Sandeen
  2018-03-22 19:35   ` [PATCH 1.5/4] xfs_repair: use custom ifork verifier in mv_orphanage Eric Sandeen
  2 siblings, 1 reply; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-20 21:47 UTC (permalink / raw)
  To: sandeen; +Cc: linux-xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

There are a few cases where an early stage of xfs_repair will write an
invalid inode fork buffer to signal to a later stage that it needs to
correct the value.  This happens in phase 4 when we detect an inline
format directory with an invalid .. pointer.  To avoid triggering the
ifork verifiers on this, inject a custom verifier for phase 6 that lets
this pass for now.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
v2: fix misleading comments, remove pointless wrappers
---
 libxfs/libxfs_api_defs.h |    2 ++
 repair/phase6.c          |   57 +++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
index 5d56340..78daca0 100644
--- a/libxfs/libxfs_api_defs.h
+++ b/libxfs/libxfs_api_defs.h
@@ -150,5 +150,7 @@
 #define xfs_rmap_lookup_le_range	libxfs_rmap_lookup_le_range
 #define xfs_refc_block			libxfs_refc_block
 #define xfs_rmap_compare		libxfs_rmap_compare
+#define xfs_dir_get_ops			libxfs_dir_get_ops
+#define xfs_default_ifork_ops		libxfs_default_ifork_ops
 
 #endif /* __LIBXFS_API_DEFS_H__ */
diff --git a/repair/phase6.c b/repair/phase6.c
index aff83bc..ed005e8 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -39,6 +39,61 @@ static struct xfs_name		xfs_name_dot = {(unsigned char *)".",
 						XFS_DIR3_FT_DIR};
 
 /*
+ * When we're checking directory inodes, we're allowed to set a directory's
+ * dotdot entry to zero to signal that the parent needs to be reconnected
+ * during phase 6.  If we're handling a shortform directory the ifork
+ * verifiers will fail, so temporarily patch out this canary so that we can
+ * verify the rest of the fork and move on to fixing the dir.
+ */
+static xfs_failaddr_t
+phase6_verify_dir(
+	struct xfs_inode		*ip)
+{
+	struct xfs_mount		*mp = ip->i_mount;
+	const struct xfs_dir_ops	*dops;
+	struct xfs_ifork		*ifp;
+	struct xfs_dir2_sf_hdr		*sfp;
+	xfs_failaddr_t			fa;
+	xfs_ino_t			old_parent;
+	bool				parent_bypass = false;
+	int				size;
+
+	dops = libxfs_dir_get_ops(mp, NULL);
+
+	ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
+	sfp = (struct xfs_dir2_sf_hdr *)ifp->if_u1.if_data;
+	size = ifp->if_bytes;
+
+	/*
+	 * If this is a shortform directory, phase4 may have set the parent
+	 * inode to zero to indicate that it must be fixed.  Temporarily
+	 * set a valid parent so that the directory verifier will pass.
+	 */
+	if (size > offsetof(struct xfs_dir2_sf_hdr, parent) &&
+	    size >= xfs_dir2_sf_hdr_size(sfp->i8count)) {
+		old_parent = dops->sf_get_parent_ino(sfp);
+		if (old_parent == 0) {
+			dops->sf_put_parent_ino(sfp, mp->m_sb.sb_rootino);
+			parent_bypass = true;
+		}
+	}
+
+	fa = libxfs_default_ifork_ops.verify_dir(ip);
+
+	/* Put it back. */
+	if (parent_bypass)
+		dops->sf_put_parent_ino(sfp, old_parent);
+
+	return fa;
+}
+
+static struct xfs_ifork_ops phase6_ifork_ops = {
+	.verify_attr	= xfs_attr_shortform_verify,
+	.verify_dir	= phase6_verify_dir,
+	.verify_symlink	= xfs_symlink_shortform_verify,
+};
+
+/*
  * Data structures used to keep track of directories where the ".."
  * entries are updated. These must be rebuilt after the initial pass
  */
@@ -2833,7 +2888,7 @@ process_dir_inode(
 
 	ASSERT(!is_inode_refchecked(irec, ino_offset) || dotdot_update);
 
-	error = -libxfs_iget(mp, NULL, ino, 0, &ip, NULL);
+	error = -libxfs_iget(mp, NULL, ino, 0, &ip, &phase6_ifork_ops);
 	if (error) {
 		if (!no_modify)
 			do_error(

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

* Re: [PATCH 3/4] xfs_fsr: refactor mountpoint finding to use libfrog paths functions
  2018-03-20  3:08 ` [PATCH 3/4] xfs_fsr: refactor mountpoint finding to use libfrog paths functions Darrick J. Wong
@ 2018-03-20 23:14   ` Darrick J. Wong
  2018-03-21  3:19   ` [PATCH v2 " Darrick J. Wong
  1 sibling, 0 replies; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-20 23:14 UTC (permalink / raw)
  To: sandeen; +Cc: linux-xfs

On Mon, Mar 19, 2018 at 08:08:38PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Refactor the mount-point finding code in fsr to use the libfrog helpers
> instead of open-coding yet another routine.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fsr/Makefile    |    4 ++-
>  fsr/xfs_fsr.c   |   71 +++++--------------------------------------------------
>  include/path.h  |    1 +
>  libfrog/paths.c |   47 ++++++++++++++++++++++++++++--------
>  4 files changed, 47 insertions(+), 76 deletions(-)
> 
> 
> diff --git a/fsr/Makefile b/fsr/Makefile
> index d3521b2..fc1c33b 100644
> --- a/fsr/Makefile
> +++ b/fsr/Makefile
> @@ -7,7 +7,9 @@ include $(TOPDIR)/include/builddefs
>  
>  LTCOMMAND = xfs_fsr
>  CFILES = xfs_fsr.c
> -LLDLIBS = $(LIBHANDLE)
> +LLDLIBS = $(LIBHANDLE) $(LIBFROG)
> +LTDEPENDENCIES = $(LIBFROG)
> +LLDFLAGS = -static-libtool-libs
>  
>  ifeq ($(HAVE_GETMNTENT),yes)
>  LCFLAGS += -DHAVE_GETMNTENT
> diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
> index 2a18ce0..ef6a68f 100644
> --- a/fsr/xfs_fsr.c
> +++ b/fsr/xfs_fsr.c
> @@ -22,6 +22,7 @@
>  #include "jdm.h"
>  #include "xfs_bmap_btree.h"
>  #include "xfs_attr_sf.h"
> +#include "path.h"
>  
>  #include <fcntl.h>
>  #include <errno.h>
> @@ -167,73 +168,13 @@ aborter(int unused)
>  	exit(1);
>  }
>  
> -/*
> - * Check if the argument is either the device name or mountpoint of an XFS
> - * filesystem.  Note that we do not care about bind mounted regular files
> - * here - the code that handles defragmentation of invidual files takes care
> - * of that.
> - */
> -static char *
> -find_mountpoint_check(struct stat *sb, struct mntent *t)
> -{
> -	struct stat ms;
> -
> -	if (S_ISDIR(sb->st_mode)) {		/* mount point */
> -		if (stat(t->mnt_dir, &ms) < 0)
> -			return NULL;
> -		if (sb->st_ino != ms.st_ino)
> -			return NULL;
> -		if (sb->st_dev != ms.st_dev)
> -			return NULL;
> -		if (strcmp(t->mnt_type, MNTTYPE_XFS) != 0)
> -			return NULL;
> -	} else {				/* device */
> -		if (stat(t->mnt_fsname, &ms) < 0)
> -			return NULL;
> -		if (sb->st_rdev != ms.st_rdev)
> -			return NULL;
> -		if (strcmp(t->mnt_type, MNTTYPE_XFS) != 0)
> -			return NULL;
> -		/*
> -		 * Make sure the mountpoint given by mtab is accessible
> -		 * before using it.
> -		 */
> -		if (stat(t->mnt_dir, &ms) < 0)
> -			return NULL;
> -	}
> -
> -	return t->mnt_dir;
> -}
> -
> -static char *
> -find_mountpoint(char *mtab, char *argname, struct stat *sb)
> -{
> -	struct mntent_cursor cursor;
> -	struct mntent *t = NULL;
> -	char *mntp = NULL;
> -
> -	if (platform_mntent_open(&cursor, mtab) != 0){
> -		fprintf(stderr, "Error: can't get mntent entries.\n");
> -		exit(1);
> -	}
> -
> -	while ((t = platform_mntent_next(&cursor)) != NULL) {
> -		mntp = find_mountpoint_check(sb, t);
> -		if (mntp == NULL)
> -			continue;
> -		break;
> -	}
> -	platform_mntent_close(&cursor);
> -	return mntp;
> -}
> -
>  int
>  main(int argc, char **argv)
>  {
>  	struct stat sb;
>  	char *argname;
>  	int c;
> -	char *mntp;
> +	struct fs_path	*fsp;
>  	char *mtab = NULL;
>  
>  	setlinebuf(stdout);
> @@ -343,9 +284,11 @@ main(int argc, char **argv)
>  				sb = sb2;
>  			}
>  
> -			mntp = find_mountpoint(mtab, argname, &sb);
> -			if (mntp != NULL) {
> -				fsrfs(mntp, 0, 100);
> +			fsp = fs_table_lookup_mount(argname);

Lovely, we call fs_table_lookup_mount without first calling
fs_table_initialise to initialize the mountpoint table.  Now this
program refuses directory and bdev arguments...

> +			if (!fsp)
> +				fsp = fs_table_lookup_blkdev(argname);
> +			if (fsp != NULL) {
> +				fsrfs(fsp->fs_dir, 0, 100);
>  			} else if (S_ISCHR(sb.st_mode)) {
>  				fprintf(stderr, _(
>  					"%s: char special not supported: %s\n"),
> diff --git a/include/path.h b/include/path.h
> index 1d3a902..88dc44b 100644
> --- a/include/path.h
> +++ b/include/path.h
> @@ -57,6 +57,7 @@ extern void fs_table_insert_project_path(char *__dir, uint __projid);
>  
>  extern fs_path_t *fs_table_lookup(const char *__dir, uint __flags);
>  extern fs_path_t *fs_table_lookup_mount(const char *__dir);
> +extern fs_path_t *fs_table_lookup_blkdev(const char *bdev);
>  
>  typedef struct fs_cursor {
>  	uint		count;		/* total count of mount entries	*/
> diff --git a/libfrog/paths.c b/libfrog/paths.c
> index 19ee1ea..a80a30b 100644
> --- a/libfrog/paths.c
> +++ b/libfrog/paths.c
> @@ -89,15 +89,10 @@ fs_table_lookup(
>  	return NULL;
>  }
>  
> -/*
> - * Find the FS table entry describing an actual mount for the given path.
> - * Unlike fs_table_lookup(), fs_table_lookup_mount() compares the "dir"
> - * argument to actual mount point entries in the table. Accordingly, it
> - * will find matches only if the "dir" argument is indeed mounted.
> - */
> -struct fs_path *
> -fs_table_lookup_mount(
> -	const char	*dir)
> +static struct fs_path *
> +__fs_table_lookup_mount(
> +	const char	*dir,
> +	const char	*blkdev)
>  {
>  	uint		i;
>  	dev_t		dev = 0;
> @@ -106,13 +101,17 @@ fs_table_lookup_mount(
>  
>  	if (fs_device_number(dir, &dev))
>  		return NULL;

...which is just as well, since dir can now be NULL which means that
fs_table_lookup_blkdev will always bail out here.

nak, patch is fubar.

--D

> -	if (!realpath(dir, dpath))
> +	if (dir && !realpath(dir, dpath))
> +		return NULL;
> +	if (blkdev && !realpath(blkdev, dpath))
>  		return NULL;
>  
>  	for (i = 0; i < fs_count; i++) {
>  		if (fs_table[i].fs_flags != FS_MOUNT_POINT)
>  			continue;
> -		if (!realpath(fs_table[i].fs_dir, rpath))
> +		if (dir && !realpath(fs_table[i].fs_dir, rpath))
> +			continue;
> +		if (blkdev && !realpath(fs_table[i].fs_name, rpath))
>  			continue;
>  		if (strcmp(rpath, dpath) == 0)
>  			return &fs_table[i];
> @@ -120,6 +119,32 @@ fs_table_lookup_mount(
>  	return NULL;
>  }
>  
> +/*
> + * Find the FS table entry describing an actual mount for the given path.
> + * Unlike fs_table_lookup(), fs_table_lookup_mount() compares the "dir"
> + * argument to actual mount point entries in the table. Accordingly, it
> + * will find matches only if the "dir" argument is indeed mounted.
> + */
> +struct fs_path *
> +fs_table_lookup_mount(
> +	const char	*dir)
> +{
> +	return __fs_table_lookup_mount(dir, NULL);
> +}
> +
> +/*
> + * Find the FS table entry describing an actual mount for the block device.
> + * Unlike fs_table_lookup(), fs_table_lookup_blkdev() compares the "bdev"
> + * argument to actual mount point names in the table. Accordingly, it
> + * will find matches only if the "bdev" argument is indeed mounted.
> + */
> +struct fs_path *
> +fs_table_lookup_blkdev(
> +	const char	*bdev)
> +{
> +	return __fs_table_lookup_mount(NULL, bdev);
> +}
> +
>  static int
>  fs_table_insert(
>  	char		*dir,
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 3/4] xfs_fsr: refactor mountpoint finding to use libfrog paths functions
  2018-03-20  3:08 ` [PATCH 3/4] xfs_fsr: refactor mountpoint finding to use libfrog paths functions Darrick J. Wong
  2018-03-20 23:14   ` Darrick J. Wong
@ 2018-03-21  3:19   ` Darrick J. Wong
  2018-03-21 18:49     ` Eric Sandeen
  1 sibling, 1 reply; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-21  3:19 UTC (permalink / raw)
  To: sandeen; +Cc: linux-xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

Refactor the mount-point finding code in fsr to use the libfrog helpers
instead of open-coding yet another routine.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
v2: fix obvious brokenness w/ path testing
---
 fsr/Makefile    |    4 ++-
 fsr/xfs_fsr.c   |   73 ++++++-------------------------------------------------
 include/path.h  |    1 +
 libfrog/paths.c |   48 ++++++++++++++++++++++++++----------
 4 files changed, 47 insertions(+), 79 deletions(-)

diff --git a/fsr/Makefile b/fsr/Makefile
index d3521b2..4201b38 100644
--- a/fsr/Makefile
+++ b/fsr/Makefile
@@ -7,7 +7,9 @@ include $(TOPDIR)/include/builddefs
 
 LTCOMMAND = xfs_fsr
 CFILES = xfs_fsr.c
-LLDLIBS = $(LIBHANDLE)
+LLDLIBS = $(LIBHANDLE) $(LIBFROG) $(LIBPTHREAD) $(LIBBLKID)
+LTDEPENDENCIES = $(LIBHANDLE) $(LIBFROG)
+LLDFLAGS = -static-libtool-libs
 
 ifeq ($(HAVE_GETMNTENT),yes)
 LCFLAGS += -DHAVE_GETMNTENT
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index 2a18ce0..b74a70b 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -22,6 +22,7 @@
 #include "jdm.h"
 #include "xfs_bmap_btree.h"
 #include "xfs_attr_sf.h"
+#include "path.h"
 
 #include <fcntl.h>
 #include <errno.h>
@@ -167,73 +168,13 @@ aborter(int unused)
 	exit(1);
 }
 
-/*
- * Check if the argument is either the device name or mountpoint of an XFS
- * filesystem.  Note that we do not care about bind mounted regular files
- * here - the code that handles defragmentation of invidual files takes care
- * of that.
- */
-static char *
-find_mountpoint_check(struct stat *sb, struct mntent *t)
-{
-	struct stat ms;
-
-	if (S_ISDIR(sb->st_mode)) {		/* mount point */
-		if (stat(t->mnt_dir, &ms) < 0)
-			return NULL;
-		if (sb->st_ino != ms.st_ino)
-			return NULL;
-		if (sb->st_dev != ms.st_dev)
-			return NULL;
-		if (strcmp(t->mnt_type, MNTTYPE_XFS) != 0)
-			return NULL;
-	} else {				/* device */
-		if (stat(t->mnt_fsname, &ms) < 0)
-			return NULL;
-		if (sb->st_rdev != ms.st_rdev)
-			return NULL;
-		if (strcmp(t->mnt_type, MNTTYPE_XFS) != 0)
-			return NULL;
-		/*
-		 * Make sure the mountpoint given by mtab is accessible
-		 * before using it.
-		 */
-		if (stat(t->mnt_dir, &ms) < 0)
-			return NULL;
-	}
-
-	return t->mnt_dir;
-}
-
-static char *
-find_mountpoint(char *mtab, char *argname, struct stat *sb)
-{
-	struct mntent_cursor cursor;
-	struct mntent *t = NULL;
-	char *mntp = NULL;
-
-	if (platform_mntent_open(&cursor, mtab) != 0){
-		fprintf(stderr, "Error: can't get mntent entries.\n");
-		exit(1);
-	}
-
-	while ((t = platform_mntent_next(&cursor)) != NULL) {
-		mntp = find_mountpoint_check(sb, t);
-		if (mntp == NULL)
-			continue;
-		break;
-	}
-	platform_mntent_close(&cursor);
-	return mntp;
-}
-
 int
 main(int argc, char **argv)
 {
 	struct stat sb;
 	char *argname;
 	int c;
-	char *mntp;
+	struct fs_path	*fsp;
 	char *mtab = NULL;
 
 	setlinebuf(stdout);
@@ -322,7 +263,7 @@ main(int argc, char **argv)
 	RealUid = getuid();
 
 	pagesize = getpagesize();
-
+	fs_table_initialise(0, NULL, 0, NULL);
 	if (optind < argc) {
 		for (; optind < argc; optind++) {
 			argname = argv[optind];
@@ -343,9 +284,11 @@ main(int argc, char **argv)
 				sb = sb2;
 			}
 
-			mntp = find_mountpoint(mtab, argname, &sb);
-			if (mntp != NULL) {
-				fsrfs(mntp, 0, 100);
+			fsp = fs_table_lookup_mount(argname);
+			if (!fsp)
+				fsp = fs_table_lookup_blkdev(argname);
+			if (fsp != NULL) {
+				fsrfs(fsp->fs_dir, 0, 100);
 			} else if (S_ISCHR(sb.st_mode)) {
 				fprintf(stderr, _(
 					"%s: char special not supported: %s\n"),
diff --git a/include/path.h b/include/path.h
index 1d3a902..88dc44b 100644
--- a/include/path.h
+++ b/include/path.h
@@ -57,6 +57,7 @@ extern void fs_table_insert_project_path(char *__dir, uint __projid);
 
 extern fs_path_t *fs_table_lookup(const char *__dir, uint __flags);
 extern fs_path_t *fs_table_lookup_mount(const char *__dir);
+extern fs_path_t *fs_table_lookup_blkdev(const char *bdev);
 
 typedef struct fs_cursor {
 	uint		count;		/* total count of mount entries	*/
diff --git a/libfrog/paths.c b/libfrog/paths.c
index 19ee1ea..318b48f 100644
--- a/libfrog/paths.c
+++ b/libfrog/paths.c
@@ -89,30 +89,26 @@ fs_table_lookup(
 	return NULL;
 }
 
-/*
- * Find the FS table entry describing an actual mount for the given path.
- * Unlike fs_table_lookup(), fs_table_lookup_mount() compares the "dir"
- * argument to actual mount point entries in the table. Accordingly, it
- * will find matches only if the "dir" argument is indeed mounted.
- */
-struct fs_path *
-fs_table_lookup_mount(
-	const char	*dir)
+static struct fs_path *
+__fs_table_lookup_mount(
+	const char	*dir,
+	const char	*blkdev)
 {
 	uint		i;
-	dev_t		dev = 0;
 	char		rpath[PATH_MAX];
 	char		dpath[PATH_MAX];
 
-	if (fs_device_number(dir, &dev))
+	if (dir && !realpath(dir, dpath))
 		return NULL;
-	if (!realpath(dir, dpath))
+	if (blkdev && !realpath(blkdev, dpath))
 		return NULL;
 
 	for (i = 0; i < fs_count; i++) {
 		if (fs_table[i].fs_flags != FS_MOUNT_POINT)
 			continue;
-		if (!realpath(fs_table[i].fs_dir, rpath))
+		if (dir && !realpath(fs_table[i].fs_dir, rpath))
+			continue;
+		if (blkdev && !realpath(fs_table[i].fs_name, rpath))
 			continue;
 		if (strcmp(rpath, dpath) == 0)
 			return &fs_table[i];
@@ -120,6 +116,32 @@ fs_table_lookup_mount(
 	return NULL;
 }
 
+/*
+ * Find the FS table entry describing an actual mount for the given path.
+ * Unlike fs_table_lookup(), fs_table_lookup_mount() compares the "dir"
+ * argument to actual mount point entries in the table. Accordingly, it
+ * will find matches only if the "dir" argument is indeed mounted.
+ */
+struct fs_path *
+fs_table_lookup_mount(
+	const char	*dir)
+{
+	return __fs_table_lookup_mount(dir, NULL);
+}
+
+/*
+ * Find the FS table entry describing an actual mount for the block device.
+ * Unlike fs_table_lookup(), fs_table_lookup_blkdev() compares the "bdev"
+ * argument to actual mount point names in the table. Accordingly, it
+ * will find matches only if the "bdev" argument is indeed mounted.
+ */
+struct fs_path *
+fs_table_lookup_blkdev(
+	const char	*bdev)
+{
+	return __fs_table_lookup_mount(NULL, bdev);
+}
+
 static int
 fs_table_insert(
 	char		*dir,

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

* [PATCH 5/4] misc: remove darwin, irix, and freebsd support
  2018-03-20  3:08 [PATCH 0/4] xfsprogs: more misc fixes Darrick J. Wong
                   ` (3 preceding siblings ...)
  2018-03-20  3:08 ` [PATCH 4/4] mkfs: enable sparse inodes by default Darrick J. Wong
@ 2018-03-21  3:19 ` Darrick J. Wong
  2018-03-21 18:59   ` Eric Sandeen
  2018-03-21 19:42   ` [PATCH 5.5/4] " Eric Sandeen
  2018-03-21  3:20 ` [PATCH 6/4] libfrog: absorb platform specific code Darrick J. Wong
  2018-03-26 19:56 ` [PATCH 7/4] xfs_spaceman: remove incorrect linux/fs.h include Darrick J. Wong
  6 siblings, 2 replies; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-21  3:19 UTC (permalink / raw)
  To: sandeen; +Cc: linux-xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

Remove these ports since they're not actively maintained:

IRIX support was partially removed last year; the OS itself hasn't had a
release since 2006.

FreeBSD dropped XFS support in v9.3, which EOLd in January 2017.

Darwin/OSX has never supported XFS.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 include/darwin.h  |  315 -----------------------------------------------------
 include/freebsd.h |  210 -----------------------------------
 libxfs/Makefile   |    2 
 libxfs/darwin.c   |  144 ------------------------
 libxfs/freebsd.c  |  201 ----------------------------------
 libxfs/irix.c     |  111 -------------------
 6 files changed, 1 insertion(+), 982 deletions(-)
 delete mode 100644 include/darwin.h
 delete mode 100644 include/freebsd.h
 delete mode 100644 libxfs/darwin.c
 delete mode 100644 libxfs/freebsd.c
 delete mode 100644 libxfs/irix.c

diff --git a/include/darwin.h b/include/darwin.h
deleted file mode 100644
index 2632e1d..0000000
--- a/include/darwin.h
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-#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 <sys/time.h>
-#include <ftw.h>
-#include <mach/mach_time.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <sys/mman.h>
-
-#include <machine/endian.h>
-#define __BYTE_ORDER	BYTE_ORDER
-#define __BIG_ENDIAN	BIG_ENDIAN
-#define __LITTLE_ENDIAN	LITTLE_ENDIAN
-
-#include <sys/syscall.h>
-# 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);
-}
-
-static __inline__ int platform_test_xfs_fd(int fd)
-{
-	struct statfs buf;
-	if (fstatfs(fd, &buf) < 0)
-		return 0;
-	return strncmp(buf.f_fstypename, "xfs", 4) == 0;
-}
-
-static __inline__ int platform_test_xfs_path(const char *path)
-{
-	struct statfs buf;
-	if (statfs(path, &buf) < 0)
-		return 0;
-	return strncmp(buf.f_fstypename, "xfs", 4) == 0;
-}
-
-static __inline__ int platform_fstatfs(int fd, struct statfs *buf)
-{
-	return fstatfs(fd, buf);
-}
-
-static __inline__ void platform_getoptreset(void)
-{
-	extern int optreset;
-	optreset = 0;
-}
-
-static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2)
-{
-	return uuid_compare(*uu1, *uu2);
-}
-
-static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer)
-{
-	uuid_unparse(*uu, buffer);
-}
-
-static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu)
-{
-	return uuid_parse(buffer, *uu);
-}
-
-static __inline__ int platform_uuid_is_null(uuid_t *uu)
-{
-	return uuid_is_null(*uu);
-}
-
-static __inline__ void platform_uuid_generate(uuid_t *uu)
-{
-	uuid_generate(*uu);
-}
-
-static __inline__ void platform_uuid_clear(uuid_t *uu)
-{
-	uuid_clear(*uu);
-}
-
-static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src)
-{
-	uuid_copy(*dst, *src);
-}
-
-typedef unsigned char		__u8;
-typedef signed char		__s8;
-typedef unsigned short		__u16;
-typedef signed short		__s16;
-typedef unsigned int		__u32;
-typedef signed int		__s32;
-typedef unsigned long long int	__u64;
-typedef signed long long int	__s64;
-
-#define int8_t		int8_t
-#define int16_t		int16_t
-#define int32_t		int32_t
-#define int32_t		int32_t
-#define int64_t		int64_t
-
-typedef off_t		xfs_off_t;
-typedef uint64_t	xfs_ino_t;
-typedef uint32_t	xfs_dev_t;
-typedef int64_t		xfs_daddr_t;
-typedef __u32		xfs_nlink_t;
-
-#define fdatasync	fsync
-#define memalign(a,sz)	valloc(sz)
-
-#define O_LARGEFILE     0
-#ifndef O_DIRECT
-#define O_DIRECT        0
-#endif
-#ifndef O_SYNC
-#define O_SYNC          0
-#endif
-
-#define EFSCORRUPTED	990	/* Filesystem is corrupted */
-#define EFSBADCRC	991	/* Bad CRC detected */
-
-#define HAVE_FID	1
-
-static __inline__ int
-platform_discard_blocks(int fd, uint64_t start, uint64_t len)
-{
-	return 0;
-}
-
-/*
- * 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);
-}
-
-/* FSR */
-
-#  include <sys/mount.h>
-#  include <sys/param.h>
-#include <sys/ucred.h>
-#include <errno.h>
-#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;
-}
-
-
-
-/**
- * Abstraction of mountpoints.
- */
-struct mntent_cursor {
-	FILE *mtabp;
-	struct statfs *stats;
-	int count;
-	int i;
-};
-
-/**
- * OS X uses getmntinfo, which doesn't use a mtab file. So we just ignore it.
- */
-static inline int platform_mntent_open(struct mntent_cursor * cursor, char *mtab)
-{
-	if ((cursor->count = getmntinfo(&cursor->stats, 0)) < 0) {
-		fprintf(stderr, "Error: getmntinfo() failed: %s\n", strerror(errno));
-		return 1;
-	}
-	cursor->i = 0;
-	return 0;
-}
-
-static inline struct mntent * platform_mntent_next(struct mntent_cursor * cursor)
-{
-	struct mntent * t = NULL;
-	if (cursor->i >= cursor->count){
-		return NULL;
-	}
-	mntinfo2mntent(&cursor->stats[cursor->i], t);
-	cursor->i++;
-	return t;
-}
-
-static inline void platform_mntent_close(struct mntent_cursor * cursor)
-{
-	cursor->count = 0;
-	cursor->i = 0;
-}
-
-/* check whether we have to define FS_IOC_FS[GS]ETXATTR ourselves */
-#ifndef HAVE_FSXATTR
-struct fsxattr {
-	__u32		fsx_xflags;	/* xflags field value (get/set) */
-	__u32		fsx_extsize;	/* extsize field value (get/set)*/
-	__u32		fsx_nextents;	/* nextents field value (get)	*/
-	__u32		fsx_projid;	/* project identifier (get/set) */
-	__u32		fsx_cowextsize;	/* cow extsize field value (get/set) */
-	unsigned char	fsx_pad[8];
-};
-
-/*
- * Flags for the fsx_xflags field
- */
-#define FS_XFLAG_REALTIME	0x00000001	/* data in realtime volume */
-#define FS_XFLAG_PREALLOC	0x00000002	/* preallocated file extents */
-#define FS_XFLAG_IMMUTABLE	0x00000008	/* file cannot be modified */
-#define FS_XFLAG_APPEND		0x00000010	/* all writes append */
-#define FS_XFLAG_SYNC		0x00000020	/* all writes synchronous */
-#define FS_XFLAG_NOATIME	0x00000040	/* do not update access time */
-#define FS_XFLAG_NODUMP		0x00000080	/* do not include in backups */
-#define FS_XFLAG_RTINHERIT	0x00000100	/* create with rt bit set */
-#define FS_XFLAG_PROJINHERIT	0x00000200	/* create with parents projid */
-#define FS_XFLAG_NOSYMLINKS	0x00000400	/* disallow symlink creation */
-#define FS_XFLAG_EXTSIZE	0x00000800	/* extent size allocator hint */
-#define FS_XFLAG_EXTSZINHERIT	0x00001000	/* inherit inode extent size */
-#define FS_XFLAG_NODEFRAG	0x00002000	/* do not defragment */
-#define FS_XFLAG_FILESTREAM	0x00004000	/* use filestream allocator */
-#define FS_XFLAG_DAX		0x00008000	/* use DAX for IO */
-#define FS_XFLAG_HASATTR	0x80000000	/* no DIFLAG for this	*/
-
-#define FS_IOC_FSGETXATTR     _IOR ('X', 31, struct fsxattr)
-#define FS_IOC_FSSETXATTR     _IOW ('X', 32, struct fsxattr)
-
-#endif
-
-#ifndef FS_XFLAG_COWEXTSIZE
-#define FS_XFLAG_COWEXTSIZE	0x00010000	/* CoW extent size allocator hint */
-#endif
-
-#endif	/* __XFS_DARWIN_H__ */
diff --git a/include/freebsd.h b/include/freebsd.h
deleted file mode 100644
index f52ed0a..0000000
--- a/include/freebsd.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-#ifndef __XFS_FREEBSD_H__
-#define __XFS_FREEBSD_H__
-
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <sys/ioccom.h>
-#include <sys/mount.h>
-#include <ctype.h>
-#include <libgen.h>
-#include <paths.h>
-#include <uuid.h>
-#include <mntent.h>
-
-#include <sys/endian.h>
-#define __BYTE_ORDER	BYTE_ORDER
-#define __BIG_ENDIAN	BIG_ENDIAN
-#define __LITTLE_ENDIAN	LITTLE_ENDIAN
-
-/* FreeBSD file API is 64-bit aware */
-#define fdatasync	fsync
-#define memalign(a,sz)	valloc(sz)
-
-#define EFSCORRUPTED	990	/* Filesystem is corrupted */
-#define EFSBADCRC	991	/* Bad CRC detected */
-
-typedef unsigned char		__u8;
-typedef signed char		__s8;
-typedef unsigned short		__u16;
-typedef signed short		__s16;
-typedef unsigned int		__u32;
-typedef signed int		__s32;
-typedef unsigned long long int	__u64;
-typedef signed long long int	__s64;
-
-typedef off_t		xfs_off_t;
-typedef uint64_t	xfs_ino_t;
-typedef uint32_t	xfs_dev_t;
-typedef int64_t		xfs_daddr_t;
-typedef __u32		xfs_nlink_t;
-
-#define	O_LARGEFILE	0
-
-#define HAVE_FID	1
-
-static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p)
-{
-	return ioctl(fd, cmd, p);
-}
-
-static __inline__ int platform_test_xfs_fd(int fd)
-{
-	struct statfs buf;
-	if (fstatfs(fd, &buf) < 0)
-		return 0;
-	return strncmp(buf.f_fstypename, "xfs", 4) == 0;
-}
-
-static __inline__ int platform_test_xfs_path(const char *path)
-{
-	struct statfs buf;
-	if (statfs(path, &buf) < 0)
-		return 0;
-	return strncmp(buf.f_fstypename, "xfs", 4) == 0;
-}
-
-static __inline__ int platform_fstatfs(int fd, struct statfs *buf)
-{
-	return fstatfs(fd, buf);
-}
-
-static __inline__ void platform_getoptreset(void)
-{
-	extern int optind;
-	optind = 0;
-}
-
-static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2)
-{
-	return uuid_compare(uu1, uu2, NULL);
-}
-
-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);
-}
-
-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);
-}
-
-static __inline__ int platform_uuid_is_null(uuid_t *uu)
-{
-	return uuid_is_nil(uu, NULL);
-}
-
-static __inline__ void platform_uuid_generate(uuid_t *uu)
-{
-	uuid_create(uu, NULL);
-}
-
-static __inline__ void platform_uuid_clear(uuid_t *uu)
-{
-	uuid_create_nil(uu, NULL);
-}
-
-static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src)
-{
-	memcpy(dst, src, sizeof(uuid_t));
-}
-
-static __inline__ int
-platform_discard_blocks(int fd, uint64_t start, uint64_t len)
-{
-	return 0;
-}
-
-/**
- * Abstraction of mountpoints.
- */
-struct mntent_cursor {
-	FILE *mtabp;
-};
-
-static inline int platform_mntent_open(struct mntent_cursor * cursor, char *mtab)
-{
-	cursor->mtabp = setmntent(mtab, "r");
-	if (!cursor->mtabp) {
-		fprintf(stderr, "Error: cannot read %s\n", mtab);
-		return 1;
-	}
-	return 0;
-}
-
-static inline  struct mntent * platform_mntent_next(struct mntent_cursor * cursor)
-{
-	return getmntent(cursor->mtabp);
-}
-
-static inline void platform_mntent_close(struct mntent_cursor * cursor)
-{
-	endmntent(cursor->mtabp);
-}
-
-/* check whether we have to define FS_IOC_FS[GS]ETXATTR ourselves */
-#ifndef HAVE_FSXATTR
-struct fsxattr {
-	__u32		fsx_xflags;	/* xflags field value (get/set) */
-	__u32		fsx_extsize;	/* extsize field value (get/set)*/
-	__u32		fsx_nextents;	/* nextents field value (get)	*/
-	__u32		fsx_projid;	/* project identifier (get/set) */
-	__u32		fsx_cowextsize;	/* cow extsize field value (get/set) */
-	unsigned char	fsx_pad[8];
-};
-
-/*
- * Flags for the fsx_xflags field
- */
-#define FS_XFLAG_REALTIME	0x00000001	/* data in realtime volume */
-#define FS_XFLAG_PREALLOC	0x00000002	/* preallocated file extents */
-#define FS_XFLAG_IMMUTABLE	0x00000008	/* file cannot be modified */
-#define FS_XFLAG_APPEND		0x00000010	/* all writes append */
-#define FS_XFLAG_SYNC		0x00000020	/* all writes synchronous */
-#define FS_XFLAG_NOATIME	0x00000040	/* do not update access time */
-#define FS_XFLAG_NODUMP		0x00000080	/* do not include in backups */
-#define FS_XFLAG_RTINHERIT	0x00000100	/* create with rt bit set */
-#define FS_XFLAG_PROJINHERIT	0x00000200	/* create with parents projid */
-#define FS_XFLAG_NOSYMLINKS	0x00000400	/* disallow symlink creation */
-#define FS_XFLAG_EXTSIZE	0x00000800	/* extent size allocator hint */
-#define FS_XFLAG_EXTSZINHERIT	0x00001000	/* inherit inode extent size */
-#define FS_XFLAG_NODEFRAG	0x00002000	/* do not defragment */
-#define FS_XFLAG_FILESTREAM	0x00004000	/* use filestream allocator */
-#define FS_XFLAG_DAX		0x00008000	/* use DAX for IO */
-#define FS_XFLAG_HASATTR	0x80000000	/* no DIFLAG for this	*/
-
-#define FS_IOC_FSGETXATTR     _IOR ('X', 31, struct fsxattr)
-#define FS_IOC_FSSETXATTR     _IOW ('X', 32, struct fsxattr)
-
-#endif
-
-#ifndef FS_XFLAG_COWEXTSIZE
-#define FS_XFLAG_COWEXTSIZE	0x00010000	/* CoW extent size allocator hint */
-#endif
-
-#endif	/* __XFS_FREEBSD_H__ */
diff --git a/libxfs/Makefile b/libxfs/Makefile
index 0470f5f..00df418 100644
--- a/libxfs/Makefile
+++ b/libxfs/Makefile
@@ -98,7 +98,7 @@ CFILES = cache.c \
 	xfs_trans_resv.c
 
 CFILES += $(PKG_PLATFORM).c
-PCFILES = darwin.c freebsd.c irix.c linux.c
+PCFILES = linux.c
 LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")
 LSRCFILES += gen_crc32table.c
 
diff --git a/libxfs/darwin.c b/libxfs/darwin.c
deleted file mode 100644
index 16d2c35..0000000
--- a/libxfs/darwin.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (c) 2003,2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <sys/disk.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <sys/ioctl.h>
-#include <sys/sysctl.h>
-#include "libxfs.h"
-
-int platform_has_uuid = 1;
-extern char *progname;
-
-int
-platform_check_ismounted(char *name, char *block, struct stat *s, int verbose)
-{
-	return 0;
-}
-
-int
-platform_check_iswritable(char *name, char *block, struct stat *s)
-{
-	int	fd, writable;
-
-	if ((fd = open(block, O_RDONLY, 0)) < 0) {
-		fprintf(stderr, _("%s: "
-			"error opening the device special file \"%s\": %s\n"),
-			progname, block, strerror(errno));
-		exit(1);
-	}
-
-	if (ioctl(fd, DKIOCISWRITABLE, &writable) < 0) {
-		fprintf(stderr, _("%s: can't tell if \"%s\" is writable: %s\n"),
-			progname, block, strerror(errno));
-		exit(1);
-	}
-	close(fd);
-	return writable == 0;
-}
-
-int
-platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal)
-{
-	return fatal;
-}
-
-void
-platform_flush_device(int fd, dev_t device)
-{
-	ioctl(fd, DKIOCSYNCHRONIZECACHE, NULL);
-}
-
-void
-platform_findsizes(char *path, int fd, long long *sz, int *bsz)
-{
-	uint64_t	size;
-	struct stat	st;
-
-	if (fstat(fd, &st) < 0) {
-		fprintf(stderr,
-			_("%s: cannot stat the device file \"%s\": %s\n"),
-			progname, path, strerror(errno));
-		exit(1);
-	}
-	if ((st.st_mode & S_IFMT) == S_IFREG) {
-		*sz = (long long)(st.st_size >> 9);
-		*bsz = BBSIZE;
-		return;
-	}
-	if (ioctl(fd, DKIOCGETBLOCKCOUNT, &size) < 0) {
-		fprintf(stderr, _("%s: can't determine device size: %s\n"),
-			progname, strerror(errno));
-		exit(1);
-	}
-	*sz = (long long)size;
-	*bsz = BBSIZE;
-}
-
-char *
-platform_findrawpath(char *path)
-{
-	return path;
-}
-
-char *
-platform_findblockpath(char *path)
-{
-	return path;
-}
-
-int
-platform_direct_blockdev(void)
-{
-	return 0;
-}
-
-int
-platform_align_blockdev(void)
-{
-	return sizeof(void *);
-}
-
-int
-platform_nproc(void)
-{
-	int		ncpu;
-	size_t		len = sizeof(ncpu);
-	static int	mib[2] = {CTL_HW, HW_NCPU};
-
-	if (sysctl(mib, 2, &ncpu, &len, NULL, 0) < 0)
-		ncpu = 1;
-
-	return ncpu;
-}
-
-unsigned long
-platform_physmem(void)
-{
-	unsigned long	physmem;
-	size_t		len = sizeof(physmem);
-	static int	mib[2] = {CTL_HW, HW_PHYSMEM};
-
-	if (sysctl(mib, 2, &physmem, &len, NULL, 0) < 0) {
-		fprintf(stderr, _("%s: can't determine memory size\n"),
-			progname);
-		exit(1);
-	}
-	return physmem >> 10;
-}
diff --git a/libxfs/freebsd.c b/libxfs/freebsd.c
deleted file mode 100644
index 5b9ef29..0000000
--- a/libxfs/freebsd.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (c) 2003,2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "libxfs.h"
-#include <sys/stat.h>
-#include <sys/disk.h>
-#include <sys/mount.h>
-#include <sys/ioctl.h>
-#include <sys/sysctl.h>
-
-int platform_has_uuid = 1;
-extern char *progname;
-
-int
-platform_check_ismounted(char *name, char *block, struct stat *s, int verbose)
-{
-	struct stat	st;
-        int cnt, i;
-        struct statfs *fsinfo;
-
-	if (!s) {
-		if (stat(block, &st) < 0)
-			return 0;
-		s = &st;
-	}
-
-	/* Remember, FreeBSD can now mount char devices! -- adrian */
-	if (((st.st_mode & S_IFMT) != S_IFBLK) &&
-	    ((st.st_mode & S_IFMT) != S_IFCHR))
-		return 0;
-
-	if ((cnt = getmntinfo(&fsinfo, MNT_NOWAIT)) == 0) {
-		fprintf(stderr,
-		    _("%s: %s possibly contains a mounted filesystem\n"),
-		    progname, name);
-		return 1;
-	}
-
-        for (i = 0; i < cnt; i++) {
-                if (strcmp (name, fsinfo[i].f_mntfromname) != 0)
-			continue;
-
-		if (verbose)
-			fprintf(stderr,
-			    _("%s: %s contains a mounted filesystem\n"),
-			    progname, name);
-		break;
-	}
-
-        return i < cnt;
-}
-
-int
-platform_check_iswritable(char *name, char *block, struct stat *s)
-{
-        int cnt, i;
-        struct statfs *fsinfo;
-
-        if ((cnt = getmntinfo(&fsinfo, MNT_NOWAIT)) == 0) {
-		fprintf(stderr, _("%s: %s contains a possibly writable, "
-				"mounted filesystem\n"), progname, name);
-			return 1;
-	}
-
-        for (i = 0; i < cnt; i++) {
-                if (strcmp (name, fsinfo[i].f_mntfromname) != 0)
-			continue;
-
-		if (fsinfo[i].f_flags &= MNT_RDONLY)
-			break;
-	}
-
-        if (i == cnt) {
-		fprintf(stderr, _("%s: %s contains a mounted and writable "
-				"filesystem\n"), progname, name);
-		return 1;
-	}
-	return 0;
-}
-
-int
-platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal)
-{
-	return fatal;
-}
-
-void
-platform_flush_device(int fd, dev_t device)
-{
-	return;
-}
-
-void
-platform_findsizes(char *path, int fd, long long *sz, int *bsz)
-{
-	struct stat	st;
-	int64_t		size;
-	uint		ssize;
-
-	if (fstat(fd, &st) < 0) {
-		fprintf(stderr, _("%s: "
-			"cannot stat the device file \"%s\": %s\n"),
-			progname, path, strerror(errno));
-		exit(1);
-	}
-
-	if ((st.st_mode & S_IFMT) == S_IFREG) {
-		*sz = (long long)(st.st_size >> 9);
-		*bsz = 512;
-		return;
-	}
-
-	if ((st.st_mode & S_IFMT) != S_IFCHR) {
-		fprintf(stderr, _("%s: Not a device or file: \"%s\"\n"),
-			progname, path);
-		exit(1);
-	}
-
-	if (ioctl(fd, DIOCGMEDIASIZE, &size) != 0) {
-		fprintf(stderr, _("%s: DIOCGMEDIASIZE failed on \"%s\": %s\n"),
-			progname, path, strerror(errno));
-		exit(1);
-	}
-
-	if (ioctl(fd, DIOCGSECTORSIZE, &ssize) != 0) {
-		fprintf(stderr, _("%s: "
-			"DIOCGSECTORSIZE failed on \"%s\": %s\n"),
-			progname, path, strerror(errno));
-		exit(1);
-	}
-
-	*sz = (long long) (size / ssize);
-	*bsz = (int)ssize;
-}
-
-char *
-platform_findrawpath(char *path)
-{
-	return path;
-}
-
-char *
-platform_findblockpath(char *path)
-{
-	return path;
-}
-
-int
-platform_direct_blockdev(void)
-{
-	return 0;
-}
-
-int
-platform_align_blockdev(void)
-{
-	return sizeof(void *);
-}
-
-int
-platform_nproc(void)
-{
-	int		ncpu;
-	size_t		len = sizeof(ncpu);
-	static int	mib[2] = {CTL_HW, HW_NCPU};
-
-	if (sysctl(mib, 2, &ncpu, &len, NULL, 0) < 0)
-		ncpu = 1;
-
-	return ncpu;
-}
-
-unsigned long
-platform_physmem(void)
-{
-	unsigned long	physmem;
-	size_t		len = sizeof(physmem);
-	static int	mib[2] = {CTL_HW, HW_PHYSMEM};
-
-	if (sysctl(mib, 2, &physmem, &len, NULL, 0) < 0) {
-		fprintf(stderr, _("%s: can't determine memory size\n"),
-			progname);
-		exit(1);
-	}
-	return physmem >> 10;
-}
diff --git a/libxfs/irix.c b/libxfs/irix.c
deleted file mode 100644
index 0f14aec..0000000
--- a/libxfs/irix.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "libxfs.h"
-#include <diskinfo.h>
-#include <sys/sysmp.h>
-
-int platform_has_uuid = 0;
-extern char *progname;
-extern int64_t findsize(char *);
-
-int
-platform_check_ismounted(char *name, char *block, struct stat *s, int verbose)
-{
-	return 0;
-}
-
-int
-platform_check_iswritable(char *name, char *block, struct stat *s)
-{
-	return 1;
-}
-
-int
-platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal)
-{
-	return fatal;
-}
-
-void
-platform_flush_device(int fd, dev_t device)
-{
-	return;
-}
-
-void
-platform_findsizes(char *path, int fd, long long *sz, int *bsz)
-{
-	struct stat		st;
-
-	if (fstat(fd, &st) < 0) {
-		fprintf(stderr,
-			_("%s: cannot stat the device file \"%s\": %s\n"),
-			progname, path, strerror(errno));
-		exit(1);
-	}
-	if ((st.st_mode & S_IFMT) == S_IFREG) {
-		*sz = (long long)(st.st_size >> 9);
-	} else {
-		*sz = findsize(path);
-	}
-	*bsz = BBSIZE;
-}
-
-char *
-platform_findrawpath(char *path)
-{
-	return findrawpath(path);
-}
-
-char *
-platform_findblockpath(char *path)
-{
-	return findblockpath(path);
-}
-
-int
-platform_direct_blockdev(void)
-{
-	return 0;
-}
-
-int
-platform_align_blockdev(void)
-{
-	return sizeof(void *);
-}
-
-int
-platform_nproc(void)
-{
-	return sysmp(MP_NPROCS);
-}
-
-unsigned long
-platform_physmem(void)
-{
-	struct rminfo ri;
-
-	if (sysmp(MP_SAGET, MPSA_RMINFO, &ri, sizeof(ri)) < 0)
-		fprintf(stderr, _("%s: can't determine memory size\n"),
-			progname);
-		exit(1);
-	}
-	return (ri.physmem >> 10) * getpagesize();	/* kilobytes */
-}

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

* [PATCH 6/4] libfrog: absorb platform specific code
  2018-03-20  3:08 [PATCH 0/4] xfsprogs: more misc fixes Darrick J. Wong
                   ` (4 preceding siblings ...)
  2018-03-21  3:19 ` [PATCH 5/4] misc: remove darwin, irix, and freebsd support Darrick J. Wong
@ 2018-03-21  3:20 ` Darrick J. Wong
  2018-03-21 19:52   ` Eric Sandeen
  2018-03-26 19:56 ` [PATCH 7/4] xfs_spaceman: remove incorrect linux/fs.h include Darrick J. Wong
  6 siblings, 1 reply; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-21  3:20 UTC (permalink / raw)
  To: sandeen; +Cc: linux-xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

Move the linux support code to libfrog, which should remove the final
dependency of libfrog on libxfs.  libfrog is the runtime support library
anyway.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libfrog/Makefile |    4 +
 libfrog/linux.c  |  265 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 libxfs/Makefile  |    3 -
 libxfs/linux.c   |  265 ------------------------------------------------------
 4 files changed, 269 insertions(+), 268 deletions(-)
 create mode 100644 libfrog/linux.c
 delete mode 100644 libxfs/linux.c

diff --git a/libfrog/Makefile b/libfrog/Makefile
index 230b08f..e3065e6 100644
--- a/libfrog/Makefile
+++ b/libfrog/Makefile
@@ -22,6 +22,10 @@ topology.c \
 util.c \
 workqueue.c
 
+CFILES += $(PKG_PLATFORM).c
+PCFILES = linux.c
+LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")
+
 ifeq ($(HAVE_GETMNTENT),yes)
 LCFLAGS += -DHAVE_GETMNTENT
 endif
diff --git a/libfrog/linux.c b/libfrog/linux.c
new file mode 100644
index 0000000..0bace3e
--- /dev/null
+++ b/libfrog/linux.c
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <mntent.h>
+#include <sys/stat.h>
+#include <sys/mount.h>
+#include <sys/ioctl.h>
+#include <sys/sysinfo.h>
+
+#include "libxfs_priv.h"
+#include "xfs_fs.h"
+
+int platform_has_uuid = 1;
+extern char *progname;
+static int max_block_alignment;
+
+#ifndef BLKGETSIZE64
+# define BLKGETSIZE64	_IOR(0x12,114,size_t)
+#endif
+#ifndef BLKBSZSET
+# define BLKBSZSET	_IOW(0x12,113,size_t)
+#endif
+#ifndef BLKSSZGET
+# define BLKSSZGET	_IO(0x12,104)
+#endif
+
+#ifndef RAMDISK_MAJOR
+#define RAMDISK_MAJOR	1	/* ramdisk major number */
+#endif
+
+#define PROC_MOUNTED	"/proc/mounts"
+
+/*
+ * Check if the filesystem is mounted.  Be verbose if asked, and
+ * optionally restrict check to /writable/ mounts (i.e. RO is OK)
+ */
+#define	CHECK_MOUNT_VERBOSE	0x1
+#define	CHECK_MOUNT_WRITABLE	0x2
+
+static int
+platform_check_mount(char *name, char *block, struct stat *s, int flags)
+{
+	FILE		*f;
+	struct stat	st, mst;
+	struct mntent	*mnt;
+	char		mounts[MAXPATHLEN];
+
+	if (!s) {
+		/* If either fails we are not mounted */
+		if (stat(block, &st) < 0)
+			return 0;
+		if ((st.st_mode & S_IFMT) != S_IFBLK)
+			return 0;
+		s = &st;
+	}
+
+	strcpy(mounts, (!access(PROC_MOUNTED, R_OK)) ? PROC_MOUNTED : MOUNTED);
+	if ((f = setmntent(mounts, "r")) == NULL) {
+		/* Unexpected failure, warn unconditionally */
+		fprintf(stderr,
+		    _("%s: %s possibly contains a mounted filesystem\n"),
+		    progname, name);
+		return 1;
+	}
+	while ((mnt = getmntent(f)) != NULL) {
+		if (stat(mnt->mnt_dir, &mst) < 0)
+			continue;
+		if (mst.st_dev != s->st_rdev)
+			continue;
+		/* Found our device, is RO OK? */
+		if ((flags & CHECK_MOUNT_WRITABLE) && hasmntopt(mnt, MNTOPT_RO))
+			continue;
+		else
+			break;
+	}
+	endmntent(f);
+
+	/* No mounts contained the condition we were looking for */
+	if (mnt == NULL)
+		return 0;
+
+	if (flags & CHECK_MOUNT_VERBOSE) {
+		if (flags & CHECK_MOUNT_WRITABLE) {
+			fprintf(stderr,
+_("%s: %s contains a mounted and writable filesystem\n"),
+				progname, name);
+		} else {
+			fprintf(stderr,
+_("%s: %s contains a mounted filesystem\n"),
+				progname, name);
+		}
+	}
+	return 1;
+}
+
+int
+platform_check_ismounted(char *name, char *block, struct stat *s, int verbose)
+{
+	int flags;
+
+	flags = verbose ? CHECK_MOUNT_VERBOSE : 0;
+	return platform_check_mount(name, block, s, flags);
+}
+
+int
+platform_check_iswritable(char *name, char *block, struct stat *s)
+{
+	int flags;
+
+	/* Writable checks are always verbose */
+	flags = CHECK_MOUNT_WRITABLE | CHECK_MOUNT_VERBOSE;
+	return platform_check_mount(name, block, s, flags);
+}
+
+int
+platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal)
+{
+	int error = 0;
+
+	if (major(device) != RAMDISK_MAJOR) {
+		if ((error = ioctl(fd, BLKBSZSET, &blocksize)) < 0) {
+			fprintf(stderr, _("%s: %s - cannot set blocksize "
+					"%d on block device %s: %s\n"),
+				progname, fatal ? "error": "warning",
+				blocksize, path, strerror(errno));
+		}
+	}
+	return error;
+}
+
+void
+platform_flush_device(int fd, dev_t device)
+{
+	struct stat	st;
+	if (major(device) == RAMDISK_MAJOR)
+		return;
+
+	if (fstat(fd, &st) < 0)
+		return;
+
+	if (S_ISREG(st.st_mode))
+		fsync(fd);
+	else
+		ioctl(fd, BLKFLSBUF, 0);
+}
+
+void
+platform_findsizes(char *path, int fd, long long *sz, int *bsz)
+{
+	struct stat	st;
+	uint64_t	size;
+	int		error;
+
+	if (fstat(fd, &st) < 0) {
+		fprintf(stderr, _("%s: "
+			"cannot stat the device file \"%s\": %s\n"),
+			progname, path, strerror(errno));
+		exit(1);
+	}
+
+	if ((st.st_mode & S_IFMT) == S_IFREG) {
+		struct dioattr	da;
+
+		*sz = (long long)(st.st_size >> 9);
+
+		if (ioctl(fd, XFS_IOC_DIOINFO, &da) < 0) {
+			/*
+			 * fall back to BBSIZE; mkfs might fail if there's a
+			 * size mismatch between the image & the host fs...
+			 */
+			*bsz = BBSIZE;
+		} else
+			*bsz = da.d_miniosz;
+
+		if (*bsz > max_block_alignment)
+			max_block_alignment = *bsz;
+		return;
+	}
+
+	error = ioctl(fd, BLKGETSIZE64, &size);
+	if (error >= 0) {
+		/* BLKGETSIZE64 returns size in bytes not 512-byte blocks */
+		*sz = (long long)(size >> 9);
+	} else {
+		/* If BLKGETSIZE64 fails, try BLKGETSIZE */
+		unsigned long tmpsize;
+
+		error = ioctl(fd, BLKGETSIZE, &tmpsize);
+		if (error < 0) {
+			fprintf(stderr, _("%s: can't determine device size\n"),
+				progname);
+			exit(1);
+		}
+		*sz = (long long)tmpsize;
+	}
+
+	if (ioctl(fd, BLKSSZGET, bsz) < 0) {
+		fprintf(stderr, _("%s: warning - cannot get sector size "
+				"from block device %s: %s\n"),
+			progname, path, strerror(errno));
+		*bsz = BBSIZE;
+	}
+	if (*bsz > max_block_alignment)
+		max_block_alignment = *bsz;
+}
+
+char *
+platform_findrawpath(char *path)
+{
+	return path;
+}
+
+char *
+platform_findblockpath(char *path)
+{
+	return path;
+}
+
+int
+platform_direct_blockdev(void)
+{
+	return 1;
+}
+
+int
+platform_align_blockdev(void)
+{
+	if (!max_block_alignment)
+		return getpagesize();
+	return max_block_alignment;
+}
+
+int
+platform_nproc(void)
+{
+	return sysconf(_SC_NPROCESSORS_ONLN);
+}
+
+unsigned long
+platform_physmem(void)
+{
+	struct sysinfo  si;
+
+	if (sysinfo(&si) < 0) {
+		fprintf(stderr, _("%s: can't determine memory size\n"),
+			progname);
+		exit(1);
+	}
+	return (si.totalram >> 10) * si.mem_unit;	/* kilobytes */
+}
diff --git a/libxfs/Makefile b/libxfs/Makefile
index 00df418..7cde18d 100644
--- a/libxfs/Makefile
+++ b/libxfs/Makefile
@@ -97,9 +97,6 @@ CFILES = cache.c \
 	xfs_symlink_remote.c \
 	xfs_trans_resv.c
 
-CFILES += $(PKG_PLATFORM).c
-PCFILES = linux.c
-LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")
 LSRCFILES += gen_crc32table.c
 
 #
diff --git a/libxfs/linux.c b/libxfs/linux.c
deleted file mode 100644
index 0bace3e..0000000
--- a/libxfs/linux.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <mntent.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <sys/ioctl.h>
-#include <sys/sysinfo.h>
-
-#include "libxfs_priv.h"
-#include "xfs_fs.h"
-
-int platform_has_uuid = 1;
-extern char *progname;
-static int max_block_alignment;
-
-#ifndef BLKGETSIZE64
-# define BLKGETSIZE64	_IOR(0x12,114,size_t)
-#endif
-#ifndef BLKBSZSET
-# define BLKBSZSET	_IOW(0x12,113,size_t)
-#endif
-#ifndef BLKSSZGET
-# define BLKSSZGET	_IO(0x12,104)
-#endif
-
-#ifndef RAMDISK_MAJOR
-#define RAMDISK_MAJOR	1	/* ramdisk major number */
-#endif
-
-#define PROC_MOUNTED	"/proc/mounts"
-
-/*
- * Check if the filesystem is mounted.  Be verbose if asked, and
- * optionally restrict check to /writable/ mounts (i.e. RO is OK)
- */
-#define	CHECK_MOUNT_VERBOSE	0x1
-#define	CHECK_MOUNT_WRITABLE	0x2
-
-static int
-platform_check_mount(char *name, char *block, struct stat *s, int flags)
-{
-	FILE		*f;
-	struct stat	st, mst;
-	struct mntent	*mnt;
-	char		mounts[MAXPATHLEN];
-
-	if (!s) {
-		/* If either fails we are not mounted */
-		if (stat(block, &st) < 0)
-			return 0;
-		if ((st.st_mode & S_IFMT) != S_IFBLK)
-			return 0;
-		s = &st;
-	}
-
-	strcpy(mounts, (!access(PROC_MOUNTED, R_OK)) ? PROC_MOUNTED : MOUNTED);
-	if ((f = setmntent(mounts, "r")) == NULL) {
-		/* Unexpected failure, warn unconditionally */
-		fprintf(stderr,
-		    _("%s: %s possibly contains a mounted filesystem\n"),
-		    progname, name);
-		return 1;
-	}
-	while ((mnt = getmntent(f)) != NULL) {
-		if (stat(mnt->mnt_dir, &mst) < 0)
-			continue;
-		if (mst.st_dev != s->st_rdev)
-			continue;
-		/* Found our device, is RO OK? */
-		if ((flags & CHECK_MOUNT_WRITABLE) && hasmntopt(mnt, MNTOPT_RO))
-			continue;
-		else
-			break;
-	}
-	endmntent(f);
-
-	/* No mounts contained the condition we were looking for */
-	if (mnt == NULL)
-		return 0;
-
-	if (flags & CHECK_MOUNT_VERBOSE) {
-		if (flags & CHECK_MOUNT_WRITABLE) {
-			fprintf(stderr,
-_("%s: %s contains a mounted and writable filesystem\n"),
-				progname, name);
-		} else {
-			fprintf(stderr,
-_("%s: %s contains a mounted filesystem\n"),
-				progname, name);
-		}
-	}
-	return 1;
-}
-
-int
-platform_check_ismounted(char *name, char *block, struct stat *s, int verbose)
-{
-	int flags;
-
-	flags = verbose ? CHECK_MOUNT_VERBOSE : 0;
-	return platform_check_mount(name, block, s, flags);
-}
-
-int
-platform_check_iswritable(char *name, char *block, struct stat *s)
-{
-	int flags;
-
-	/* Writable checks are always verbose */
-	flags = CHECK_MOUNT_WRITABLE | CHECK_MOUNT_VERBOSE;
-	return platform_check_mount(name, block, s, flags);
-}
-
-int
-platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal)
-{
-	int error = 0;
-
-	if (major(device) != RAMDISK_MAJOR) {
-		if ((error = ioctl(fd, BLKBSZSET, &blocksize)) < 0) {
-			fprintf(stderr, _("%s: %s - cannot set blocksize "
-					"%d on block device %s: %s\n"),
-				progname, fatal ? "error": "warning",
-				blocksize, path, strerror(errno));
-		}
-	}
-	return error;
-}
-
-void
-platform_flush_device(int fd, dev_t device)
-{
-	struct stat	st;
-	if (major(device) == RAMDISK_MAJOR)
-		return;
-
-	if (fstat(fd, &st) < 0)
-		return;
-
-	if (S_ISREG(st.st_mode))
-		fsync(fd);
-	else
-		ioctl(fd, BLKFLSBUF, 0);
-}
-
-void
-platform_findsizes(char *path, int fd, long long *sz, int *bsz)
-{
-	struct stat	st;
-	uint64_t	size;
-	int		error;
-
-	if (fstat(fd, &st) < 0) {
-		fprintf(stderr, _("%s: "
-			"cannot stat the device file \"%s\": %s\n"),
-			progname, path, strerror(errno));
-		exit(1);
-	}
-
-	if ((st.st_mode & S_IFMT) == S_IFREG) {
-		struct dioattr	da;
-
-		*sz = (long long)(st.st_size >> 9);
-
-		if (ioctl(fd, XFS_IOC_DIOINFO, &da) < 0) {
-			/*
-			 * fall back to BBSIZE; mkfs might fail if there's a
-			 * size mismatch between the image & the host fs...
-			 */
-			*bsz = BBSIZE;
-		} else
-			*bsz = da.d_miniosz;
-
-		if (*bsz > max_block_alignment)
-			max_block_alignment = *bsz;
-		return;
-	}
-
-	error = ioctl(fd, BLKGETSIZE64, &size);
-	if (error >= 0) {
-		/* BLKGETSIZE64 returns size in bytes not 512-byte blocks */
-		*sz = (long long)(size >> 9);
-	} else {
-		/* If BLKGETSIZE64 fails, try BLKGETSIZE */
-		unsigned long tmpsize;
-
-		error = ioctl(fd, BLKGETSIZE, &tmpsize);
-		if (error < 0) {
-			fprintf(stderr, _("%s: can't determine device size\n"),
-				progname);
-			exit(1);
-		}
-		*sz = (long long)tmpsize;
-	}
-
-	if (ioctl(fd, BLKSSZGET, bsz) < 0) {
-		fprintf(stderr, _("%s: warning - cannot get sector size "
-				"from block device %s: %s\n"),
-			progname, path, strerror(errno));
-		*bsz = BBSIZE;
-	}
-	if (*bsz > max_block_alignment)
-		max_block_alignment = *bsz;
-}
-
-char *
-platform_findrawpath(char *path)
-{
-	return path;
-}
-
-char *
-platform_findblockpath(char *path)
-{
-	return path;
-}
-
-int
-platform_direct_blockdev(void)
-{
-	return 1;
-}
-
-int
-platform_align_blockdev(void)
-{
-	if (!max_block_alignment)
-		return getpagesize();
-	return max_block_alignment;
-}
-
-int
-platform_nproc(void)
-{
-	return sysconf(_SC_NPROCESSORS_ONLN);
-}
-
-unsigned long
-platform_physmem(void)
-{
-	struct sysinfo  si;
-
-	if (sysinfo(&si) < 0) {
-		fprintf(stderr, _("%s: can't determine memory size\n"),
-			progname);
-		exit(1);
-	}
-	return (si.totalram >> 10) * si.mem_unit;	/* kilobytes */
-}

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

* Re: [PATCH v2 1/4] xfs_repair: implement custom ifork verifiers
  2018-03-20 21:47   ` [PATCH v2 " Darrick J. Wong
@ 2018-03-21 18:37     ` Eric Sandeen
  0 siblings, 0 replies; 27+ messages in thread
From: Eric Sandeen @ 2018-03-21 18:37 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs

On 3/20/18 4:47 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> There are a few cases where an early stage of xfs_repair will write an
> invalid inode fork buffer to signal to a later stage that it needs to
> correct the value.  This happens in phase 4 when we detect an inline
> format directory with an invalid .. pointer.  To avoid triggering the
> ifork verifiers on this, inject a custom verifier for phase 6 that lets
> this pass for now.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks good, thanks.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
> v2: fix misleading comments, remove pointless wrappers
> ---
>  libxfs/libxfs_api_defs.h |    2 ++
>  repair/phase6.c          |   57 +++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 58 insertions(+), 1 deletion(-)
> 
> diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
> index 5d56340..78daca0 100644
> --- a/libxfs/libxfs_api_defs.h
> +++ b/libxfs/libxfs_api_defs.h
> @@ -150,5 +150,7 @@
>  #define xfs_rmap_lookup_le_range	libxfs_rmap_lookup_le_range
>  #define xfs_refc_block			libxfs_refc_block
>  #define xfs_rmap_compare		libxfs_rmap_compare
> +#define xfs_dir_get_ops			libxfs_dir_get_ops
> +#define xfs_default_ifork_ops		libxfs_default_ifork_ops
>  
>  #endif /* __LIBXFS_API_DEFS_H__ */
> diff --git a/repair/phase6.c b/repair/phase6.c
> index aff83bc..ed005e8 100644
> --- a/repair/phase6.c
> +++ b/repair/phase6.c
> @@ -39,6 +39,61 @@ static struct xfs_name		xfs_name_dot = {(unsigned char *)".",
>  						XFS_DIR3_FT_DIR};
>  
>  /*
> + * When we're checking directory inodes, we're allowed to set a directory's
> + * dotdot entry to zero to signal that the parent needs to be reconnected
> + * during phase 6.  If we're handling a shortform directory the ifork
> + * verifiers will fail, so temporarily patch out this canary so that we can
> + * verify the rest of the fork and move on to fixing the dir.
> + */
> +static xfs_failaddr_t
> +phase6_verify_dir(
> +	struct xfs_inode		*ip)
> +{
> +	struct xfs_mount		*mp = ip->i_mount;
> +	const struct xfs_dir_ops	*dops;
> +	struct xfs_ifork		*ifp;
> +	struct xfs_dir2_sf_hdr		*sfp;
> +	xfs_failaddr_t			fa;
> +	xfs_ino_t			old_parent;
> +	bool				parent_bypass = false;
> +	int				size;
> +
> +	dops = libxfs_dir_get_ops(mp, NULL);
> +
> +	ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
> +	sfp = (struct xfs_dir2_sf_hdr *)ifp->if_u1.if_data;
> +	size = ifp->if_bytes;
> +
> +	/*
> +	 * If this is a shortform directory, phase4 may have set the parent
> +	 * inode to zero to indicate that it must be fixed.  Temporarily
> +	 * set a valid parent so that the directory verifier will pass.
> +	 */
> +	if (size > offsetof(struct xfs_dir2_sf_hdr, parent) &&
> +	    size >= xfs_dir2_sf_hdr_size(sfp->i8count)) {
> +		old_parent = dops->sf_get_parent_ino(sfp);
> +		if (old_parent == 0) {
> +			dops->sf_put_parent_ino(sfp, mp->m_sb.sb_rootino);
> +			parent_bypass = true;
> +		}
> +	}
> +
> +	fa = libxfs_default_ifork_ops.verify_dir(ip);
> +
> +	/* Put it back. */
> +	if (parent_bypass)
> +		dops->sf_put_parent_ino(sfp, old_parent);
> +
> +	return fa;
> +}
> +
> +static struct xfs_ifork_ops phase6_ifork_ops = {
> +	.verify_attr	= xfs_attr_shortform_verify,
> +	.verify_dir	= phase6_verify_dir,
> +	.verify_symlink	= xfs_symlink_shortform_verify,
> +};
> +
> +/*
>   * Data structures used to keep track of directories where the ".."
>   * entries are updated. These must be rebuilt after the initial pass
>   */
> @@ -2833,7 +2888,7 @@ process_dir_inode(
>  
>  	ASSERT(!is_inode_refchecked(irec, ino_offset) || dotdot_update);
>  
> -	error = -libxfs_iget(mp, NULL, ino, 0, &ip, NULL);
> +	error = -libxfs_iget(mp, NULL, ino, 0, &ip, &phase6_ifork_ops);
>  	if (error) {
>  		if (!no_modify)
>  			do_error(
> 


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

* Re: [PATCH v2 3/4] xfs_fsr: refactor mountpoint finding to use libfrog paths functions
  2018-03-21  3:19   ` [PATCH v2 " Darrick J. Wong
@ 2018-03-21 18:49     ` Eric Sandeen
  0 siblings, 0 replies; 27+ messages in thread
From: Eric Sandeen @ 2018-03-21 18:49 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs

On 3/20/18 10:19 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Refactor the mount-point finding code in fsr to use the libfrog helpers
> instead of open-coding yet another routine.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Seems fine, I'll test further but:

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
> v2: fix obvious brokenness w/ path testing
> ---
>  fsr/Makefile    |    4 ++-
>  fsr/xfs_fsr.c   |   73 ++++++-------------------------------------------------
>  include/path.h  |    1 +
>  libfrog/paths.c |   48 ++++++++++++++++++++++++++----------
>  4 files changed, 47 insertions(+), 79 deletions(-)
> 
> diff --git a/fsr/Makefile b/fsr/Makefile
> index d3521b2..4201b38 100644
> --- a/fsr/Makefile
> +++ b/fsr/Makefile
> @@ -7,7 +7,9 @@ include $(TOPDIR)/include/builddefs
>  
>  LTCOMMAND = xfs_fsr
>  CFILES = xfs_fsr.c
> -LLDLIBS = $(LIBHANDLE)
> +LLDLIBS = $(LIBHANDLE) $(LIBFROG) $(LIBPTHREAD) $(LIBBLKID)
> +LTDEPENDENCIES = $(LIBHANDLE) $(LIBFROG)
> +LLDFLAGS = -static-libtool-libs
>  
>  ifeq ($(HAVE_GETMNTENT),yes)
>  LCFLAGS += -DHAVE_GETMNTENT
> diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
> index 2a18ce0..b74a70b 100644
> --- a/fsr/xfs_fsr.c
> +++ b/fsr/xfs_fsr.c
> @@ -22,6 +22,7 @@
>  #include "jdm.h"
>  #include "xfs_bmap_btree.h"
>  #include "xfs_attr_sf.h"
> +#include "path.h"
>  
>  #include <fcntl.h>
>  #include <errno.h>
> @@ -167,73 +168,13 @@ aborter(int unused)
>  	exit(1);
>  }
>  
> -/*
> - * Check if the argument is either the device name or mountpoint of an XFS
> - * filesystem.  Note that we do not care about bind mounted regular files
> - * here - the code that handles defragmentation of invidual files takes care
> - * of that.
> - */
> -static char *
> -find_mountpoint_check(struct stat *sb, struct mntent *t)
> -{
> -	struct stat ms;
> -
> -	if (S_ISDIR(sb->st_mode)) {		/* mount point */
> -		if (stat(t->mnt_dir, &ms) < 0)
> -			return NULL;
> -		if (sb->st_ino != ms.st_ino)
> -			return NULL;
> -		if (sb->st_dev != ms.st_dev)
> -			return NULL;
> -		if (strcmp(t->mnt_type, MNTTYPE_XFS) != 0)
> -			return NULL;
> -	} else {				/* device */
> -		if (stat(t->mnt_fsname, &ms) < 0)
> -			return NULL;
> -		if (sb->st_rdev != ms.st_rdev)
> -			return NULL;
> -		if (strcmp(t->mnt_type, MNTTYPE_XFS) != 0)
> -			return NULL;
> -		/*
> -		 * Make sure the mountpoint given by mtab is accessible
> -		 * before using it.
> -		 */
> -		if (stat(t->mnt_dir, &ms) < 0)
> -			return NULL;
> -	}
> -
> -	return t->mnt_dir;
> -}
> -
> -static char *
> -find_mountpoint(char *mtab, char *argname, struct stat *sb)
> -{
> -	struct mntent_cursor cursor;
> -	struct mntent *t = NULL;
> -	char *mntp = NULL;
> -
> -	if (platform_mntent_open(&cursor, mtab) != 0){
> -		fprintf(stderr, "Error: can't get mntent entries.\n");
> -		exit(1);
> -	}
> -
> -	while ((t = platform_mntent_next(&cursor)) != NULL) {
> -		mntp = find_mountpoint_check(sb, t);
> -		if (mntp == NULL)
> -			continue;
> -		break;
> -	}
> -	platform_mntent_close(&cursor);
> -	return mntp;
> -}
> -
>  int
>  main(int argc, char **argv)
>  {
>  	struct stat sb;
>  	char *argname;
>  	int c;
> -	char *mntp;
> +	struct fs_path	*fsp;
>  	char *mtab = NULL;
>  
>  	setlinebuf(stdout);
> @@ -322,7 +263,7 @@ main(int argc, char **argv)
>  	RealUid = getuid();
>  
>  	pagesize = getpagesize();
> -
> +	fs_table_initialise(0, NULL, 0, NULL);
>  	if (optind < argc) {
>  		for (; optind < argc; optind++) {
>  			argname = argv[optind];
> @@ -343,9 +284,11 @@ main(int argc, char **argv)
>  				sb = sb2;
>  			}
>  
> -			mntp = find_mountpoint(mtab, argname, &sb);
> -			if (mntp != NULL) {
> -				fsrfs(mntp, 0, 100);
> +			fsp = fs_table_lookup_mount(argname);
> +			if (!fsp)
> +				fsp = fs_table_lookup_blkdev(argname);
> +			if (fsp != NULL) {
> +				fsrfs(fsp->fs_dir, 0, 100);
>  			} else if (S_ISCHR(sb.st_mode)) {
>  				fprintf(stderr, _(
>  					"%s: char special not supported: %s\n"),
> diff --git a/include/path.h b/include/path.h
> index 1d3a902..88dc44b 100644
> --- a/include/path.h
> +++ b/include/path.h
> @@ -57,6 +57,7 @@ extern void fs_table_insert_project_path(char *__dir, uint __projid);
>  
>  extern fs_path_t *fs_table_lookup(const char *__dir, uint __flags);
>  extern fs_path_t *fs_table_lookup_mount(const char *__dir);
> +extern fs_path_t *fs_table_lookup_blkdev(const char *bdev);
>  
>  typedef struct fs_cursor {
>  	uint		count;		/* total count of mount entries	*/
> diff --git a/libfrog/paths.c b/libfrog/paths.c
> index 19ee1ea..318b48f 100644
> --- a/libfrog/paths.c
> +++ b/libfrog/paths.c
> @@ -89,30 +89,26 @@ fs_table_lookup(
>  	return NULL;
>  }
>  
> -/*
> - * Find the FS table entry describing an actual mount for the given path.
> - * Unlike fs_table_lookup(), fs_table_lookup_mount() compares the "dir"
> - * argument to actual mount point entries in the table. Accordingly, it
> - * will find matches only if the "dir" argument is indeed mounted.
> - */
> -struct fs_path *
> -fs_table_lookup_mount(
> -	const char	*dir)
> +static struct fs_path *
> +__fs_table_lookup_mount(
> +	const char	*dir,
> +	const char	*blkdev)
>  {
>  	uint		i;
> -	dev_t		dev = 0;
>  	char		rpath[PATH_MAX];
>  	char		dpath[PATH_MAX];
>  
> -	if (fs_device_number(dir, &dev))
> +	if (dir && !realpath(dir, dpath))
>  		return NULL;
> -	if (!realpath(dir, dpath))
> +	if (blkdev && !realpath(blkdev, dpath))
>  		return NULL;
>  
>  	for (i = 0; i < fs_count; i++) {
>  		if (fs_table[i].fs_flags != FS_MOUNT_POINT)
>  			continue;
> -		if (!realpath(fs_table[i].fs_dir, rpath))
> +		if (dir && !realpath(fs_table[i].fs_dir, rpath))
> +			continue;
> +		if (blkdev && !realpath(fs_table[i].fs_name, rpath))
>  			continue;
>  		if (strcmp(rpath, dpath) == 0)
>  			return &fs_table[i];
> @@ -120,6 +116,32 @@ fs_table_lookup_mount(
>  	return NULL;
>  }
>  
> +/*
> + * Find the FS table entry describing an actual mount for the given path.
> + * Unlike fs_table_lookup(), fs_table_lookup_mount() compares the "dir"
> + * argument to actual mount point entries in the table. Accordingly, it
> + * will find matches only if the "dir" argument is indeed mounted.
> + */
> +struct fs_path *
> +fs_table_lookup_mount(
> +	const char	*dir)
> +{
> +	return __fs_table_lookup_mount(dir, NULL);
> +}
> +
> +/*
> + * Find the FS table entry describing an actual mount for the block device.
> + * Unlike fs_table_lookup(), fs_table_lookup_blkdev() compares the "bdev"
> + * argument to actual mount point names in the table. Accordingly, it
> + * will find matches only if the "bdev" argument is indeed mounted.
> + */
> +struct fs_path *
> +fs_table_lookup_blkdev(
> +	const char	*bdev)
> +{
> +	return __fs_table_lookup_mount(NULL, bdev);
> +}
> +
>  static int
>  fs_table_insert(
>  	char		*dir,
> 


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

* Re: [PATCH 5/4] misc: remove darwin, irix, and freebsd support
  2018-03-21  3:19 ` [PATCH 5/4] misc: remove darwin, irix, and freebsd support Darrick J. Wong
@ 2018-03-21 18:59   ` Eric Sandeen
  2018-03-21 19:01     ` Eric Sandeen
  2018-03-21 21:26     ` Dave Chinner
  2018-03-21 19:42   ` [PATCH 5.5/4] " Eric Sandeen
  1 sibling, 2 replies; 27+ messages in thread
From: Eric Sandeen @ 2018-03-21 18:59 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: linux-xfs

On 3/20/18 10:19 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Remove these ports since they're not actively maintained:
> 
> IRIX support was partially removed last year; the OS itself hasn't had a
> release since 2006.
> 
> FreeBSD dropped XFS support in v9.3, which EOLd in January 2017.
> 
> Darwin/OSX has never supported XFS.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Probably should clean up more than just whole files, see bits & pieces
sprinkled throughout:

include/builddefs.in 
include/platform_defs.h.in
include/gnukfreebsd.h (?)
include/xfs.h 
libhandle/Makefile
quota/Makefile
io/Makefile
*/Makefile
m4/package_libcdev.m4 (AC_HAVE_GETMNTINFO)

...maybe even a wholesale removal of all references to PKG_PLATFORM at this point?

I suppose we can start with this and clean up more as we go.

> ---
>  include/darwin.h  |  315 -----------------------------------------------------
>  include/freebsd.h |  210 -----------------------------------
>  libxfs/Makefile   |    2 
>  libxfs/darwin.c   |  144 ------------------------
>  libxfs/freebsd.c  |  201 ----------------------------------
>  libxfs/irix.c     |  111 -------------------

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

* Re: [PATCH 5/4] misc: remove darwin, irix, and freebsd support
  2018-03-21 18:59   ` Eric Sandeen
@ 2018-03-21 19:01     ` Eric Sandeen
  2018-03-21 21:26     ` Dave Chinner
  1 sibling, 0 replies; 27+ messages in thread
From: Eric Sandeen @ 2018-03-21 19:01 UTC (permalink / raw)
  To: Eric Sandeen, Darrick J. Wong; +Cc: linux-xfs



On 3/21/18 1:59 PM, Eric Sandeen wrote:
> On 3/20/18 10:19 PM, Darrick J. Wong wrote:
>> From: Darrick J. Wong <darrick.wong@oracle.com>
>>
>> Remove these ports since they're not actively maintained:
>>
>> IRIX support was partially removed last year; the OS itself hasn't had a
>> release since 2006.
>>
>> FreeBSD dropped XFS support in v9.3, which EOLd in January 2017.
>>
>> Darwin/OSX has never supported XFS.
>>
>> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Probably should clean up more than just whole files, see bits & pieces
> sprinkled throughout:
> 
> include/builddefs.in 
> include/platform_defs.h.in
> include/gnukfreebsd.h (?)
> include/xfs.h 
> libhandle/Makefile
> quota/Makefile
> io/Makefile
> */Makefile
> m4/package_libcdev.m4 (AC_HAVE_GETMNTINFO)
> 
> ...maybe even a wholesale removal of all references to PKG_PLATFORM at this point?
> 
> I suppose we can start with this and clean up more as we go.

./quota/darwin.c
./quota/freebsd.c
./quota/irix.c


...

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

* [PATCH 5.5/4] misc: remove darwin, irix, and freebsd support
  2018-03-21  3:19 ` [PATCH 5/4] misc: remove darwin, irix, and freebsd support Darrick J. Wong
  2018-03-21 18:59   ` Eric Sandeen
@ 2018-03-21 19:42   ` Eric Sandeen
  2018-03-21 20:13     ` Darrick J. Wong
  1 sibling, 1 reply; 27+ messages in thread
From: Eric Sandeen @ 2018-03-21 19:42 UTC (permalink / raw)
  To: Darrick J. Wong, sandeen; +Cc: linux-xfs

Remove even more unsupported platform bits.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/Makefile b/Makefile
index 7ddfa31..4ff2cac 100644
--- a/Makefile
+++ b/Makefile
@@ -47,13 +47,9 @@ HDR_SUBDIRS = include libxfs
 LIBFROG_SUBDIR = libfrog
 DLIB_SUBDIRS = libxlog libxcmd libhandle
 LIB_SUBDIRS = libxfs $(DLIB_SUBDIRS)
-TOOL_SUBDIRS = copy db estimate fsck growfs io logprint mkfs quota \
+TOOL_SUBDIRS = copy db estimate fsck fsr growfs io logprint mkfs quota \
 		mdrestore repair rtcp m4 man doc debian spaceman scrub
 
-ifneq ("$(PKG_PLATFORM)","darwin")
-TOOL_SUBDIRS += fsr
-endif
-
 ifneq ("$(XGETTEXT)","")
 TOOL_SUBDIRS += po
 endif
diff --git a/include/Makefile b/include/Makefile
index 6077507..09fe42c 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -47,14 +47,12 @@ LIBHFILES = libxfs.h \
 
 HFILES = handle.h \
 	jdm.h \
-	$(PKG_PLATFORM).h \
+	linux.h \
 	xfs.h \
 	xqm.h \
 	xfs_arch.h
 
-PHFILES = darwin.h freebsd.h linux.h gnukfreebsd.h
-LSRCFILES = $(shell echo $(PHFILES) | sed -e "s/$(PKG_PLATFORM).h//g")
-LSRCFILES += platform_defs.h.in builddefs.in buildmacros buildrules install-sh
+LSRCFILES = platform_defs.h.in builddefs.in buildmacros buildrules install-sh
 LSRCFILES += $(DKHFILES) $(LIBHFILES)
 LDIRT = disk
 LDIRDIRT = xfs
diff --git a/include/builddefs.in b/include/builddefs.in
index df76b2c..7f1f58c 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -48,7 +48,6 @@ PKG_USER	= @pkg_user@
 PKG_GROUP	= @pkg_group@
 PKG_RELEASE	= @pkg_release@
 PKG_VERSION	= @pkg_version@
-PKG_PLATFORM	= @pkg_platform@
 PKG_DISTRIBUTION= @pkg_distribution@
 
 prefix		= @prefix@
@@ -135,25 +134,12 @@ CROND_DIR = @crond_dir@
 GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
 
-ifeq ($(PKG_PLATFORM),linux)
 PCFLAGS = -D_GNU_SOURCE $(GCCFLAGS)
 ifeq ($(HAVE_UMODE_T),yes)
 PCFLAGS += -DHAVE_UMODE_T
 endif
 DEPENDFLAGS = -D__linux__
-endif
-ifeq ($(PKG_PLATFORM),gnukfreebsd)
-PCFLAGS = -D_GNU_SOURCE $(GCCFLAGS)
-endif
-ifeq ($(PKG_PLATFORM),darwin)
-PCFLAGS = $(GCCFLAGS)
-DEPENDFLAGS = -D__APPLE__ -D_DARWIN_FEATURE_64_BIT_INODE
-endif
-ifeq ($(PKG_PLATFORM),freebsd)
-PLDLIBS = -L/usr/local/lib -lintl
-PCFLAGS = -I/usr/local/include $(GCCFLAGS)
-DEPENDFLAGS = -D__FreeBSD__
-endif
+
 ifeq ($(HAVE_FLS),yes)
 LCFLAGS+= -DHAVE_FLS
 endif
diff --git a/include/gnukfreebsd.h b/include/gnukfreebsd.h
deleted file mode 100644
index 1db3f4f..0000000
--- a/include/gnukfreebsd.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-#ifndef __XFS_KFREEBSD_H__
-#define __XFS_KFREEBSD_H__
-
-#include <uuid/uuid.h>
-#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>
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <ctype.h>
-#include <libgen.h>
-#include <paths.h>
-#include <mntent.h>
-
-#define EFSCORRUPTED	990	/* Filesystem is corrupted */
-#define EFSBADCRC	991	/* Bad CRC detected */
-
-typedef unsigned char		__u8;
-typedef signed char		__s8;
-typedef unsigned short		__u16;
-typedef signed short		__s16;
-typedef unsigned int		__u32;
-typedef signed int		__s32;
-typedef unsigned long long int	__u64;
-typedef signed long long int	__s64;
-
-typedef off_t		xfs_off_t;
-typedef uint64_t	xfs_ino_t;
-typedef uint32_t	xfs_dev_t;
-typedef int64_t		xfs_daddr_t;
-typedef __u32		xfs_nlink_t;
-
-#define HAVE_FID	1
-
-static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p)
-{
-	return ioctl(fd, cmd, p);
-}
-
-static __inline__ int platform_test_xfs_fd(int fd)
-{
-	struct statfs buf;
-	if (fstatfs(fd, &buf) < 0)
-		return 0;
-	return strncmp(buf.f_fstypename, "xfs", 4) == 0;
-}
-
-static __inline__ int platform_test_xfs_path(const char *path)
-{
-	struct statfs buf;
-	if (statfs(path, &buf) < 0)
-		return 0;
-	return strncmp(buf.f_fstypename, "xfs", 4) == 0;
-}
-
-static __inline__ int platform_fstatfs(int fd, struct statfs *buf)
-{
-	return fstatfs(fd, buf);
-}
-
-static __inline__ void platform_getoptreset(void)
-{
-	extern int optind;
-	optind = 0;
-}
-
-static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2)
-{
-	return uuid_compare(*uu1, *uu2);
-}
-
-static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer)
-{
-	uuid_unparse(*uu, buffer);
-}
-
-static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu)
-{
-	return uuid_parse(buffer, *uu);
-}
-
-static __inline__ int platform_uuid_is_null(uuid_t *uu)
-{
-	return uuid_is_null(*uu);
-}
-
-static __inline__ void platform_uuid_generate(uuid_t *uu)
-{
-	uuid_generate(*uu);
-}
-
-static __inline__ void platform_uuid_clear(uuid_t *uu)
-{
-	uuid_clear(*uu);
-}
-
-static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src)
-{
-	uuid_copy(*dst, *src);
-}
-
-static __inline__ int
-platform_discard_blocks(int fd, uint64_t start, uint64_t len)
-{
-	return 0;
-}
-
-/**
- * Abstraction of mountpoints.
- */
-struct mntent_cursor {
-	FILE *mtabp;
-};
-
-static inline int platform_mntent_open(struct mntent_cursor * cursor, char *mtab)
-{
-	cursor->mtabp = setmntent(mtab, "r");
-	if (!cursor->mtabp) {
-		fprintf(stderr, "Error: cannot read %s\n", mtab);
-		return 1;
-	}
-	return 0;
-}
-
-static inline struct mntent * platform_mntent_next(struct mntent_cursor * cursor)
-{
-	return getmntent(cursor->mtabp);
-}
-
-static inline void platform_mntent_close(struct mntent_cursor * cursor)
-{
-	endmntent(cursor->mtabp);
-}
-
-#endif	/* __XFS_KFREEBSD_H__ */
diff --git a/include/xfs.h b/include/xfs.h
index a40ca0c..1cbe3ad 100644
--- a/include/xfs.h
+++ b/include/xfs.h
@@ -35,12 +35,6 @@
 
 #if defined(__linux__)
 #include <xfs/linux.h>
-#elif defined(__FreeBSD__)
-#include <xfs/freebsd.h>
-#elif defined(__FreeBSD_kernel__)
-#include <xfs/gnukfreebsd.h>
-#elif defined(__APPLE__)
-#include <xfs/darwin.h>
 #else
 # error unknown platform... have fun porting!
 #endif
diff --git a/io/Makefile b/io/Makefile
index 8055d4b..a251b28 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -9,10 +9,10 @@ LTCOMMAND = xfs_io
 LSRCFILES = xfs_bmap.sh xfs_freeze.sh xfs_mkfile.sh
 HFILES = init.h io.h
 CFILES = init.c \
-	attr.c bmap.c cowextsize.c encrypt.c file.c freeze.c fsync.c \
-	getrusage.c imap.c link.c mmap.c open.c parent.c pread.c prealloc.c \
-	pwrite.c reflink.c scrub.c seek.c shutdown.c stat.c sync.c truncate.c \
-	utimes.c
+	attr.c bmap.c cowextsize.c encrypt.c file.c freeze.c fsmap.c fsync.c \
+	getrusage.c imap.c inject.c link.c mmap.c open.c parent.c pread.c \
+	prealloc.c pwrite.c reflink.c resblks.c scrub.c seek.c shutdown.c \
+	stat.c sync.c truncate.c utimes.c
 
 LLDLIBS = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG) $(LIBPTHREAD)
 LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG)
@@ -53,13 +53,6 @@ else
 LSRCFILES += fiemap.c
 endif
 
-ifeq ($(PKG_PLATFORM),irix)
-LSRCFILES += inject.c resblks.c
-else
-CFILES += inject.c resblks.c
-LCFLAGS += -DHAVE_INJECT -DHAVE_RESBLKS
-endif
-
 ifeq ($(HAVE_COPY_FILE_RANGE),yes)
 CFILES += copy_file_range.c
 LCFLAGS += -DHAVE_COPY_FILE_RANGE
@@ -114,13 +107,6 @@ LLDLIBS += $(LIBDEVMAPPER)
 LCFLAGS += -DHAVE_DEVMAPPER
 endif
 
-# On linux we get fsmap from the system or define it ourselves
-# so include this based on platform type.  If this reverts to only
-# the autoconf check w/o local definition, change to testing HAVE_GETFSMAP
-ifeq ($(PKG_PLATFORM),linux)
-CFILES += fsmap.c
-endif
-
 ifeq ($(HAVE_STATFS_FLAGS),yes)
 LCFLAGS += -DHAVE_STATFS_FLAGS
 endif
diff --git a/io/io.h b/io/io.h
index 5cf7c30..4516554 100644
--- a/io/io.h
+++ b/io/io.h
@@ -116,6 +116,7 @@ extern void		pread_init(void);
 extern void		prealloc_init(void);
 extern void		pwrite_init(void);
 extern void		quit_init(void);
+extern void		resblks_init(void);
 extern void		seek_init(void);
 extern void		shutdown_init(void);
 extern void		stat_init(void);
@@ -129,12 +130,6 @@ extern void		fadvise_init(void);
 #define fadvise_init()	do { } while (0)
 #endif
 
-#ifdef HAVE_RESBLKS
-extern void		resblks_init(void);
-#else
-#define resblks_init()	do { } while (0)
-#endif
-
 #ifdef HAVE_SENDFILE
 extern void		sendfile_init(void);
 #else
diff --git a/libhandle/Makefile b/libhandle/Makefile
index fe1a2af..cc4ad1d 100644
--- a/libhandle/Makefile
+++ b/libhandle/Makefile
@@ -10,11 +10,7 @@ LT_CURRENT = 1
 LT_REVISION = 3
 LT_AGE = 0
 
-ifeq ($(PKG_PLATFORM),darwin)
-LTLDFLAGS += -Wl,libhandle.sym
-else
 LTLDFLAGS += -Wl,--version-script,libhandle.sym
-endif
 
 CFILES = handle.c jdm.c
 LSRCFILES = libhandle.sym
diff --git a/libxfs/Makefile b/libxfs/Makefile
index 00df418..48f66d4 100644
--- a/libxfs/Makefile
+++ b/libxfs/Makefile
@@ -58,6 +58,7 @@ CFILES = cache.c \
 	defer_item.c \
 	init.c \
 	kmem.c \
+	linux.c \
 	logitem.c \
 	rdwr.c \
 	trans.c \
@@ -97,9 +98,6 @@ CFILES = cache.c \
 	xfs_symlink_remote.c \
 	xfs_trans_resv.c
 
-CFILES += $(PKG_PLATFORM).c
-PCFILES = linux.c
-LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")
 LSRCFILES += gen_crc32table.c
 
 #
diff --git a/m4/package_globals.m4 b/m4/package_globals.m4
index e469671..892e3bd 100644
--- a/m4/package_globals.m4
+++ b/m4/package_globals.m4
@@ -40,8 +40,4 @@ AC_DEFUN([AC_PACKAGE_GLOBALS],
     pkg_distribution=`uname -s`
     test -z "$DISTRIBUTION" || pkg_distribution="$DISTRIBUTION"
     AC_SUBST(pkg_distribution)
-
-    pkg_platform=`uname -s | tr 'A-Z' 'a-z' | tr -d / | sed -e 's/irix64/irix/'`
-    test -z "$PLATFORM" || pkg_platform="$PLATFORM"
-    AC_SUBST(pkg_platform)
   ])
diff --git a/quota/Makefile b/quota/Makefile
index 120af2e..62cc8a0 100644
--- a/quota/Makefile
+++ b/quota/Makefile
@@ -8,11 +8,7 @@ include $(TOPDIR)/include/builddefs
 LTCOMMAND = xfs_quota
 HFILES = init.h quota.h
 CFILES = init.c util.c \
-	edit.c free.c path.c project.c quot.c quota.c report.c state.c
-
-CFILES += $(PKG_PLATFORM).c
-PCFILES = darwin.c freebsd.c irix.c linux.c
-LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")
+	edit.c free.c linux.c path.c project.c quot.c quota.c report.c state.c
 
 LLDLIBS = $(LIBXCMD) $(LIBFROG)
 LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG)
diff --git a/quota/darwin.c b/quota/darwin.c
deleted file mode 100644
index fb81f7f..0000000
--- a/quota/darwin.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "quota.h"
-#include <sys/quota.h>
-
-int
-xfsquotactl(
-	int		command,
-	const char	*device,
-	uint		type,
-	uint		id,
-	void		*addr)
-{
-	/* return quotactl(device, QCMD(command, type), id, addr); */
-	errno = -ENOSYS;
-	return -1;
-}
diff --git a/quota/freebsd.c b/quota/freebsd.c
deleted file mode 100644
index 7770b3c..0000000
--- a/quota/freebsd.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "quota.h"
-
-int
-xfsquotactl(
-	int		command,
-	const char	*device,
-	uint		type,
-	uint		id,
-	void		*addr)
-{
-	errno = -ENOSYS;
-	return -1;
-}
diff --git a/quota/irix.c b/quota/irix.c
deleted file mode 100644
index bbbcd18..0000000
--- a/quota/irix.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "quota.h"
-#include <sys/quota.h>
-
-static int
-xcommand_to_qcommand(
-	uint		command,
-	uint		type)
-{
-	switch (command) {
-	case XFS_QUOTAON:
-		return Q_XQUOTAON;
-	case XFS_QUOTAOFF:
-		return Q_XQUOTAOFF;
-	case XFS_GETQUOTA:
-		if (type == XFS_GROUP_QUOTA)
-			return Q_XGETGQUOTA;
-		if (type == XFS_PROJ_QUOTA)
-			return Q_XGETPQUOTA;
-		return Q_XGETQUOTA;
-	case XFS_SETQLIM:
-		if (type == XFS_GROUP_QUOTA)
-			return Q_XSETGQLIM;
-		if (type == XFS_PROJ_QUOTA)
-			return Q_XSETPQLIM;
-		return Q_XSETQLIM;
-	case XFS_GETQSTAT:
-		return Q_XGETQSTAT;
-	case XFS_QUOTARM:
-		return Q_XQUOTARM;
-	case XFS_QSYNC:
-		return Q_SYNC;
-	}
-	return 0;
-}
-
-int
-xfsquotactl(
-	int		command,
-	const char	*device,
-	uint		type,
-	uint		id,
-	void		*addr)
-{
-	int		qcommand;
-
-	qcommand = xcommand_to_qcommand(command, type);
-	return quotactl(qcommand, (char *)device, id, addr);
-}
diff --git a/scrub/Makefile b/scrub/Makefile
index 0632794..94c6313 100644
--- a/scrub/Makefile
+++ b/scrub/Makefile
@@ -8,9 +8,9 @@ include $(TOPDIR)/include/builddefs
 # On linux we get fsmap from the system or define it ourselves
 # so include this based on platform type.  If this reverts to only
 # the autoconf check w/o local definition, change to testing HAVE_GETFSMAP
-SCRUB_PREREQS=$(PKG_PLATFORM)$(HAVE_OPENAT)$(HAVE_FSTATAT)
+SCRUB_PREREQS=$(HAVE_OPENAT)$(HAVE_FSTATAT)
 
-ifeq ($(SCRUB_PREREQS),linuxyesyes)
+ifeq ($(SCRUB_PREREQS),yesyes)
 LTCOMMAND = xfs_scrub
 INSTALL_SCRUB = install-scrub
 XFS_SCRUB_ALL_PROG = xfs_scrub_all
diff --git a/spaceman/Makefile b/spaceman/Makefile
index 8b31030..a137efc 100644
--- a/spaceman/Makefile
+++ b/spaceman/Makefile
@@ -7,7 +7,7 @@ include $(TOPDIR)/include/builddefs
 
 LTCOMMAND = xfs_spaceman
 HFILES = init.h space.h
-CFILES = init.c file.c prealloc.c trim.c
+CFILES = freesp.c init.c file.c prealloc.c trim.c
 
 LLDLIBS = $(LIBXCMD) $(LIBFROG)
 LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG)
@@ -21,13 +21,6 @@ ifeq ($(ENABLE_EDITLINE),yes)
 LLDLIBS += $(LIBEDITLINE) $(LIBTERMCAP)
 endif
 
-# On linux we get fsmap from the system or define it ourselves
-# so include this based on platform type.  If this reverts to only
-# the autoconf check w/o local definition, change to testing HAVE_GETFSMAP
-ifeq ($(PKG_PLATFORM),linux)
-CFILES += freesp.c
-endif
-
 default: depend $(LTCOMMAND)
 
 include $(BUILDRULES)


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

* Re: [PATCH 6/4] libfrog: absorb platform specific code
  2018-03-21  3:20 ` [PATCH 6/4] libfrog: absorb platform specific code Darrick J. Wong
@ 2018-03-21 19:52   ` Eric Sandeen
  0 siblings, 0 replies; 27+ messages in thread
From: Eric Sandeen @ 2018-03-21 19:52 UTC (permalink / raw)
  To: Darrick J. Wong, sandeen; +Cc: linux-xfs

On 3/20/18 10:20 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Move the linux support code to libfrog, which should remove the final
> dependency of libfrog on libxfs.  libfrog is the runtime support library
> anyway.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

sorry, my patch 5.5/4 probably kinda blew this up.

We can fold it in, or whatever ...

> ---
>  libfrog/Makefile |    4 +
>  libfrog/linux.c  |  265 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  libxfs/Makefile  |    3 -
>  libxfs/linux.c   |  265 ------------------------------------------------------
>  4 files changed, 269 insertions(+), 268 deletions(-)
>  create mode 100644 libfrog/linux.c
>  delete mode 100644 libxfs/linux.c
> 
> diff --git a/libfrog/Makefile b/libfrog/Makefile
> index 230b08f..e3065e6 100644
> --- a/libfrog/Makefile
> +++ b/libfrog/Makefile
> @@ -22,6 +22,10 @@ topology.c \
>  util.c \
>  workqueue.c
>  
> +CFILES += $(PKG_PLATFORM).c
> +PCFILES = linux.c
> +LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")

Ok so this doesn't really do anything at this point :)
(LSRCFILES will always be empty)

Just add linux.c to the main CFILES list and delete this

The rest makes sense, I think, unless quota/linux.c should get the same
treatment.  Probably not.

-Eric

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

* Re: [PATCH 5.5/4] misc: remove darwin, irix, and freebsd support
  2018-03-21 19:42   ` [PATCH 5.5/4] " Eric Sandeen
@ 2018-03-21 20:13     ` Darrick J. Wong
  0 siblings, 0 replies; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-21 20:13 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: sandeen, linux-xfs

On Wed, Mar 21, 2018 at 02:42:28PM -0500, Eric Sandeen wrote:
> Remove even more unsupported platform bits.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Looks fine to me, though we should wait a few days to see if anyone
complains...

Looking at osx again, there /was/ a readonly fuse driver.  It claims to
support OSX 10.7 (EOLd 3.5 years ago) and bundles its own copy of
xfsprogs 3.1.4 (imported 6 years ago)... so I think it's probably ok to
cut it loose.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
> 
> diff --git a/Makefile b/Makefile
> index 7ddfa31..4ff2cac 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -47,13 +47,9 @@ HDR_SUBDIRS = include libxfs
>  LIBFROG_SUBDIR = libfrog
>  DLIB_SUBDIRS = libxlog libxcmd libhandle
>  LIB_SUBDIRS = libxfs $(DLIB_SUBDIRS)
> -TOOL_SUBDIRS = copy db estimate fsck growfs io logprint mkfs quota \
> +TOOL_SUBDIRS = copy db estimate fsck fsr growfs io logprint mkfs quota \
>  		mdrestore repair rtcp m4 man doc debian spaceman scrub
>  
> -ifneq ("$(PKG_PLATFORM)","darwin")
> -TOOL_SUBDIRS += fsr
> -endif
> -
>  ifneq ("$(XGETTEXT)","")
>  TOOL_SUBDIRS += po
>  endif
> diff --git a/include/Makefile b/include/Makefile
> index 6077507..09fe42c 100644
> --- a/include/Makefile
> +++ b/include/Makefile
> @@ -47,14 +47,12 @@ LIBHFILES = libxfs.h \
>  
>  HFILES = handle.h \
>  	jdm.h \
> -	$(PKG_PLATFORM).h \
> +	linux.h \
>  	xfs.h \
>  	xqm.h \
>  	xfs_arch.h
>  
> -PHFILES = darwin.h freebsd.h linux.h gnukfreebsd.h
> -LSRCFILES = $(shell echo $(PHFILES) | sed -e "s/$(PKG_PLATFORM).h//g")
> -LSRCFILES += platform_defs.h.in builddefs.in buildmacros buildrules install-sh
> +LSRCFILES = platform_defs.h.in builddefs.in buildmacros buildrules install-sh
>  LSRCFILES += $(DKHFILES) $(LIBHFILES)
>  LDIRT = disk
>  LDIRDIRT = xfs
> diff --git a/include/builddefs.in b/include/builddefs.in
> index df76b2c..7f1f58c 100644
> --- a/include/builddefs.in
> +++ b/include/builddefs.in
> @@ -48,7 +48,6 @@ PKG_USER	= @pkg_user@
>  PKG_GROUP	= @pkg_group@
>  PKG_RELEASE	= @pkg_release@
>  PKG_VERSION	= @pkg_version@
> -PKG_PLATFORM	= @pkg_platform@
>  PKG_DISTRIBUTION= @pkg_distribution@
>  
>  prefix		= @prefix@
> @@ -135,25 +134,12 @@ CROND_DIR = @crond_dir@
>  GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
>  #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
>  
> -ifeq ($(PKG_PLATFORM),linux)
>  PCFLAGS = -D_GNU_SOURCE $(GCCFLAGS)
>  ifeq ($(HAVE_UMODE_T),yes)
>  PCFLAGS += -DHAVE_UMODE_T
>  endif
>  DEPENDFLAGS = -D__linux__
> -endif
> -ifeq ($(PKG_PLATFORM),gnukfreebsd)
> -PCFLAGS = -D_GNU_SOURCE $(GCCFLAGS)
> -endif
> -ifeq ($(PKG_PLATFORM),darwin)
> -PCFLAGS = $(GCCFLAGS)
> -DEPENDFLAGS = -D__APPLE__ -D_DARWIN_FEATURE_64_BIT_INODE
> -endif
> -ifeq ($(PKG_PLATFORM),freebsd)
> -PLDLIBS = -L/usr/local/lib -lintl
> -PCFLAGS = -I/usr/local/include $(GCCFLAGS)
> -DEPENDFLAGS = -D__FreeBSD__
> -endif
> +
>  ifeq ($(HAVE_FLS),yes)
>  LCFLAGS+= -DHAVE_FLS
>  endif
> diff --git a/include/gnukfreebsd.h b/include/gnukfreebsd.h
> deleted file mode 100644
> index 1db3f4f..0000000
> --- a/include/gnukfreebsd.h
> +++ /dev/null
> @@ -1,156 +0,0 @@
> -/*
> - * Copyright (c) 2004-2006 Silicon Graphics, Inc.
> - * All Rights Reserved.
> - *
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU Lesser General Public License
> - * as published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it would be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public License
> - * along with this program; if not, write the Free Software Foundation,
> - * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> - */
> -#ifndef __XFS_KFREEBSD_H__
> -#define __XFS_KFREEBSD_H__
> -
> -#include <uuid/uuid.h>
> -#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>
> -#include <sys/param.h>
> -#include <sys/mount.h>
> -#include <ctype.h>
> -#include <libgen.h>
> -#include <paths.h>
> -#include <mntent.h>
> -
> -#define EFSCORRUPTED	990	/* Filesystem is corrupted */
> -#define EFSBADCRC	991	/* Bad CRC detected */
> -
> -typedef unsigned char		__u8;
> -typedef signed char		__s8;
> -typedef unsigned short		__u16;
> -typedef signed short		__s16;
> -typedef unsigned int		__u32;
> -typedef signed int		__s32;
> -typedef unsigned long long int	__u64;
> -typedef signed long long int	__s64;
> -
> -typedef off_t		xfs_off_t;
> -typedef uint64_t	xfs_ino_t;
> -typedef uint32_t	xfs_dev_t;
> -typedef int64_t		xfs_daddr_t;
> -typedef __u32		xfs_nlink_t;
> -
> -#define HAVE_FID	1
> -
> -static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p)
> -{
> -	return ioctl(fd, cmd, p);
> -}
> -
> -static __inline__ int platform_test_xfs_fd(int fd)
> -{
> -	struct statfs buf;
> -	if (fstatfs(fd, &buf) < 0)
> -		return 0;
> -	return strncmp(buf.f_fstypename, "xfs", 4) == 0;
> -}
> -
> -static __inline__ int platform_test_xfs_path(const char *path)
> -{
> -	struct statfs buf;
> -	if (statfs(path, &buf) < 0)
> -		return 0;
> -	return strncmp(buf.f_fstypename, "xfs", 4) == 0;
> -}
> -
> -static __inline__ int platform_fstatfs(int fd, struct statfs *buf)
> -{
> -	return fstatfs(fd, buf);
> -}
> -
> -static __inline__ void platform_getoptreset(void)
> -{
> -	extern int optind;
> -	optind = 0;
> -}
> -
> -static __inline__ int platform_uuid_compare(uuid_t *uu1, uuid_t *uu2)
> -{
> -	return uuid_compare(*uu1, *uu2);
> -}
> -
> -static __inline__ void platform_uuid_unparse(uuid_t *uu, char *buffer)
> -{
> -	uuid_unparse(*uu, buffer);
> -}
> -
> -static __inline__ int platform_uuid_parse(char *buffer, uuid_t *uu)
> -{
> -	return uuid_parse(buffer, *uu);
> -}
> -
> -static __inline__ int platform_uuid_is_null(uuid_t *uu)
> -{
> -	return uuid_is_null(*uu);
> -}
> -
> -static __inline__ void platform_uuid_generate(uuid_t *uu)
> -{
> -	uuid_generate(*uu);
> -}
> -
> -static __inline__ void platform_uuid_clear(uuid_t *uu)
> -{
> -	uuid_clear(*uu);
> -}
> -
> -static __inline__ void platform_uuid_copy(uuid_t *dst, uuid_t *src)
> -{
> -	uuid_copy(*dst, *src);
> -}
> -
> -static __inline__ int
> -platform_discard_blocks(int fd, uint64_t start, uint64_t len)
> -{
> -	return 0;
> -}
> -
> -/**
> - * Abstraction of mountpoints.
> - */
> -struct mntent_cursor {
> -	FILE *mtabp;
> -};
> -
> -static inline int platform_mntent_open(struct mntent_cursor * cursor, char *mtab)
> -{
> -	cursor->mtabp = setmntent(mtab, "r");
> -	if (!cursor->mtabp) {
> -		fprintf(stderr, "Error: cannot read %s\n", mtab);
> -		return 1;
> -	}
> -	return 0;
> -}
> -
> -static inline struct mntent * platform_mntent_next(struct mntent_cursor * cursor)
> -{
> -	return getmntent(cursor->mtabp);
> -}
> -
> -static inline void platform_mntent_close(struct mntent_cursor * cursor)
> -{
> -	endmntent(cursor->mtabp);
> -}
> -
> -#endif	/* __XFS_KFREEBSD_H__ */
> diff --git a/include/xfs.h b/include/xfs.h
> index a40ca0c..1cbe3ad 100644
> --- a/include/xfs.h
> +++ b/include/xfs.h
> @@ -35,12 +35,6 @@
>  
>  #if defined(__linux__)
>  #include <xfs/linux.h>
> -#elif defined(__FreeBSD__)
> -#include <xfs/freebsd.h>
> -#elif defined(__FreeBSD_kernel__)
> -#include <xfs/gnukfreebsd.h>
> -#elif defined(__APPLE__)
> -#include <xfs/darwin.h>
>  #else
>  # error unknown platform... have fun porting!
>  #endif
> diff --git a/io/Makefile b/io/Makefile
> index 8055d4b..a251b28 100644
> --- a/io/Makefile
> +++ b/io/Makefile
> @@ -9,10 +9,10 @@ LTCOMMAND = xfs_io
>  LSRCFILES = xfs_bmap.sh xfs_freeze.sh xfs_mkfile.sh
>  HFILES = init.h io.h
>  CFILES = init.c \
> -	attr.c bmap.c cowextsize.c encrypt.c file.c freeze.c fsync.c \
> -	getrusage.c imap.c link.c mmap.c open.c parent.c pread.c prealloc.c \
> -	pwrite.c reflink.c scrub.c seek.c shutdown.c stat.c sync.c truncate.c \
> -	utimes.c
> +	attr.c bmap.c cowextsize.c encrypt.c file.c freeze.c fsmap.c fsync.c \
> +	getrusage.c imap.c inject.c link.c mmap.c open.c parent.c pread.c \
> +	prealloc.c pwrite.c reflink.c resblks.c scrub.c seek.c shutdown.c \
> +	stat.c sync.c truncate.c utimes.c
>  
>  LLDLIBS = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG) $(LIBPTHREAD)
>  LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE) $(LIBFROG)
> @@ -53,13 +53,6 @@ else
>  LSRCFILES += fiemap.c
>  endif
>  
> -ifeq ($(PKG_PLATFORM),irix)
> -LSRCFILES += inject.c resblks.c
> -else
> -CFILES += inject.c resblks.c
> -LCFLAGS += -DHAVE_INJECT -DHAVE_RESBLKS
> -endif
> -
>  ifeq ($(HAVE_COPY_FILE_RANGE),yes)
>  CFILES += copy_file_range.c
>  LCFLAGS += -DHAVE_COPY_FILE_RANGE
> @@ -114,13 +107,6 @@ LLDLIBS += $(LIBDEVMAPPER)
>  LCFLAGS += -DHAVE_DEVMAPPER
>  endif
>  
> -# On linux we get fsmap from the system or define it ourselves
> -# so include this based on platform type.  If this reverts to only
> -# the autoconf check w/o local definition, change to testing HAVE_GETFSMAP
> -ifeq ($(PKG_PLATFORM),linux)
> -CFILES += fsmap.c
> -endif
> -
>  ifeq ($(HAVE_STATFS_FLAGS),yes)
>  LCFLAGS += -DHAVE_STATFS_FLAGS
>  endif
> diff --git a/io/io.h b/io/io.h
> index 5cf7c30..4516554 100644
> --- a/io/io.h
> +++ b/io/io.h
> @@ -116,6 +116,7 @@ extern void		pread_init(void);
>  extern void		prealloc_init(void);
>  extern void		pwrite_init(void);
>  extern void		quit_init(void);
> +extern void		resblks_init(void);
>  extern void		seek_init(void);
>  extern void		shutdown_init(void);
>  extern void		stat_init(void);
> @@ -129,12 +130,6 @@ extern void		fadvise_init(void);
>  #define fadvise_init()	do { } while (0)
>  #endif
>  
> -#ifdef HAVE_RESBLKS
> -extern void		resblks_init(void);
> -#else
> -#define resblks_init()	do { } while (0)
> -#endif
> -
>  #ifdef HAVE_SENDFILE
>  extern void		sendfile_init(void);
>  #else
> diff --git a/libhandle/Makefile b/libhandle/Makefile
> index fe1a2af..cc4ad1d 100644
> --- a/libhandle/Makefile
> +++ b/libhandle/Makefile
> @@ -10,11 +10,7 @@ LT_CURRENT = 1
>  LT_REVISION = 3
>  LT_AGE = 0
>  
> -ifeq ($(PKG_PLATFORM),darwin)
> -LTLDFLAGS += -Wl,libhandle.sym
> -else
>  LTLDFLAGS += -Wl,--version-script,libhandle.sym
> -endif
>  
>  CFILES = handle.c jdm.c
>  LSRCFILES = libhandle.sym
> diff --git a/libxfs/Makefile b/libxfs/Makefile
> index 00df418..48f66d4 100644
> --- a/libxfs/Makefile
> +++ b/libxfs/Makefile
> @@ -58,6 +58,7 @@ CFILES = cache.c \
>  	defer_item.c \
>  	init.c \
>  	kmem.c \
> +	linux.c \
>  	logitem.c \
>  	rdwr.c \
>  	trans.c \
> @@ -97,9 +98,6 @@ CFILES = cache.c \
>  	xfs_symlink_remote.c \
>  	xfs_trans_resv.c
>  
> -CFILES += $(PKG_PLATFORM).c
> -PCFILES = linux.c
> -LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")
>  LSRCFILES += gen_crc32table.c
>  
>  #
> diff --git a/m4/package_globals.m4 b/m4/package_globals.m4
> index e469671..892e3bd 100644
> --- a/m4/package_globals.m4
> +++ b/m4/package_globals.m4
> @@ -40,8 +40,4 @@ AC_DEFUN([AC_PACKAGE_GLOBALS],
>      pkg_distribution=`uname -s`
>      test -z "$DISTRIBUTION" || pkg_distribution="$DISTRIBUTION"
>      AC_SUBST(pkg_distribution)
> -
> -    pkg_platform=`uname -s | tr 'A-Z' 'a-z' | tr -d / | sed -e 's/irix64/irix/'`
> -    test -z "$PLATFORM" || pkg_platform="$PLATFORM"
> -    AC_SUBST(pkg_platform)
>    ])
> diff --git a/quota/Makefile b/quota/Makefile
> index 120af2e..62cc8a0 100644
> --- a/quota/Makefile
> +++ b/quota/Makefile
> @@ -8,11 +8,7 @@ include $(TOPDIR)/include/builddefs
>  LTCOMMAND = xfs_quota
>  HFILES = init.h quota.h
>  CFILES = init.c util.c \
> -	edit.c free.c path.c project.c quot.c quota.c report.c state.c
> -
> -CFILES += $(PKG_PLATFORM).c
> -PCFILES = darwin.c freebsd.c irix.c linux.c
> -LSRCFILES = $(shell echo $(PCFILES) | sed -e "s/$(PKG_PLATFORM).c//g")
> +	edit.c free.c linux.c path.c project.c quot.c quota.c report.c state.c
>  
>  LLDLIBS = $(LIBXCMD) $(LIBFROG)
>  LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG)
> diff --git a/quota/darwin.c b/quota/darwin.c
> deleted file mode 100644
> index fb81f7f..0000000
> --- a/quota/darwin.c
> +++ /dev/null
> @@ -1,33 +0,0 @@
> -/*
> - * Copyright (c) 2005 Silicon Graphics, Inc.
> - * All Rights Reserved.
> - *
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU General Public License as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it would be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write the Free Software Foundation,
> - * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> - */
> -
> -#include "quota.h"
> -#include <sys/quota.h>
> -
> -int
> -xfsquotactl(
> -	int		command,
> -	const char	*device,
> -	uint		type,
> -	uint		id,
> -	void		*addr)
> -{
> -	/* return quotactl(device, QCMD(command, type), id, addr); */
> -	errno = -ENOSYS;
> -	return -1;
> -}
> diff --git a/quota/freebsd.c b/quota/freebsd.c
> deleted file mode 100644
> index 7770b3c..0000000
> --- a/quota/freebsd.c
> +++ /dev/null
> @@ -1,31 +0,0 @@
> -/*
> - * Copyright (c) 2005 Silicon Graphics, Inc.
> - * All Rights Reserved.
> - *
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU General Public License as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it would be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write the Free Software Foundation,
> - * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> - */
> -
> -#include "quota.h"
> -
> -int
> -xfsquotactl(
> -	int		command,
> -	const char	*device,
> -	uint		type,
> -	uint		id,
> -	void		*addr)
> -{
> -	errno = -ENOSYS;
> -	return -1;
> -}
> diff --git a/quota/irix.c b/quota/irix.c
> deleted file mode 100644
> index bbbcd18..0000000
> --- a/quota/irix.c
> +++ /dev/null
> @@ -1,66 +0,0 @@
> -/*
> - * Copyright (c) 2005 Silicon Graphics, Inc.
> - * All Rights Reserved.
> - *
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU General Public License as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it would be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write the Free Software Foundation,
> - * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> - */
> -
> -#include "quota.h"
> -#include <sys/quota.h>
> -
> -static int
> -xcommand_to_qcommand(
> -	uint		command,
> -	uint		type)
> -{
> -	switch (command) {
> -	case XFS_QUOTAON:
> -		return Q_XQUOTAON;
> -	case XFS_QUOTAOFF:
> -		return Q_XQUOTAOFF;
> -	case XFS_GETQUOTA:
> -		if (type == XFS_GROUP_QUOTA)
> -			return Q_XGETGQUOTA;
> -		if (type == XFS_PROJ_QUOTA)
> -			return Q_XGETPQUOTA;
> -		return Q_XGETQUOTA;
> -	case XFS_SETQLIM:
> -		if (type == XFS_GROUP_QUOTA)
> -			return Q_XSETGQLIM;
> -		if (type == XFS_PROJ_QUOTA)
> -			return Q_XSETPQLIM;
> -		return Q_XSETQLIM;
> -	case XFS_GETQSTAT:
> -		return Q_XGETQSTAT;
> -	case XFS_QUOTARM:
> -		return Q_XQUOTARM;
> -	case XFS_QSYNC:
> -		return Q_SYNC;
> -	}
> -	return 0;
> -}
> -
> -int
> -xfsquotactl(
> -	int		command,
> -	const char	*device,
> -	uint		type,
> -	uint		id,
> -	void		*addr)
> -{
> -	int		qcommand;
> -
> -	qcommand = xcommand_to_qcommand(command, type);
> -	return quotactl(qcommand, (char *)device, id, addr);
> -}
> diff --git a/scrub/Makefile b/scrub/Makefile
> index 0632794..94c6313 100644
> --- a/scrub/Makefile
> +++ b/scrub/Makefile
> @@ -8,9 +8,9 @@ include $(TOPDIR)/include/builddefs
>  # On linux we get fsmap from the system or define it ourselves
>  # so include this based on platform type.  If this reverts to only
>  # the autoconf check w/o local definition, change to testing HAVE_GETFSMAP
> -SCRUB_PREREQS=$(PKG_PLATFORM)$(HAVE_OPENAT)$(HAVE_FSTATAT)
> +SCRUB_PREREQS=$(HAVE_OPENAT)$(HAVE_FSTATAT)
>  
> -ifeq ($(SCRUB_PREREQS),linuxyesyes)
> +ifeq ($(SCRUB_PREREQS),yesyes)
>  LTCOMMAND = xfs_scrub
>  INSTALL_SCRUB = install-scrub
>  XFS_SCRUB_ALL_PROG = xfs_scrub_all
> diff --git a/spaceman/Makefile b/spaceman/Makefile
> index 8b31030..a137efc 100644
> --- a/spaceman/Makefile
> +++ b/spaceman/Makefile
> @@ -7,7 +7,7 @@ include $(TOPDIR)/include/builddefs
>  
>  LTCOMMAND = xfs_spaceman
>  HFILES = init.h space.h
> -CFILES = init.c file.c prealloc.c trim.c
> +CFILES = freesp.c init.c file.c prealloc.c trim.c
>  
>  LLDLIBS = $(LIBXCMD) $(LIBFROG)
>  LTDEPENDENCIES = $(LIBXCMD) $(LIBFROG)
> @@ -21,13 +21,6 @@ ifeq ($(ENABLE_EDITLINE),yes)
>  LLDLIBS += $(LIBEDITLINE) $(LIBTERMCAP)
>  endif
>  
> -# On linux we get fsmap from the system or define it ourselves
> -# so include this based on platform type.  If this reverts to only
> -# the autoconf check w/o local definition, change to testing HAVE_GETFSMAP
> -ifeq ($(PKG_PLATFORM),linux)
> -CFILES += freesp.c
> -endif
> -
>  default: depend $(LTCOMMAND)
>  
>  include $(BUILDRULES)
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 5/4] misc: remove darwin, irix, and freebsd support
  2018-03-21 18:59   ` Eric Sandeen
  2018-03-21 19:01     ` Eric Sandeen
@ 2018-03-21 21:26     ` Dave Chinner
  2018-03-21 21:31       ` Darrick J. Wong
  1 sibling, 1 reply; 27+ messages in thread
From: Dave Chinner @ 2018-03-21 21:26 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Darrick J. Wong, linux-xfs

On Wed, Mar 21, 2018 at 01:59:26PM -0500, Eric Sandeen wrote:
> On 3/20/18 10:19 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Remove these ports since they're not actively maintained:
> > 
> > IRIX support was partially removed last year; the OS itself hasn't had a
> > release since 2006.
> > 
> > FreeBSD dropped XFS support in v9.3, which EOLd in January 2017.
> > 
> > Darwin/OSX has never supported XFS.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Probably should clean up more than just whole files, see bits & pieces
> sprinkled throughout:
> 
> include/builddefs.in 
> include/platform_defs.h.in
> include/gnukfreebsd.h (?)

So, this makes me wonder. IIRC, that's the header for the debian
distro on a freebsd kernel. That's a thing, and we package xfsprogs
in debian. Do they build xfsprogs for that platform, and if they do
do we care if we break it?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 5/4] misc: remove darwin, irix, and freebsd support
  2018-03-21 21:26     ` Dave Chinner
@ 2018-03-21 21:31       ` Darrick J. Wong
  2018-03-21 23:10         ` Dave Chinner
  0 siblings, 1 reply; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-21 21:31 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Eric Sandeen, linux-xfs

On Thu, Mar 22, 2018 at 08:26:17AM +1100, Dave Chinner wrote:
> On Wed, Mar 21, 2018 at 01:59:26PM -0500, Eric Sandeen wrote:
> > On 3/20/18 10:19 PM, Darrick J. Wong wrote:
> > > From: Darrick J. Wong <darrick.wong@oracle.com>
> > > 
> > > Remove these ports since they're not actively maintained:
> > > 
> > > IRIX support was partially removed last year; the OS itself hasn't had a
> > > release since 2006.
> > > 
> > > FreeBSD dropped XFS support in v9.3, which EOLd in January 2017.
> > > 
> > > Darwin/OSX has never supported XFS.
> > > 
> > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Probably should clean up more than just whole files, see bits & pieces
> > sprinkled throughout:
> > 
> > include/builddefs.in 
> > include/platform_defs.h.in
> > include/gnukfreebsd.h (?)
> 
> So, this makes me wonder. IIRC, that's the header for the debian
> distro on a freebsd kernel. That's a thing, and we package xfsprogs
> in debian. Do they build xfsprogs for that platform, and if they do
> do we care if we break it?

>From the looks of it[1] they (Debian) don't package xfsprogs for
kfreebsd (not even the wheezy release that supposedly had an xfs driver
in the kernle) so I doubt anyone would care.

--D

[1] https://packages.debian.org/search?keywords=xfsprogs

> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com

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

* Re: [PATCH 5/4] misc: remove darwin, irix, and freebsd support
  2018-03-21 21:31       ` Darrick J. Wong
@ 2018-03-21 23:10         ` Dave Chinner
  0 siblings, 0 replies; 27+ messages in thread
From: Dave Chinner @ 2018-03-21 23:10 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Eric Sandeen, linux-xfs

On Wed, Mar 21, 2018 at 02:31:38PM -0700, Darrick J. Wong wrote:
> On Thu, Mar 22, 2018 at 08:26:17AM +1100, Dave Chinner wrote:
> > On Wed, Mar 21, 2018 at 01:59:26PM -0500, Eric Sandeen wrote:
> > > On 3/20/18 10:19 PM, Darrick J. Wong wrote:
> > > > From: Darrick J. Wong <darrick.wong@oracle.com>
> > > > 
> > > > Remove these ports since they're not actively maintained:
> > > > 
> > > > IRIX support was partially removed last year; the OS itself hasn't had a
> > > > release since 2006.
> > > > 
> > > > FreeBSD dropped XFS support in v9.3, which EOLd in January 2017.
> > > > 
> > > > Darwin/OSX has never supported XFS.
> > > > 
> > > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > > 
> > > Probably should clean up more than just whole files, see bits & pieces
> > > sprinkled throughout:
> > > 
> > > include/builddefs.in 
> > > include/platform_defs.h.in
> > > include/gnukfreebsd.h (?)
> > 
> > So, this makes me wonder. IIRC, that's the header for the debian
> > distro on a freebsd kernel. That's a thing, and we package xfsprogs
> > in debian. Do they build xfsprogs for that platform, and if they do
> > do we care if we break it?
> 
> From the looks of it[1] they (Debian) don't package xfsprogs for
> kfreebsd (not even the wheezy release that supposedly had an xfs driver
> in the kernle) so I doubt anyone would care.

No worries, just making sure we cover all bases, because it seems
not every knows what "gnu/freebsd" is :P

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* [PATCH 1.5/4] xfs_repair: use custom ifork verifier in mv_orphanage
  2018-03-20  3:08 ` [PATCH 1/4] xfs_repair: implement custom ifork verifiers Darrick J. Wong
  2018-03-20 19:54   ` Eric Sandeen
  2018-03-20 21:47   ` [PATCH v2 " Darrick J. Wong
@ 2018-03-22 19:35   ` Eric Sandeen
  2018-03-22 19:49     ` Darrick J. Wong
  2 siblings, 1 reply; 27+ messages in thread
From: Eric Sandeen @ 2018-03-22 19:35 UTC (permalink / raw)
  To: Darrick J. Wong, sandeen; +Cc: linux-xfs

Now that we have a custom verifier which can ignore parent
inode numbers, use it in mv_orphanage() as well; orphan inodes
may have invalid parents, and we're about to reconnect
them anyway, so override that test when we get them off disk.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/repair/phase6.c b/repair/phase6.c
index ed005e8..498a3b5 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -1138,7 +1138,8 @@ mv_orphanage(
 		xname.len = snprintf((char *)fname, sizeof(fname), "%llu.%d",
 					(unsigned long long)ino, ++incr);
 
-	err = -libxfs_iget(mp, NULL, ino, 0, &ino_p, &xfs_default_ifork_ops);
+	/* Orphans may not have a proper parent, so use custom ops here */
+	err = -libxfs_iget(mp, NULL, ino, 0, &ino_p, &phase6_ifork_ops);
 	if (err)
 		do_error(_("%d - couldn't iget disconnected inode\n"), err);
 


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

* Re: [PATCH 1.5/4] xfs_repair: use custom ifork verifier in mv_orphanage
  2018-03-22 19:35   ` [PATCH 1.5/4] xfs_repair: use custom ifork verifier in mv_orphanage Eric Sandeen
@ 2018-03-22 19:49     ` Darrick J. Wong
  0 siblings, 0 replies; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-22 19:49 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: sandeen, linux-xfs

On Thu, Mar 22, 2018 at 02:35:34PM -0500, Eric Sandeen wrote:
> Now that we have a custom verifier which can ignore parent
> inode numbers, use it in mv_orphanage() as well; orphan inodes
> may have invalid parents, and we're about to reconnect
> them anyway, so override that test when we get them off disk.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
> 
> diff --git a/repair/phase6.c b/repair/phase6.c
> index ed005e8..498a3b5 100644
> --- a/repair/phase6.c
> +++ b/repair/phase6.c
> @@ -1138,7 +1138,8 @@ mv_orphanage(
>  		xname.len = snprintf((char *)fname, sizeof(fname), "%llu.%d",
>  					(unsigned long long)ino, ++incr);
>  
> -	err = -libxfs_iget(mp, NULL, ino, 0, &ino_p, &xfs_default_ifork_ops);
> +	/* Orphans may not have a proper parent, so use custom ops here */
> +	err = -libxfs_iget(mp, NULL, ino, 0, &ino_p, &phase6_ifork_ops);
>  	if (err)
>  		do_error(_("%d - couldn't iget disconnected inode\n"), err);
>  
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 7/4] xfs_spaceman: remove incorrect linux/fs.h include
  2018-03-20  3:08 [PATCH 0/4] xfsprogs: more misc fixes Darrick J. Wong
                   ` (5 preceding siblings ...)
  2018-03-21  3:20 ` [PATCH 6/4] libfrog: absorb platform specific code Darrick J. Wong
@ 2018-03-26 19:56 ` Darrick J. Wong
  6 siblings, 0 replies; 27+ messages in thread
From: Darrick J. Wong @ 2018-03-26 19:56 UTC (permalink / raw)
  To: sandeen; +Cc: linux-xfs

From: Darrick J. Wong <darrick.wong@oracle.com>

Remove the direct linux/fs.h include from spaceman because all xfs
utilities should include xfs.h so that we can wrap missing kernel header
declarations properly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 spaceman/trim.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/spaceman/trim.c b/spaceman/trim.c
index 6df9e6a..c1efb52 100644
--- a/spaceman/trim.c
+++ b/spaceman/trim.c
@@ -17,7 +17,6 @@
  */
 
 #include "libxfs.h"
-#include <linux/fs.h>
 #include "command.h"
 #include "init.h"
 #include "path.h"

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

end of thread, other threads:[~2018-03-26 19:56 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-20  3:08 [PATCH 0/4] xfsprogs: more misc fixes Darrick J. Wong
2018-03-20  3:08 ` [PATCH 1/4] xfs_repair: implement custom ifork verifiers Darrick J. Wong
2018-03-20 19:54   ` Eric Sandeen
2018-03-20 21:19     ` Darrick J. Wong
2018-03-20 21:47   ` [PATCH v2 " Darrick J. Wong
2018-03-21 18:37     ` Eric Sandeen
2018-03-22 19:35   ` [PATCH 1.5/4] xfs_repair: use custom ifork verifier in mv_orphanage Eric Sandeen
2018-03-22 19:49     ` Darrick J. Wong
2018-03-20  3:08 ` [PATCH 2/4] libfrog: fs_table_lookup_mount should realpath the argument Darrick J. Wong
2018-03-20 19:55   ` Eric Sandeen
2018-03-20  3:08 ` [PATCH 3/4] xfs_fsr: refactor mountpoint finding to use libfrog paths functions Darrick J. Wong
2018-03-20 23:14   ` Darrick J. Wong
2018-03-21  3:19   ` [PATCH v2 " Darrick J. Wong
2018-03-21 18:49     ` Eric Sandeen
2018-03-20  3:08 ` [PATCH 4/4] mkfs: enable sparse inodes by default Darrick J. Wong
2018-03-20 21:16   ` Eric Sandeen
2018-03-21  3:19 ` [PATCH 5/4] misc: remove darwin, irix, and freebsd support Darrick J. Wong
2018-03-21 18:59   ` Eric Sandeen
2018-03-21 19:01     ` Eric Sandeen
2018-03-21 21:26     ` Dave Chinner
2018-03-21 21:31       ` Darrick J. Wong
2018-03-21 23:10         ` Dave Chinner
2018-03-21 19:42   ` [PATCH 5.5/4] " Eric Sandeen
2018-03-21 20:13     ` Darrick J. Wong
2018-03-21  3:20 ` [PATCH 6/4] libfrog: absorb platform specific code Darrick J. Wong
2018-03-21 19:52   ` Eric Sandeen
2018-03-26 19:56 ` [PATCH 7/4] xfs_spaceman: remove incorrect linux/fs.h include Darrick J. Wong

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.