From dc9b1f58bffb702ea7f17720f9412677d903964a Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 27 Nov 2017 14:23:38 -0600 Subject: [PATCH] xfs: abstract out dev_t conversions Source kernel commit: 274e0a1f4777b9362fc03a34e86358cc36003e48 And move them to xfs_linux.h so that xfsprogs can stub them out more easily. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong [sandeen: stub them out in xfsprogs] Signed-off-by: Eric Sandeen --- include/xfs_inode.h | 2 +- libxfs/libxfs_priv.h | 14 ++++++-------- libxfs/xfs_inode_fork.c | 8 ++------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/include/xfs_inode.h b/include/xfs_inode.h index 005a5b26f..11a549e36 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -36,7 +36,7 @@ struct xfs_dir_ops; struct inode { mode_t i_mode; uint32_t i_nlink; - dev_t i_rdev; + xfs_dev_t i_rdev; /* This actually holds xfs_dev_t */ uint32_t i_generation; uint64_t i_version; struct timespec i_atime; diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 709b4b81e..82ae2e9cc 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -87,14 +87,12 @@ extern char *progname; #undef ASSERT #define ASSERT(ex) assert(ex) -#define MKDEV(major, minor) IRIX_MKDEV(major, minor) -#define sysv_major(dev) IRIX_DEV_MAJOR(dev) -#define sysv_minor(dev) IRIX_DEV_MINOR(dev) - -static inline uint32_t sysv_encode_dev(dev_t dev) -{ - return IRIX_DEV_MINOR(dev) | (IRIX_DEV_MAJOR(dev) << 18); -} +/* + * We have no need for the "linux" dev_t in userspace, so these + * are no-ops, and an xfs_dev_t is stored in VFS_I(ip)->i_rdev + */ +#define xfs_to_linux_dev_t(dev) dev +#define linux_to_xfs_dev_t(dev) dev #ifndef EWRONGFS #define EWRONGFS EINVAL diff --git a/libxfs/xfs_inode_fork.c b/libxfs/xfs_inode_fork.c index 79e0398c8..3c0be58ba 100644 --- a/libxfs/xfs_inode_fork.c +++ b/libxfs/xfs_inode_fork.c @@ -39,11 +39,6 @@ STATIC int xfs_iformat_local(xfs_inode_t *, xfs_dinode_t *, int, int); STATIC int xfs_iformat_extents(xfs_inode_t *, xfs_dinode_t *, int); STATIC int xfs_iformat_btree(xfs_inode_t *, xfs_dinode_t *, int); -static inline dev_t xfs_to_linux_dev_t(xfs_dev_t dev) -{ - return MKDEV(sysv_major(dev) & 0x1ff, sysv_minor(dev)); -} - /* * Copy inode type and data and attr format specific information from the * on-disk inode to the in-core inode and fork structures. For fifos, devices, @@ -789,7 +784,8 @@ xfs_iflush_fork( case XFS_DINODE_FMT_DEV: if (iip->ili_fields & XFS_ILOG_DEV) { ASSERT(whichfork == XFS_DATA_FORK); - xfs_dinode_put_rdev(dip, sysv_encode_dev(VFS_I(ip)->i_rdev)); + xfs_dinode_put_rdev(dip, + linux_to_xfs_dev_t(VFS_I(ip)->i_rdev)); } break; -- 2.47.2