Diff for /xfs-linux/linux-2.6/xfs_ioctl.c between versions 1.155 and 1.156

version 1.155, 2007/09/26 06:08:57 version 1.156, 2007/10/01 15:54:42
Line 75  xfs_find_handle( Line 75  xfs_find_handle(
         xfs_handle_t            handle;          xfs_handle_t            handle;
         xfs_fsop_handlereq_t    hreq;          xfs_fsop_handlereq_t    hreq;
         struct inode            *inode;          struct inode            *inode;
         bhv_vnode_t             *vp;  
   
         if (copy_from_user(&hreq, arg, sizeof(hreq)))          if (copy_from_user(&hreq, arg, sizeof(hreq)))
                 return -XFS_ERROR(EFAULT);                  return -XFS_ERROR(EFAULT);
Line 134  xfs_find_handle( Line 133  xfs_find_handle(
                 return -XFS_ERROR(EBADF);                  return -XFS_ERROR(EBADF);
         }          }
   
         /* we need the vnode */  
         vp = vn_from_inode(inode);  
   
         /* now we can grab the fsid */          /* now we can grab the fsid */
         memcpy(&handle.ha_fsid, XFS_I(inode)->i_mount->m_fixedfsid,          memcpy(&handle.ha_fsid, XFS_I(inode)->i_mount->m_fixedfsid,
                         sizeof(xfs_fsid_t));                          sizeof(xfs_fsid_t));
         hsize = sizeof(xfs_fsid_t);          hsize = sizeof(xfs_fsid_t);
   
         if (cmd != XFS_IOC_PATH_TO_FSHANDLE) {          if (cmd != XFS_IOC_PATH_TO_FSHANDLE) {
                 xfs_inode_t     *ip;                  xfs_inode_t     *ip = XFS_I(inode);
                 int             lock_mode;                  int             lock_mode;
   
                 /* need to get access to the xfs_inode to read the generation */                  /* need to get access to the xfs_inode to read the generation */
                 ip = xfs_vtoi(vp);  
                 ASSERT(ip);  
                 lock_mode = xfs_ilock_map_shared(ip);                  lock_mode = xfs_ilock_map_shared(ip);
   
                 /* fill in fid section of handle from inode */                  /* fill in fid section of handle from inode */
Line 176  xfs_find_handle( Line 170  xfs_find_handle(
   
   
 /*  /*
  * Convert userspace handle data into vnode (and inode).   * Convert userspace handle data into inode.
  * We [ab]use the fact that all the fsop_handlereq ioctl calls   *
  * have a data structure argument whose first component is always   * We use the fact that all the fsop_handlereq ioctl calls have a data
  * a xfs_fsop_handlereq_t, so we can cast to and from this type.   * structure argument whose first component is always a xfs_fsop_handlereq_t,
  * This allows us to optimise the copy_from_user calls and gives   * so we can pass that sub structure into this handy, shared routine.
  * a handy, shared routine.  
  *   *
  * If no error, caller must always VN_RELE the returned vp.   * If no error, caller must always iput the returned inode.
  */   */
 STATIC int  STATIC int
 xfs_vget_fsop_handlereq(  xfs_vget_fsop_handlereq(
         xfs_mount_t             *mp,          xfs_mount_t             *mp,
         struct inode            *parinode,      /* parent inode pointer    */          struct inode            *parinode,      /* parent inode pointer    */
         xfs_fsop_handlereq_t    *hreq,          xfs_fsop_handlereq_t    *hreq,
         bhv_vnode_t             **vp,  
         struct inode            **inode)          struct inode            **inode)
 {  {
         void                    __user *hanp;          void                    __user *hanp;
Line 199  xfs_vget_fsop_handlereq( Line 191  xfs_vget_fsop_handlereq(
         xfs_handle_t            *handlep;          xfs_handle_t            *handlep;
         xfs_handle_t            handle;          xfs_handle_t            handle;
         xfs_inode_t             *ip;          xfs_inode_t             *ip;
         struct inode            *inodep;  
         bhv_vnode_t             *vpp;  
         xfs_ino_t               ino;          xfs_ino_t               ino;
         __u32                   igen;          __u32                   igen;
         int                     error;          int                     error;
Line 241  xfs_vget_fsop_handlereq( Line 231  xfs_vget_fsop_handlereq(
         }          }
   
         /*          /*
          * Get the XFS inode, building a vnode to go with it.           * Get the XFS inode, building a Linux inode to go with it.
          */           */
         error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, 0);          error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, 0);
         if (error)          if (error)
Line 253  xfs_vget_fsop_handlereq( Line 243  xfs_vget_fsop_handlereq(
                 return XFS_ERROR(ENOENT);                  return XFS_ERROR(ENOENT);
         }          }
   
         vpp = XFS_ITOV(ip);  
         inodep = vn_to_inode(vpp);  
         xfs_iunlock(ip, XFS_ILOCK_SHARED);          xfs_iunlock(ip, XFS_ILOCK_SHARED);
   
         *vp = vpp;          *inode = XFS_ITOV(ip);
         *inode = inodep;  
         return 0;          return 0;
 }  }
   
Line 275  xfs_open_by_handle( Line 262  xfs_open_by_handle(
         struct file             *filp;          struct file             *filp;
         struct inode            *inode;          struct inode            *inode;
         struct dentry           *dentry;          struct dentry           *dentry;
         bhv_vnode_t             *vp;  
         xfs_fsop_handlereq_t    hreq;          xfs_fsop_handlereq_t    hreq;
   
         if (!capable(CAP_SYS_ADMIN))          if (!capable(CAP_SYS_ADMIN))
Line 283  xfs_open_by_handle( Line 269  xfs_open_by_handle(
         if (copy_from_user(&hreq, arg, sizeof(xfs_fsop_handlereq_t)))          if (copy_from_user(&hreq, arg, sizeof(xfs_fsop_handlereq_t)))
                 return -XFS_ERROR(EFAULT);                  return -XFS_ERROR(EFAULT);
   
         error = xfs_vget_fsop_handlereq(mp, parinode, &hreq, &vp, &inode);          error = xfs_vget_fsop_handlereq(mp, parinode, &hreq, &inode);
         if (error)          if (error)
                 return -error;                  return -error;
   
Line 385  xfs_readlink_by_handle( Line 371  xfs_readlink_by_handle(
 {  {
         struct inode            *inode;          struct inode            *inode;
         xfs_fsop_handlereq_t    hreq;          xfs_fsop_handlereq_t    hreq;
         bhv_vnode_t             *vp;  
         __u32                   olen;          __u32                   olen;
         void                    *link;          void                    *link;
         int                     error;          int                     error;
Line 395  xfs_readlink_by_handle( Line 380  xfs_readlink_by_handle(
         if (copy_from_user(&hreq, arg, sizeof(xfs_fsop_handlereq_t)))          if (copy_from_user(&hreq, arg, sizeof(xfs_fsop_handlereq_t)))
                 return -XFS_ERROR(EFAULT);                  return -XFS_ERROR(EFAULT);
   
         error = xfs_vget_fsop_handlereq(mp, parinode, &hreq, &vp, &inode);          error = xfs_vget_fsop_handlereq(mp, parinode, &hreq, &inode);
         if (error)          if (error)
                 return -error;                  return -error;
   
Line 438  xfs_fssetdm_by_handle( Line 423  xfs_fssetdm_by_handle(
         struct fsdmidata        fsd;          struct fsdmidata        fsd;
         xfs_fsop_setdm_handlereq_t dmhreq;          xfs_fsop_setdm_handlereq_t dmhreq;
         struct inode            *inode;          struct inode            *inode;
         bhv_vnode_t             *vp;  
   
         if (!capable(CAP_MKNOD))          if (!capable(CAP_MKNOD))
                 return -XFS_ERROR(EPERM);                  return -XFS_ERROR(EPERM);
         if (copy_from_user(&dmhreq, arg, sizeof(xfs_fsop_setdm_handlereq_t)))          if (copy_from_user(&dmhreq, arg, sizeof(xfs_fsop_setdm_handlereq_t)))
                 return -XFS_ERROR(EFAULT);                  return -XFS_ERROR(EFAULT);
   
         error = xfs_vget_fsop_handlereq(mp, parinode, &dmhreq.hreq, &vp, &inode);          error = xfs_vget_fsop_handlereq(mp, parinode, &dmhreq.hreq, &inode);
         if (error)          if (error)
                 return -error;                  return -error;
   
         if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {          if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
                 VN_RELE(vp);                  error = -XFS_ERROR(EPERM);
                 return -XFS_ERROR(EPERM);                  goto out;
         }          }
   
         if (copy_from_user(&fsd, dmhreq.data, sizeof(fsd))) {          if (copy_from_user(&fsd, dmhreq.data, sizeof(fsd))) {
                 VN_RELE(vp);                  error = -XFS_ERROR(EFAULT);
                 return -XFS_ERROR(EFAULT);                  goto out;
         }          }
   
         error = xfs_set_dmattrs(xfs_vtoi(vp),          error = -xfs_set_dmattrs(XFS_I(inode), fsd.fsd_dmevmask,
                         fsd.fsd_dmevmask, fsd.fsd_dmstate);                                   fsd.fsd_dmstate);
   
         VN_RELE(vp);   out:
         if (error)          iput(inode);
                 return -error;          return error;
         return 0;  
 }  }
   
 STATIC int  STATIC int
Line 478  xfs_attrlist_by_handle( Line 461  xfs_attrlist_by_handle(
         attrlist_cursor_kern_t  *cursor;          attrlist_cursor_kern_t  *cursor;
         xfs_fsop_attrlist_handlereq_t al_hreq;          xfs_fsop_attrlist_handlereq_t al_hreq;
         struct inode            *inode;          struct inode            *inode;
         bhv_vnode_t             *vp;  
         char                    *kbuf;          char                    *kbuf;
   
         if (!capable(CAP_SYS_ADMIN))          if (!capable(CAP_SYS_ADMIN))
Line 488  xfs_attrlist_by_handle( Line 470  xfs_attrlist_by_handle(
         if (al_hreq.buflen > XATTR_LIST_MAX)          if (al_hreq.buflen > XATTR_LIST_MAX)
                 return -XFS_ERROR(EINVAL);                  return -XFS_ERROR(EINVAL);
   
         error = xfs_vget_fsop_handlereq(mp, parinode, &al_hreq.hreq,          error = xfs_vget_fsop_handlereq(mp, parinode, &al_hreq.hreq, &inode);
                         &vp, &inode);  
         if (error)          if (error)
                 goto out;                  goto out;
   
Line 509  xfs_attrlist_by_handle( Line 490  xfs_attrlist_by_handle(
  out_kfree:   out_kfree:
         kfree(kbuf);          kfree(kbuf);
  out_vn_rele:   out_vn_rele:
         VN_RELE(vp);          iput(inode);
  out:   out:
         return -error;          return -error;
 }  }
Line 598  xfs_attrmulti_by_handle( Line 579  xfs_attrmulti_by_handle(
         xfs_attr_multiop_t      *ops;          xfs_attr_multiop_t      *ops;
         xfs_fsop_attrmulti_handlereq_t am_hreq;          xfs_fsop_attrmulti_handlereq_t am_hreq;
         struct inode            *inode;          struct inode            *inode;
         bhv_vnode_t             *vp;  
         unsigned int            i, size;          unsigned int            i, size;
         char                    *attr_name;          char                    *attr_name;
   
Line 607  xfs_attrmulti_by_handle( Line 587  xfs_attrmulti_by_handle(
         if (copy_from_user(&am_hreq, arg, sizeof(xfs_fsop_attrmulti_handlereq_t)))          if (copy_from_user(&am_hreq, arg, sizeof(xfs_fsop_attrmulti_handlereq_t)))
                 return -XFS_ERROR(EFAULT);                  return -XFS_ERROR(EFAULT);
   
         error = xfs_vget_fsop_handlereq(mp, parinode, &am_hreq.hreq, &vp, &inode);          error = xfs_vget_fsop_handlereq(mp, parinode, &am_hreq.hreq, &inode);
         if (error)          if (error)
                 goto out;                  goto out;
   
Line 666  xfs_attrmulti_by_handle( Line 646  xfs_attrmulti_by_handle(
  out_kfree_ops:   out_kfree_ops:
         kfree(ops);          kfree(ops);
  out_vn_rele:   out_vn_rele:
         VN_RELE(vp);          iput(inode);
  out:   out:
         return -error;          return -error;
 }  }
Line 702  xfs_ioc_fsgeometry( Line 682  xfs_ioc_fsgeometry(
   
 STATIC int  STATIC int
 xfs_ioc_xattr(  xfs_ioc_xattr(
         bhv_vnode_t             *vp,  
         xfs_inode_t             *ip,          xfs_inode_t             *ip,
         struct file             *filp,          struct file             *filp,
         unsigned int            cmd,          unsigned int            cmd,
Line 735  xfs_ioctl( Line 714  xfs_ioctl(
         void                    __user *arg)          void                    __user *arg)
 {  {
         struct inode            *inode = filp->f_path.dentry->d_inode;          struct inode            *inode = filp->f_path.dentry->d_inode;
         bhv_vnode_t             *vp = vn_from_inode(inode);  
         xfs_mount_t             *mp = ip->i_mount;          xfs_mount_t             *mp = ip->i_mount;
         int                     error;          int                     error;
   
Line 795  xfs_ioctl( Line 773  xfs_ioctl(
         case XFS_IOC_GETXFLAGS:          case XFS_IOC_GETXFLAGS:
         case XFS_IOC_SETXFLAGS:          case XFS_IOC_SETXFLAGS:
         case XFS_IOC_FSSETXATTR:          case XFS_IOC_FSSETXATTR:
                 return xfs_ioc_xattr(vp, ip, filp, cmd, arg);                  return xfs_ioc_xattr(ip, filp, cmd, arg);
   
         case XFS_IOC_FSSETDM: {          case XFS_IOC_FSSETDM: {
                 struct fsdmidata        dmi;                  struct fsdmidata        dmi;
Line 1206  xfs_ioc_fsgetxattr( Line 1184  xfs_ioc_fsgetxattr(
   
 STATIC int  STATIC int
 xfs_ioc_xattr(  xfs_ioc_xattr(
         bhv_vnode_t             *vp,  
         xfs_inode_t             *ip,          xfs_inode_t             *ip,
         struct file             *filp,          struct file             *filp,
         unsigned int            cmd,          unsigned int            cmd,
Line 1240  xfs_ioc_xattr( Line 1217  xfs_ioc_xattr(
   
                 error = xfs_setattr(ip, vattr, attr_flags, NULL);                  error = xfs_setattr(ip, vattr, attr_flags, NULL);
                 if (likely(!error))                  if (likely(!error))
                         vn_revalidate(vp);      /* update flags */                          vn_revalidate(XFS_ITOV(ip));    /* update flags */
                 error = -error;                  error = -error;
                 break;                  break;
         }          }
Line 1275  xfs_ioc_xattr( Line 1252  xfs_ioc_xattr(
   
                 error = xfs_setattr(ip, vattr, attr_flags, NULL);                  error = xfs_setattr(ip, vattr, attr_flags, NULL);
                 if (likely(!error))                  if (likely(!error))
                         vn_revalidate(vp);      /* update flags */                          vn_revalidate(XFS_ITOV(ip));    /* update flags */
                 error = -error;                  error = -error;
                 break;                  break;
         }          }

Removed from v.1.155  
changed lines
  Added in v.1.156


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>