]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/xfs/linux-2.6/xfs_ioctl32.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial
[linux-2.6-omap-h63xx.git] / fs / xfs / linux-2.6 / xfs_ioctl32.c
index 17993352aa647196fd7b5f0b93ecf0cda9787e52..0504cece9f6668768fb4c91b019d6f55438f6ba3 100644 (file)
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include <linux/compat.h>
-#include <linux/init.h>
 #include <linux/ioctl.h>
-#include <linux/syscalls.h>
-#include <linux/types.h>
-#include <linux/fs.h>
 #include <asm/uaccess.h>
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -131,7 +127,7 @@ xfs_inumbers_fmt_compat(
 
 #else
 #define xfs_inumbers_fmt_compat xfs_inumbers_fmt
-#endif
+#endif /* BROKEN_X86_ALIGNMENT */
 
 STATIC int
 xfs_ioctl32_bstime_copyin(
@@ -563,20 +559,66 @@ xfs_compat_attrmulti_by_handle(
        return -error;
 }
 
-STATIC long
-xfs_compat_ioctl(
-       xfs_inode_t     *ip,
-       struct file     *filp,
-       int             ioflags,
-       unsigned        cmd,
-       void            __user *arg)
+STATIC int
+xfs_compat_fssetdm_by_handle(
+       xfs_mount_t             *mp,
+       void                    __user *arg,
+       struct inode            *parinode)
+{
+       int                     error;
+       struct fsdmidata        fsd;
+       compat_xfs_fsop_setdm_handlereq_t dmhreq;
+       struct inode            *inode;
+
+       if (!capable(CAP_MKNOD))
+               return -XFS_ERROR(EPERM);
+       if (copy_from_user(&dmhreq, arg,
+                          sizeof(compat_xfs_fsop_setdm_handlereq_t)))
+               return -XFS_ERROR(EFAULT);
+
+       error = xfs_vget_fsop_handlereq_compat(mp, parinode, &dmhreq.hreq,
+                                              &inode);
+       if (error)
+               return -error;
+
+       if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
+               error = -XFS_ERROR(EPERM);
+               goto out;
+       }
+
+       if (copy_from_user(&fsd, compat_ptr(dmhreq.data), sizeof(fsd))) {
+               error = -XFS_ERROR(EFAULT);
+               goto out;
+       }
+
+       error = -xfs_set_dmattrs(XFS_I(inode), fsd.fsd_dmevmask,
+                                fsd.fsd_dmstate);
+
+out:
+       iput(inode);
+       return error;
+}
+
+long
+xfs_file_compat_ioctl(
+       struct file             *filp,
+       unsigned                cmd,
+       unsigned long           p)
 {
-       struct inode    *inode = filp->f_path.dentry->d_inode;
-       xfs_mount_t     *mp = ip->i_mount;
-       int             error;
+       struct inode            *inode = filp->f_path.dentry->d_inode;
+       struct xfs_inode        *ip = XFS_I(inode);
+       struct xfs_mount        *mp = ip->i_mount;
+       void                    __user *arg = (void __user *)p;
+       int                     ioflags = 0;
+       int                     error;
+
+       if (filp->f_mode & FMODE_NOCMTIME)
+               ioflags |= IO_INVIS;
+
+       xfs_itrace_entry(ip);
 
-       xfs_itrace_entry(XFS_I(inode));
        switch (cmd) {
+       /* No size or alignment issues on any arch */
        case XFS_IOC_DIOINFO:
        case XFS_IOC_FSGEOMETRY:
        case XFS_IOC_FSGETXATTR:
@@ -586,39 +628,31 @@ xfs_compat_ioctl(
        case XFS_IOC_GETBMAP:
        case XFS_IOC_GETBMAPA:
        case XFS_IOC_GETBMAPX:
-/*     case XFS_IOC_FSSETDM_BY_HANDLE: not handled */
        case XFS_IOC_FSCOUNTS:
        case XFS_IOC_SET_RESBLKS:
        case XFS_IOC_GET_RESBLKS:
-       case XFS_IOC_FSGROWFSDATA:
        case XFS_IOC_FSGROWFSLOG:
-       case XFS_IOC_FSGROWFSRT:
        case XFS_IOC_FREEZE:
        case XFS_IOC_THAW:
        case XFS_IOC_GOINGDOWN:
        case XFS_IOC_ERROR_INJECTION:
        case XFS_IOC_ERROR_CLEARALL:
-               break;
-
-       case XFS_IOC_GETXFLAGS_32:
-       case XFS_IOC_SETXFLAGS_32:
-       case XFS_IOC_GETVERSION_32:
-               cmd = _NATIVE_IOC(cmd, long);
-               break;
-       case XFS_IOC_SWAPEXT: {
-               struct xfs_swapext        sxp;
-               struct compat_xfs_swapext __user *sxu = arg;
-
-               /* Bulk copy in up to the sx_stat field, then grab bstat */
-               if (copy_from_user(&sxp, sxu,
-                                  offsetof(xfs_swapext_t, sx_stat)) ||
-                   xfs_ioctl32_bstat_copyin(&sxp.sx_stat, &sxu->sx_stat))
-                       return -XFS_ERROR(EFAULT);
-               error = xfs_swapext(&sxp);
-               return -error;
-       }
-#ifdef BROKEN_X86_ALIGNMENT
-       /* xfs_flock_t has wrong u32 vs u64 alignment */
+               return xfs_file_ioctl(filp, cmd, p);
+#ifndef BROKEN_X86_ALIGNMENT
+       /* These are handled fine if no alignment issues */
+       case XFS_IOC_ALLOCSP:
+       case XFS_IOC_FREESP:
+       case XFS_IOC_RESVSP:
+       case XFS_IOC_UNRESVSP:
+       case XFS_IOC_ALLOCSP64:
+       case XFS_IOC_FREESP64:
+       case XFS_IOC_RESVSP64:
+       case XFS_IOC_UNRESVSP64:
+       case XFS_IOC_FSGEOMETRY_V1:
+       case XFS_IOC_FSGROWFSDATA:
+       case XFS_IOC_FSGROWFSRT:
+               return xfs_file_ioctl(filp, cmd, p);
+#else
        case XFS_IOC_ALLOCSP_32:
        case XFS_IOC_FREESP_32:
        case XFS_IOC_ALLOCSP64_32:
@@ -652,18 +686,25 @@ xfs_compat_ioctl(
                error = xfs_growfs_rt(mp, &in);
                return -error;
        }
-#else /* These are handled fine if no alignment issues */
-       case XFS_IOC_ALLOCSP:
-       case XFS_IOC_FREESP:
-       case XFS_IOC_RESVSP:
-       case XFS_IOC_UNRESVSP:
-       case XFS_IOC_ALLOCSP64:
-       case XFS_IOC_FREESP64:
-       case XFS_IOC_RESVSP64:
-       case XFS_IOC_UNRESVSP64:
-       case XFS_IOC_FSGEOMETRY_V1:
-               break;
 #endif
+       /* long changes size, but xfs only copiese out 32 bits */
+       case XFS_IOC_GETXFLAGS_32:
+       case XFS_IOC_SETXFLAGS_32:
+       case XFS_IOC_GETVERSION_32:
+               cmd = _NATIVE_IOC(cmd, long);
+               return xfs_file_ioctl(filp, cmd, p);
+       case XFS_IOC_SWAPEXT: {
+               struct xfs_swapext        sxp;
+               struct compat_xfs_swapext __user *sxu = arg;
+
+               /* Bulk copy in up to the sx_stat field, then copy bstat */
+               if (copy_from_user(&sxp, sxu,
+                                  offsetof(struct xfs_swapext, sx_stat)) ||
+                   xfs_ioctl32_bstat_copyin(&sxp.sx_stat, &sxu->sx_stat))
+                       return -XFS_ERROR(EFAULT);
+               error = xfs_swapext(&sxp);
+               return -error;
+       }
        case XFS_IOC_FSBULKSTAT_32:
        case XFS_IOC_FSBULKSTAT_SINGLE_32:
        case XFS_IOC_FSINUMBERS_32:
@@ -696,33 +737,9 @@ xfs_compat_ioctl(
                return xfs_compat_attrlist_by_handle(mp, arg, inode);
        case XFS_IOC_ATTRMULTI_BY_HANDLE_32:
                return xfs_compat_attrmulti_by_handle(mp, arg, inode);
+       case XFS_IOC_FSSETDM_BY_HANDLE_32:
+               return xfs_compat_fssetdm_by_handle(mp, arg, inode);
        default:
                return -XFS_ERROR(ENOIOCTLCMD);
        }
-
-       error = xfs_ioctl(ip, filp, ioflags, cmd, arg);
-       return error;
-}
-
-long
-xfs_file_compat_ioctl(
-       struct file             *filp,
-       unsigned int            cmd,
-       unsigned long           p)
-{
-       struct inode    *inode = filp->f_path.dentry->d_inode;
-
-       return xfs_compat_ioctl(XFS_I(inode), filp, 0, cmd, (void __user *)p);
-}
-
-long
-xfs_file_compat_invis_ioctl(
-       struct file             *filp,
-       unsigned int            cmd,
-       unsigned long           p)
-{
-       struct inode    *inode = filp->f_path.dentry->d_inode;
-
-       return xfs_compat_ioctl(XFS_I(inode), filp, IO_INVIS, cmd,
-                               (void __user *)p);
 }