Re: [PATCH 4/4] xfs_db: add command to copy directory trees out of filesystems

Christoph Hellwig
2025-02-18T08:36:34Z

On Thu, Feb 06, 2025 at 03:03:32PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> Aheada of deprecating V4 support in the kernel, let's give people a way
> to extract their files from a filesystem without needing to mount.

So I've wanted a userspace file access for a while, but if we deprecate
the v4 support in the kernel that will propagte to libxfs quickly,
and this code won't help you with v4 file systems either. So I don't
think the rationale here seems very good.

> extern void bmapinflate_init(void);
> +extern void rdump_init(void);

No need for the extern.

> + /* XXX cannot copy fsxattrs */

Should this be fixed first? Or document in a full sentence comment
explaining why it can't should not be?

> + [1] = {
> + .tv_sec = inode_get_mtime_sec(VFS_I(ip)),
> + .tv_nsec = inode_get_mtime_nsec(VFS_I(ip)),
> + },
> + };
> + int ret;
> +
> + /* XXX cannot copy ctime or btime */

Same for this and others.

> + /* Format xattr name */
> + if (attr_flags & XFS_ATTR_ROOT)
> + nsp = XATTR_TRUSTED_PREFIX;
> + else if (attr_flags & XFS_ATTR_SECURE)
> + nsp = XATTR_SECURITY_PREFIX;
> + else
> + nsp = XATTR_USER_PREFIX;

Add a self-cotained helper for this? I'm pretty sure we do this
translation in a few places.

> + if (XFS_IS_REALTIME_INODE(ip))
> + btp = ip->i_mount->m_rtdev_targp;
> + else
> + btp = ip->i_mount->m_ddev_targp;

Should be move xfs_inode_buftarg from kernel code to common code?