#include <linux/namei.h>
#include <linux/pagemap.h>
-/*
- * ioctl commands that are used by Linux filesystems
- */
-#define XFS_IOC_GETXFLAGS _IOR('f', 1, long)
-#define XFS_IOC_SETXFLAGS _IOW('f', 2, long)
-#define XFS_IOC_GETVERSION _IOR('v', 1, long)
-
-
/*
* xfs_find_handle maps from userspace xfs_fsop_handlereq structure to
* a file or fs handle.
STATIC int
xfs_find_handle(
unsigned int cmd,
- unsigned long arg)
+ void __user *arg)
{
int hsize;
xfs_handle_t handle;
struct inode *inode;
struct vnode *vp;
- if (copy_from_user(&hreq, (xfs_fsop_handlereq_t *)arg, sizeof(hreq)))
+ if (copy_from_user(&hreq, arg, sizeof(hreq)))
return -XFS_ERROR(EFAULT);
memset((char *)&handle, 0, sizeof(handle));
struct nameidata nd;
int error;
- error = user_path_walk_link(hreq.path, &nd);
+ error = user_path_walk_link((const char __user *)hreq.path, &nd);
if (error)
return error;
}
/* now copy our handle into the user buffer & write out the size */
- if (copy_to_user((xfs_handle_t *)hreq.ohandle, &handle, hsize) ||
+ if (copy_to_user(hreq.ohandle, &handle, hsize) ||
copy_to_user(hreq.ohandlen, &hsize, sizeof(__s32))) {
iput(inode);
return -XFS_ERROR(EFAULT);
xfs_mount_t *mp,
struct inode *parinode, /* parent inode pointer */
int cap, /* capability level for op */
- unsigned long arg, /* userspace data pointer */
+ void __user *arg, /* userspace data pointer */
unsigned long size, /* size of expected struct */
/* output arguments */
xfs_fsop_handlereq_t *hreq,
vnode_t **vp,
struct inode **inode)
{
- void *hanp;
+ void __user *hanp;
size_t hlen;
xfs_fid_t *xfid;
xfs_handle_t *handlep;
* Copy the handle down from the user and validate
* that it looks to be in the correct format.
*/
- if (copy_from_user(hreq, (struct xfs_fsop_handlereq *)arg, size))
+ if (copy_from_user(hreq, arg, size))
return XFS_ERROR(EFAULT);
hanp = hreq->ihandle;
STATIC int
xfs_open_by_handle(
xfs_mount_t *mp,
- unsigned long arg,
+ void __user *arg,
struct file *parfilp,
struct inode *parinode)
{
STATIC int
xfs_readlink_by_handle(
xfs_mount_t *mp,
- unsigned long arg,
+ void __user *arg,
struct file *parfilp,
struct inode *parinode)
{
STATIC int
xfs_fssetdm_by_handle(
xfs_mount_t *mp,
- unsigned long arg,
+ void __user *arg,
struct file *parfilp,
struct inode *parinode)
{
STATIC int
xfs_attrlist_by_handle(
xfs_mount_t *mp,
- unsigned long arg,
+ void __user *arg,
struct file *parfilp,
struct inode *parinode)
{
STATIC int
xfs_attrmulti_by_handle(
xfs_mount_t *mp,
- unsigned long arg,
+ void __user *arg,
struct file *parfilp,
struct inode *parinode)
{
struct file *filp,
int flags,
unsigned int cmd,
- unsigned long arg);
+ void __user *arg);
STATIC int
xfs_ioc_bulkstat(
xfs_mount_t *mp,
unsigned int cmd,
- unsigned long arg);
+ void __user *arg);
STATIC int
xfs_ioc_fsgeometry_v1(
xfs_mount_t *mp,
- unsigned long arg);
+ void __user *arg);
STATIC int
xfs_ioc_fsgeometry(
xfs_mount_t *mp,
- unsigned long arg);
+ void __user *arg);
STATIC int
xfs_ioc_xattr(
xfs_inode_t *ip,
struct file *filp,
unsigned int cmd,
- unsigned long arg);
+ void __user *arg);
STATIC int
xfs_ioc_getbmap(
struct file *filp,
int flags,
unsigned int cmd,
- unsigned long arg);
+ void __user *arg);
STATIC int
xfs_ioc_getbmapx(
bhv_desc_t *bdp,
- unsigned long arg);
+ void __user *arg);
int
xfs_ioctl(
struct file *filp,
int ioflags,
unsigned int cmd,
- unsigned long arg)
+ void __user *arg)
{
int error;
vnode_t *vp;
/* The size dio will do in one go */
da.d_maxiosz = 64 * PAGE_CACHE_SIZE;
- if (copy_to_user((struct dioattr *)arg, &da, sizeof(da)))
+ if (copy_to_user(arg, &da, sizeof(da)))
return -XFS_ERROR(EFAULT);
return 0;
}
case XFS_IOC_FSSETDM: {
struct fsdmidata dmi;
- if (copy_from_user(&dmi, (struct fsdmidata *)arg, sizeof(dmi)))
+ if (copy_from_user(&dmi, arg, sizeof(dmi)))
return -XFS_ERROR(EFAULT);
error = xfs_set_dmattrs(bdp, dmi.fsd_dmevmask, dmi.fsd_dmstate,
return xfs_attrmulti_by_handle(mp, arg, filp, inode);
case XFS_IOC_SWAPEXT: {
- error = xfs_swapext((struct xfs_swapext *)arg);
+ error = xfs_swapext((struct xfs_swapext __user *)arg);
return -error;
}
if (error)
return -error;
- if (copy_to_user((char *)arg, &out, sizeof(out)))
+ if (copy_to_user(arg, &out, sizeof(out)))
return -XFS_ERROR(EFAULT);
return 0;
}
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- if (copy_from_user(&inout, (char *)arg, sizeof(inout)))
+ if (copy_from_user(&inout, arg, sizeof(inout)))
return -XFS_ERROR(EFAULT);
/* input parameter is passed in resblks field of structure */
if (error)
return -error;
- if (copy_to_user((char *)arg, &inout, sizeof(inout)))
+ if (copy_to_user(arg, &inout, sizeof(inout)))
return -XFS_ERROR(EFAULT);
return 0;
}
if (error)
return -error;
- if (copy_to_user((char *)arg, &out, sizeof(out)))
+ if (copy_to_user(arg, &out, sizeof(out)))
return -XFS_ERROR(EFAULT);
return 0;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- if (copy_from_user(&in, (char *)arg, sizeof(in)))
+ if (copy_from_user(&in, arg, sizeof(in)))
return -XFS_ERROR(EFAULT);
error = xfs_growfs_data(mp, &in);
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- if (copy_from_user(&in, (char *)arg, sizeof(in)))
+ if (copy_from_user(&in, arg, sizeof(in)))
return -XFS_ERROR(EFAULT);
error = xfs_growfs_log(mp, &in);
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- if (copy_from_user(&in, (char *)arg, sizeof(in)))
+ if (copy_from_user(&in, arg, sizeof(in)))
return -XFS_ERROR(EFAULT);
error = xfs_growfs_rt(mp, &in);
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- freeze_bdev(inode->i_sb->s_bdev);
+ if (inode->i_sb->s_frozen == SB_UNFROZEN)
+ freeze_bdev(inode->i_sb->s_bdev);
return 0;
case XFS_IOC_THAW:
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- thaw_bdev(inode->i_sb->s_bdev, inode->i_sb);
+ if (inode->i_sb->s_frozen != SB_UNFROZEN)
+ thaw_bdev(inode->i_sb->s_bdev, inode->i_sb);
return 0;
case XFS_IOC_GOINGDOWN: {
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- if (get_user(in, (__uint32_t *)arg))
+ if (get_user(in, (__uint32_t __user *)arg))
return -XFS_ERROR(EFAULT);
error = xfs_fs_goingdown(mp, in);
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- if (copy_from_user(&in, (char *)arg, sizeof(in)))
+ if (copy_from_user(&in, arg, sizeof(in)))
return -XFS_ERROR(EFAULT);
error = xfs_errortag_add(in.errtag, mp);
struct file *filp,
int ioflags,
unsigned int cmd,
- unsigned long arg)
+ void __user *arg)
{
xfs_flock64_t bf;
int attr_flags = 0;
if (vp->v_type != VREG)
return -XFS_ERROR(EINVAL);
- if (copy_from_user(&bf, (xfs_flock64_t *)arg, sizeof(bf)))
+ if (copy_from_user(&bf, arg, sizeof(bf)))
return -XFS_ERROR(EFAULT);
if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
xfs_ioc_bulkstat(
xfs_mount_t *mp,
unsigned int cmd,
- unsigned long arg)
+ void __user *arg)
{
xfs_fsop_bulkreq_t bulkreq;
int count; /* # of records returned */
if (XFS_FORCED_SHUTDOWN(mp))
return -XFS_ERROR(EIO);
- if (copy_from_user(&bulkreq, (xfs_fsop_bulkreq_t *)arg,
- sizeof(xfs_fsop_bulkreq_t)))
+ if (copy_from_user(&bulkreq, arg, sizeof(xfs_fsop_bulkreq_t)))
return -XFS_ERROR(EFAULT);
- if (copy_from_user(&inlast, (__s64 *)bulkreq.lastip,
- sizeof(__s64)))
+ if (copy_from_user(&inlast, bulkreq.lastip, sizeof(__s64)))
return -XFS_ERROR(EFAULT);
if ((count = bulkreq.icount) <= 0)
return -error;
if (bulkreq.ocount != NULL) {
- if (copy_to_user((xfs_ino_t *)bulkreq.lastip, &inlast,
+ if (copy_to_user(bulkreq.lastip, &inlast,
sizeof(xfs_ino_t)))
return -XFS_ERROR(EFAULT);
- if (copy_to_user((__s32 *)bulkreq.ocount, &count,
- sizeof(count)))
+ if (copy_to_user(bulkreq.ocount, &count, sizeof(count)))
return -XFS_ERROR(EFAULT);
}
STATIC int
xfs_ioc_fsgeometry_v1(
xfs_mount_t *mp,
- unsigned long arg)
+ void __user *arg)
{
xfs_fsop_geom_v1_t fsgeo;
int error;
if (error)
return -error;
- if (copy_to_user((xfs_fsop_geom_t *)arg, &fsgeo, sizeof(fsgeo)))
+ if (copy_to_user(arg, &fsgeo, sizeof(fsgeo)))
return -XFS_ERROR(EFAULT);
return 0;
}
STATIC int
xfs_ioc_fsgeometry(
xfs_mount_t *mp,
- unsigned long arg)
+ void __user *arg)
{
xfs_fsop_geom_t fsgeo;
int error;
if (error)
return -error;
- if (copy_to_user((xfs_fsop_geom_t *)arg, &fsgeo, sizeof(fsgeo)))
+ if (copy_to_user(arg, &fsgeo, sizeof(fsgeo)))
return -XFS_ERROR(EFAULT);
return 0;
}
xfs_inode_t *ip,
struct file *filp,
unsigned int cmd,
- unsigned long arg)
+ void __user *arg)
{
struct fsxattr fa;
vattr_t va;
fa.fsx_extsize = va.va_extsize;
fa.fsx_nextents = va.va_nextents;
- if (copy_to_user((struct fsxattr *)arg, &fa, sizeof(fa)))
+ if (copy_to_user(arg, &fa, sizeof(fa)))
return -XFS_ERROR(EFAULT);
return 0;
}
case XFS_IOC_FSSETXATTR: {
- if (copy_from_user(&fa, (struct fsxattr *)arg, sizeof(fa)))
+ if (copy_from_user(&fa, arg, sizeof(fa)))
return -XFS_ERROR(EFAULT);
attr_flags = 0;
fa.fsx_extsize = va.va_extsize;
fa.fsx_nextents = va.va_anextents;
- if (copy_to_user((struct fsxattr *)arg, &fa, sizeof(fa)))
+ if (copy_to_user(arg, &fa, sizeof(fa)))
return -XFS_ERROR(EFAULT);
return 0;
}
case XFS_IOC_GETXFLAGS: {
flags = xfs_di2lxflags(ip->i_d.di_flags);
- if (copy_to_user((unsigned int *)arg, &flags, sizeof(flags)))
+ if (copy_to_user(arg, &flags, sizeof(flags)))
return -XFS_ERROR(EFAULT);
return 0;
}
case XFS_IOC_SETXFLAGS: {
- if (copy_from_user(&flags, (unsigned int *)arg, sizeof(flags)))
+ if (copy_from_user(&flags, arg, sizeof(flags)))
return -XFS_ERROR(EFAULT);
if (flags & ~(LINUX_XFLAG_IMMUTABLE | LINUX_XFLAG_APPEND | \
case XFS_IOC_GETVERSION: {
flags = LINVFS_GET_IP(vp)->i_generation;
- if (copy_to_user((unsigned int *)arg, &flags, sizeof(flags)))
+ if (copy_to_user(arg, &flags, sizeof(flags)))
return -XFS_ERROR(EFAULT);
return 0;
}
struct file *filp,
int ioflags,
unsigned int cmd,
- unsigned long arg)
+ void __user *arg)
{
struct getbmap bm;
int iflags;
int error;
- if (copy_from_user(&bm, (struct getbmap *)arg, sizeof(bm)))
+ if (copy_from_user(&bm, arg, sizeof(bm)))
return -XFS_ERROR(EFAULT);
if (bm.bmv_count < 2)
if (ioflags & IO_INVIS)
iflags |= BMV_IF_NO_DMAPI_READ;
- error = xfs_getbmap(bdp, &bm, (struct getbmap *)arg+1, iflags);
+ error = xfs_getbmap(bdp, &bm, (struct getbmap __user *)arg+1, iflags);
if (error)
return -error;
- if (copy_to_user((struct getbmap *)arg, &bm, sizeof(bm)))
+ if (copy_to_user(arg, &bm, sizeof(bm)))
return -XFS_ERROR(EFAULT);
return 0;
}
STATIC int
xfs_ioc_getbmapx(
bhv_desc_t *bdp,
- unsigned long arg)
+ void __user *arg)
{
struct getbmapx bmx;
struct getbmap bm;
int iflags;
int error;
- if (copy_from_user(&bmx, (struct getbmapx *)arg, sizeof(bmx)))
+ if (copy_from_user(&bmx, arg, sizeof(bmx)))
return -XFS_ERROR(EFAULT);
if (bmx.bmv_count < 2)
iflags |= BMV_IF_EXTENDED;
- error = xfs_getbmap(bdp, &bm, (struct getbmapx *)arg+1, iflags);
+ error = xfs_getbmap(bdp, &bm, (struct getbmapx __user *)arg+1, iflags);
if (error)
return -error;
GETBMAP_CONVERT(bm, bmx);
- if (copy_to_user((struct getbmapx *)arg, &bmx, sizeof(bmx)))
+ if (copy_to_user(arg, &bmx, sizeof(bmx)))
return -XFS_ERROR(EFAULT);
return 0;