Re: [PATCH 1/2 v2] convert xfs_getbmap to take formatter functions

Christoph Hellwig
2008-10-25T20:27:51Z

> +int xfs_getbmapx_format(void __user **ap, struct getbmapx *bmv, int *filled)
> +{
> + *filled = 0;
> + if (copy_to_user(*ap, bmv, sizeof(struct getbmapx)))
> + return XFS_ERROR(EFAULT);
> +
> + *ap += sizeof(struct getbmapx);
> + *filled = 1;
> + return 0;
> +}
> +
> +int xfs_getbmap_format(void __user **ap, struct getbmapx *bmv, int *filled)
> +{
> + *filled = 0;
> + /* copy only getbmap portion (not getbmapx) */
> + if (copy_to_user(*ap, bmv, sizeof(struct getbmap)))
> + return XFS_ERROR(EFAULT);
> +
> + *ap += sizeof(struct getbmap);
> + *filled = 1;
> + return 0;
> +}

Probably makes sense to have these two helpers in xfs_ioctl.c, where
they are used, similar to how fiemap is implemented.