From: "Darrick J. Wong" <djwong@kernel.org>
To: Catherine Hoang <catherine.hoang@oracle.com>
Cc: linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org
Subject: Re: [PATCH v2 2/2] xfs: add FS_IOC_GETFSUUID ioctl
Date: Mon, 21 Nov 2022 10:05:59 -0800 [thread overview]
Message-ID: <Y3u+ByGRghPOnyVM@magnolia> (raw)
In-Reply-To: <20221118211408.72796-3-catherine.hoang@oracle.com>
On Fri, Nov 18, 2022 at 01:14:08PM -0800, Catherine Hoang wrote:
> Add a new ioctl to retrieve the UUID of a mounted xfs filesystem. This is a
> precursor to adding the SETFSUUID ioctl.
>
> Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
> Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
LGTM,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_ioctl.c | 36 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
>
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 1f783e979629..cf77715afe9e 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1865,6 +1865,39 @@ xfs_fs_eofblocks_from_user(
> return 0;
> }
>
> +static int
> +xfs_ioctl_getuuid(
> + struct xfs_mount *mp,
> + struct fsuuid __user *ufsuuid)
> +{
> + struct fsuuid fsuuid;
> + __u8 uuid[UUID_SIZE];
> +
> + if (copy_from_user(&fsuuid, ufsuuid, sizeof(fsuuid)))
> + return -EFAULT;
> +
> + if (fsuuid.fsu_len == 0) {
> + fsuuid.fsu_len = UUID_SIZE;
> + if (copy_to_user(&ufsuuid->fsu_len, &fsuuid.fsu_len,
> + sizeof(fsuuid.fsu_len)))
> + return -EFAULT;
> + return 0;
> + }
> +
> + if (fsuuid.fsu_len < UUID_SIZE || fsuuid.fsu_flags != 0)
> + return -EINVAL;
> +
> + spin_lock(&mp->m_sb_lock);
> + memcpy(uuid, &mp->m_sb.sb_uuid, UUID_SIZE);
> + spin_unlock(&mp->m_sb_lock);
> +
> + fsuuid.fsu_len = UUID_SIZE;
> + if (copy_to_user(ufsuuid, &fsuuid, sizeof(fsuuid)) ||
> + copy_to_user(&ufsuuid->fsu_uuid[0], uuid, UUID_SIZE))
> + return -EFAULT;
> + return 0;
> +}
> +
> /*
> * These long-unused ioctls were removed from the official ioctl API in 5.17,
> * but retain these definitions so that we can log warnings about them.
> @@ -2153,6 +2186,9 @@ xfs_file_ioctl(
> return error;
> }
>
> + case FS_IOC_GETFSUUID:
> + return xfs_ioctl_getuuid(mp, arg);
> +
> default:
> return -ENOTTY;
> }
> --
> 2.25.1
>
next prev parent reply other threads:[~2022-11-21 18:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-18 21:14 [PATCH v2 0/2] porting the GETFSUUID ioctl to xfs Catherine Hoang
2022-11-18 21:14 ` [PATCH v2 1/2] fs: hoist get/set UUID ioctls Catherine Hoang
2022-11-21 21:14 ` Dave Chinner
2022-11-18 21:14 ` [PATCH v2 2/2] xfs: add FS_IOC_GETFSUUID ioctl Catherine Hoang
2022-11-21 18:05 ` Darrick J. Wong [this message]
2022-11-21 21:02 ` Dave Chinner
2022-11-21 22:18 ` Darrick J. Wong
2022-11-21 23:20 ` Dave Chinner
2022-11-21 21:15 ` [PATCH v2 0/2] porting the GETFSUUID ioctl to xfs Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y3u+ByGRghPOnyVM@magnolia \
--to=djwong@kernel.org \
--cc=catherine.hoang@oracle.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox