Re: [PATCH v1 2/2] xfs: add FS_IOC_GETFSUUID ioctl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2022-11-09 at 14:19 -0800, Catherine Hoang wrote:
> Add a new ioctl to retrieve the UUID of a mounted xfs filesystem.
> 
> Signed-off-by: Catherine Hoang <catherine.hoang@xxxxxxxxxx>

With Darricks commentary addressed, I think this one looks good
Reviewed-by: Allison Henderson <allison.henderson@xxxxxxxxxx>
> ---
>  fs/xfs/xfs_ioctl.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 1f783e979629..657fe058dfba 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -1865,6 +1865,35 @@ 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, &fsuuid,
> sizeof(fsuuid.fsu_len)))
> +                       return -EFAULT;
> +               return -EINVAL;
> +       }
> +
> +       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);
> +
> +       if (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 +2182,9 @@ xfs_file_ioctl(
>                 return error;
>         }
>  
> +       case FS_IOC_GETFSUUID:
> +               return xfs_ioctl_getuuid(mp, arg);
> +
>         default:
>                 return -ENOTTY;
>         }





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux