X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fxfs%2Flinux-2.6%2Fxfs_ioctl.c;h=f29c51059ce579092b65b7f504c61152db07ece5;hb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;hp=e348ef84944a90d75fdeba8d7b99a1036b140001;hpb=e812ccbe0c915857ebea6a632bfadc631f7504a9;p=linux-2.6.git diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c index e348ef849..f29c51059 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl.c +++ b/fs/xfs/linux-2.6/xfs_ioctl.c @@ -72,14 +72,6 @@ #include #include -/* - * 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. @@ -94,7 +86,7 @@ STATIC int xfs_find_handle( unsigned int cmd, - unsigned long arg) + void __user *arg) { int hsize; xfs_handle_t handle; @@ -102,7 +94,7 @@ xfs_find_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)); @@ -113,7 +105,7 @@ xfs_find_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; @@ -185,7 +177,7 @@ xfs_find_handle( } /* 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); @@ -211,14 +203,14 @@ xfs_vget_fsop_handlereq( 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; @@ -243,7 +235,7 @@ xfs_vget_fsop_handlereq( * 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; @@ -300,7 +292,7 @@ xfs_vget_fsop_handlereq( STATIC int xfs_open_by_handle( xfs_mount_t *mp, - unsigned long arg, + void __user *arg, struct file *parfilp, struct inode *parinode) { @@ -383,7 +375,7 @@ xfs_open_by_handle( STATIC int xfs_readlink_by_handle( xfs_mount_t *mp, - unsigned long arg, + void __user *arg, struct file *parfilp, struct inode *parinode) { @@ -429,7 +421,7 @@ xfs_readlink_by_handle( STATIC int xfs_fssetdm_by_handle( xfs_mount_t *mp, - unsigned long arg, + void __user *arg, struct file *parfilp, struct inode *parinode) { @@ -469,7 +461,7 @@ xfs_fssetdm_by_handle( STATIC int xfs_attrlist_by_handle( xfs_mount_t *mp, - unsigned long arg, + void __user *arg, struct file *parfilp, struct inode *parinode) { @@ -498,7 +490,7 @@ xfs_attrlist_by_handle( STATIC int xfs_attrmulti_by_handle( xfs_mount_t *mp, - unsigned long arg, + void __user *arg, struct file *parfilp, struct inode *parinode) { @@ -577,23 +569,23 @@ xfs_ioc_space( 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( @@ -601,7 +593,7 @@ xfs_ioc_xattr( xfs_inode_t *ip, struct file *filp, unsigned int cmd, - unsigned long arg); + void __user *arg); STATIC int xfs_ioc_getbmap( @@ -609,12 +601,12 @@ 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( @@ -623,7 +615,7 @@ xfs_ioctl( struct file *filp, int ioflags, unsigned int cmd, - unsigned long arg) + void __user *arg) { int error; vnode_t *vp; @@ -667,7 +659,7 @@ xfs_ioctl( /* 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; } @@ -694,7 +686,7 @@ xfs_ioctl( 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, @@ -730,7 +722,7 @@ xfs_ioctl( 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; } @@ -741,7 +733,7 @@ xfs_ioctl( 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; } @@ -753,7 +745,7 @@ xfs_ioctl( 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 */ @@ -762,7 +754,7 @@ xfs_ioctl( 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; } @@ -777,7 +769,7 @@ xfs_ioctl( 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; @@ -789,7 +781,7 @@ xfs_ioctl( 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); @@ -802,7 +794,7 @@ xfs_ioctl( 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); @@ -815,7 +807,7 @@ xfs_ioctl( 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); @@ -826,13 +818,15 @@ xfs_ioctl( 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: { @@ -841,7 +835,7 @@ xfs_ioctl( 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); @@ -854,7 +848,7 @@ xfs_ioctl( 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); @@ -880,7 +874,7 @@ xfs_ioc_space( struct file *filp, int ioflags, unsigned int cmd, - unsigned long arg) + void __user *arg) { xfs_flock64_t bf; int attr_flags = 0; @@ -895,7 +889,7 @@ xfs_ioc_space( 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)) @@ -912,7 +906,7 @@ STATIC int 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 */ @@ -929,12 +923,10 @@ xfs_ioc_bulkstat( 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) @@ -963,12 +955,11 @@ xfs_ioc_bulkstat( 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); } @@ -978,7 +969,7 @@ xfs_ioc_bulkstat( STATIC int xfs_ioc_fsgeometry_v1( xfs_mount_t *mp, - unsigned long arg) + void __user *arg) { xfs_fsop_geom_v1_t fsgeo; int error; @@ -987,7 +978,7 @@ xfs_ioc_fsgeometry_v1( 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; } @@ -995,7 +986,7 @@ xfs_ioc_fsgeometry_v1( STATIC int xfs_ioc_fsgeometry( xfs_mount_t *mp, - unsigned long arg) + void __user *arg) { xfs_fsop_geom_t fsgeo; int error; @@ -1004,7 +995,7 @@ xfs_ioc_fsgeometry( 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; } @@ -1017,6 +1008,8 @@ xfs_ioc_fsgeometry( #define LINUX_XFLAG_APPEND 0x00000020 /* writes to file may only append */ #define LINUX_XFLAG_NODUMP 0x00000040 /* do not dump file */ #define LINUX_XFLAG_NOATIME 0x00000080 /* do not update atime */ +#define LINUX_XFLAG_BARRIER 0x00004000 /* chroot() barrier */ +#define LINUX_XFLAG_IUNLINK 0x00008000 /* Immutable unlink */ STATIC unsigned int xfs_merge_ioc_xflags( @@ -1057,6 +1050,10 @@ xfs_di2lxflags( if (di_flags & XFS_DIFLAG_IMMUTABLE) flags |= LINUX_XFLAG_IMMUTABLE; + if (di_flags & XFS_DIFLAG_IUNLINK) + flags |= LINUX_XFLAG_IUNLINK; + if (di_flags & XFS_DIFLAG_BARRIER) + flags |= LINUX_XFLAG_BARRIER; if (di_flags & XFS_DIFLAG_APPEND) flags |= LINUX_XFLAG_APPEND; if (di_flags & XFS_DIFLAG_SYNC) @@ -1074,7 +1071,7 @@ xfs_ioc_xattr( xfs_inode_t *ip, struct file *filp, unsigned int cmd, - unsigned long arg) + void __user *arg) { struct fsxattr fa; vattr_t va; @@ -1093,13 +1090,13 @@ xfs_ioc_xattr( 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; @@ -1126,20 +1123,20 @@ xfs_ioc_xattr( 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 | \ @@ -1163,7 +1160,7 @@ xfs_ioc_xattr( 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; } @@ -1179,13 +1176,13 @@ xfs_ioc_getbmap( 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) @@ -1195,11 +1192,11 @@ xfs_ioc_getbmap( 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; } @@ -1207,14 +1204,14 @@ xfs_ioc_getbmap( 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) @@ -1233,13 +1230,13 @@ xfs_ioc_getbmapx( 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;