]> err.no Git - linux-2.6/blobdiff - fs/xfs/linux-2.6/xfs_ioctl.c
Merge branches 'release' and 'autoload' into release
[linux-2.6] / fs / xfs / linux-2.6 / xfs_ioctl.c
index 8ff465db909b6100de3130466b23eb4afbb8b352..98a56568bb24a942640729e47bd5d0e6a6d2234f 100644 (file)
@@ -138,7 +138,7 @@ xfs_find_handle(
        vp = vn_from_inode(inode);
 
        /* now we can grab the fsid */
-       memcpy(&handle.ha_fsid, XFS_MTOVFS(XFS_I(inode)->i_mount)->vfs_altfsid,
+       memcpy(&handle.ha_fsid, XFS_I(inode)->i_mount->m_fixedfsid,
                        sizeof(xfs_fsid_t));
        hsize = sizeof(xfs_fsid_t);
 
@@ -152,11 +152,11 @@ xfs_find_handle(
                lock_mode = xfs_ilock_map_shared(ip);
 
                /* fill in fid section of handle from inode */
-               handle.ha_fid.xfs_fid_len = sizeof(xfs_fid_t) -
-                                           sizeof(handle.ha_fid.xfs_fid_len);
-               handle.ha_fid.xfs_fid_pad = 0;
-               handle.ha_fid.xfs_fid_gen = ip->i_d.di_gen;
-               handle.ha_fid.xfs_fid_ino = ip->i_ino;
+               handle.ha_fid.fid_len = sizeof(xfs_fid_t) -
+                                       sizeof(handle.ha_fid.fid_len);
+               handle.ha_fid.fid_pad = 0;
+               handle.ha_fid.fid_gen = ip->i_d.di_gen;
+               handle.ha_fid.fid_ino = ip->i_ino;
 
                xfs_iunlock_map_shared(ip, lock_mode);
 
@@ -222,10 +222,10 @@ xfs_vget_fsop_handlereq(
        if (hlen < sizeof(*handlep))
                memset(((char *)handlep) + hlen, 0, sizeof(*handlep) - hlen);
        if (hlen > sizeof(handlep->ha_fsid)) {
-               if (handlep->ha_fid.xfs_fid_len !=
-                               (hlen - sizeof(handlep->ha_fsid)
-                                       - sizeof(handlep->ha_fid.xfs_fid_len))
-                   || handlep->ha_fid.xfs_fid_pad)
+               if (handlep->ha_fid.fid_len !=
+                   (hlen - sizeof(handlep->ha_fsid) -
+                           sizeof(handlep->ha_fid.fid_len)) ||
+                   handlep->ha_fid.fid_pad)
                        return XFS_ERROR(EINVAL);
        }
 
@@ -233,9 +233,9 @@ xfs_vget_fsop_handlereq(
         * Crack the handle, obtain the inode # & generation #
         */
        xfid = (struct xfs_fid *)&handlep->ha_fid;
-       if (xfid->xfs_fid_len == sizeof(*xfid) - sizeof(xfid->xfs_fid_len)) {
-               ino  = xfid->xfs_fid_ino;
-               igen = xfid->xfs_fid_gen;
+       if (xfid->fid_len == sizeof(*xfid) - sizeof(xfid->fid_len)) {
+               ino  = xfid->fid_ino;
+               igen = xfid->fid_gen;
        } else {
                return XFS_ERROR(EINVAL);
        }
@@ -708,6 +708,12 @@ xfs_ioc_xattr(
        unsigned int            cmd,
        void                    __user *arg);
 
+STATIC int
+xfs_ioc_fsgetxattr(
+       xfs_inode_t             *ip,
+       int                     attr,
+       void                    __user *arg);
+
 STATIC int
 xfs_ioc_getbmap(
        struct xfs_inode        *ip,
@@ -733,7 +739,7 @@ xfs_ioctl(
        xfs_mount_t             *mp = ip->i_mount;
        int                     error;
 
-       vn_trace_entry(vp, "xfs_ioctl", (inst_t *)__return_address);
+       vn_trace_entry(XFS_I(inode), "xfs_ioctl", (inst_t *)__return_address);
 
        switch (cmd) {
 
@@ -783,11 +789,13 @@ xfs_ioctl(
        case XFS_IOC_GETVERSION:
                return put_user(inode->i_generation, (int __user *)arg);
 
+       case XFS_IOC_FSGETXATTR:
+               return xfs_ioc_fsgetxattr(ip, 0, arg);
+       case XFS_IOC_FSGETXATTRA:
+               return xfs_ioc_fsgetxattr(ip, 1, arg);
        case XFS_IOC_GETXFLAGS:
        case XFS_IOC_SETXFLAGS:
-       case XFS_IOC_FSGETXATTR:
        case XFS_IOC_FSSETXATTR:
-       case XFS_IOC_FSGETXATTRA:
                return xfs_ioc_xattr(vp, ip, filp, cmd, arg);
 
        case XFS_IOC_FSSETDM: {
@@ -966,7 +974,7 @@ xfs_ioctl(
                if (!capable(CAP_SYS_ADMIN))
                        return -EPERM;
 
-               error = xfs_errortag_clearall(mp);
+               error = xfs_errortag_clearall(mp, 1);
                return -error;
 
        default:
@@ -1039,24 +1047,20 @@ xfs_ioc_bulkstat(
        if ((count = bulkreq.icount) <= 0)
                return -XFS_ERROR(EINVAL);
 
+       if (bulkreq.ubuffer == NULL)
+               return -XFS_ERROR(EINVAL);
+
        if (cmd == XFS_IOC_FSINUMBERS)
                error = xfs_inumbers(mp, &inlast, &count,
                                        bulkreq.ubuffer, xfs_inumbers_fmt);
        else if (cmd == XFS_IOC_FSBULKSTAT_SINGLE)
                error = xfs_bulkstat_single(mp, &inlast,
                                                bulkreq.ubuffer, &done);
-       else {  /* XFS_IOC_FSBULKSTAT */
-               if (count == 1 && inlast != 0) {
-                       inlast++;
-                       error = xfs_bulkstat_single(mp, &inlast,
-                                       bulkreq.ubuffer, &done);
-               } else {
-                       error = xfs_bulkstat(mp, &inlast, &count,
-                               (bulkstat_one_pf)xfs_bulkstat_one, NULL,
-                               sizeof(xfs_bstat_t), bulkreq.ubuffer,
-                               BULKSTAT_FG_QUICK, &done);
-               }
-       }
+       else    /* XFS_IOC_FSBULKSTAT */
+               error = xfs_bulkstat(mp, &inlast, &count,
+                       (bulkstat_one_pf)xfs_bulkstat_one, NULL,
+                       sizeof(xfs_bstat_t), bulkreq.ubuffer,
+                       BULKSTAT_FG_QUICK, &done);
 
        if (error)
                return -error;
@@ -1161,6 +1165,42 @@ xfs_di2lxflags(
        return flags;
 }
 
+STATIC int
+xfs_ioc_fsgetxattr(
+       xfs_inode_t             *ip,
+       int                     attr,
+       void                    __user *arg)
+{
+       struct fsxattr          fa;
+
+       xfs_ilock(ip, XFS_ILOCK_SHARED);
+       fa.fsx_xflags = xfs_ip2xflags(ip);
+       fa.fsx_extsize = ip->i_d.di_extsize << ip->i_mount->m_sb.sb_blocklog;
+       fa.fsx_projid = ip->i_d.di_projid;
+
+       if (attr) {
+               if (ip->i_afp) {
+                       if (ip->i_afp->if_flags & XFS_IFEXTENTS)
+                               fa.fsx_nextents = ip->i_afp->if_bytes /
+                                                       sizeof(xfs_bmbt_rec_t);
+                       else
+                               fa.fsx_nextents = ip->i_d.di_anextents;
+               } else
+                       fa.fsx_nextents = 0;
+       } else {
+               if (ip->i_df.if_flags & XFS_IFEXTENTS)
+                       fa.fsx_nextents = ip->i_df.if_bytes /
+                                               sizeof(xfs_bmbt_rec_t);
+               else
+                       fa.fsx_nextents = ip->i_d.di_nextents;
+       }
+       xfs_iunlock(ip, XFS_ILOCK_SHARED);
+
+       if (copy_to_user(arg, &fa, sizeof(fa)))
+               return -EFAULT;
+       return 0;
+}
+
 STATIC int
 xfs_ioc_xattr(
        bhv_vnode_t             *vp,
@@ -1180,27 +1220,6 @@ xfs_ioc_xattr(
                return -ENOMEM;
 
        switch (cmd) {
-       case XFS_IOC_FSGETXATTR: {
-               vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
-                                XFS_AT_NEXTENTS | XFS_AT_PROJID;
-               error = xfs_getattr(ip, vattr, 0);
-               if (unlikely(error)) {
-                       error = -error;
-                       break;
-               }
-
-               fa.fsx_xflags   = vattr->va_xflags;
-               fa.fsx_extsize  = vattr->va_extsize;
-               fa.fsx_nextents = vattr->va_nextents;
-               fa.fsx_projid   = vattr->va_projid;
-
-               if (copy_to_user(arg, &fa, sizeof(fa))) {
-                       error = -EFAULT;
-                       break;
-               }
-               break;
-       }
-
        case XFS_IOC_FSSETXATTR: {
                if (copy_from_user(&fa, arg, sizeof(fa))) {
                        error = -EFAULT;
@@ -1223,27 +1242,6 @@ xfs_ioc_xattr(
                break;
        }
 
-       case XFS_IOC_FSGETXATTRA: {
-               vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
-                                XFS_AT_ANEXTENTS | XFS_AT_PROJID;
-               error = xfs_getattr(ip, vattr, 0);
-               if (unlikely(error)) {
-                       error = -error;
-                       break;
-               }
-
-               fa.fsx_xflags   = vattr->va_xflags;
-               fa.fsx_extsize  = vattr->va_extsize;
-               fa.fsx_nextents = vattr->va_anextents;
-               fa.fsx_projid   = vattr->va_projid;
-
-               if (copy_to_user(arg, &fa, sizeof(fa))) {
-                       error = -EFAULT;
-                       break;
-               }
-               break;
-       }
-
        case XFS_IOC_GETXFLAGS: {
                flags = xfs_di2lxflags(ip->i_d.di_flags);
                if (copy_to_user(arg, &flags, sizeof(flags)))