RETURN(rc);
}
-int ll_ioctl_projid(struct inode *inode, unsigned int cmd,
- unsigned long arg)
+int ll_ioctl_fsgetxattr(struct inode *inode, unsigned int cmd,
+ unsigned long arg)
{
- int rc = 0;
- struct fsxattr *fsxattr;
- int alloc_size = sizeof(*fsxattr);
+ struct fsxattr fsxattr;
- switch (cmd) {
- case LL_IOC_FSGETXATTR: {
- OBD_ALLOC_PTR(fsxattr);
- if (fsxattr == NULL)
- RETURN(-ENOMEM);
+ if (copy_from_user(&fsxattr,
+ (const struct fsxattr __user *)arg,
+ sizeof(fsxattr)))
+ RETURN(-EFAULT);
- if (copy_from_user(fsxattr,
- (const struct fsxattr __user *)arg,
- alloc_size))
- GOTO(out_fsxattr, rc = -EFAULT);
-
- fsxattr->fsx_projid = ll_i2info(inode)->lli_projid;
- if (copy_to_user((struct fsxattr __user *)arg,
- fsxattr, alloc_size))
- GOTO(out_fsxattr, rc = -EFAULT);
-out_fsxattr:
- OBD_FREE(fsxattr, alloc_size);
- RETURN(rc);
- }
+ fsxattr.fsx_projid = ll_i2info(inode)->lli_projid;
+ if (copy_to_user((struct fsxattr __user *)arg,
+ &fsxattr, sizeof(fsxattr)))
+ RETURN(-EFAULT);
- case LL_IOC_FSSETXATTR: {
- struct md_op_data *op_data;
- struct ptlrpc_request *req = NULL;
+ RETURN(0);
+}
- /* only root could change project ID */
- if (!cfs_capable(CFS_CAP_SYS_ADMIN))
- RETURN(-EPERM);
+int ll_ioctl_fssetxattr(struct inode *inode, unsigned int cmd,
+ unsigned long arg)
+{
- op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
- LUSTRE_OPC_ANY, NULL);
- if (IS_ERR(op_data))
- RETURN(PTR_ERR(op_data));
+ struct md_op_data *op_data;
+ struct ptlrpc_request *req = NULL;
+ int rc = 0;
+ struct fsxattr fsxattr;
+
+ /* only root could change project ID */
+ if (!cfs_capable(CFS_CAP_SYS_ADMIN))
+ RETURN(-EPERM);
- OBD_ALLOC_PTR(fsxattr);
- if (fsxattr == NULL)
- GOTO(out_fsxattr1, rc = -ENOMEM);
+ op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
+ LUSTRE_OPC_ANY, NULL);
+ if (IS_ERR(op_data))
+ RETURN(PTR_ERR(op_data));
- if (copy_from_user(fsxattr,
- (const struct fsxattr __user *)arg,
- alloc_size))
- GOTO(out_fsxattr1, rc = -EFAULT);
+ if (copy_from_user(&fsxattr,
+ (const struct fsxattr __user *)arg,
+ sizeof(fsxattr)))
+ GOTO(out_fsxattr1, rc = -EFAULT);
- op_data->op_projid = fsxattr->fsx_projid;
- op_data->op_attr.ia_valid |= MDS_ATTR_PROJID;
- rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, NULL,
- 0, &req);
- ptlrpc_req_finished(req);
+ op_data->op_projid = fsxattr.fsx_projid;
+ op_data->op_attr.ia_valid |= MDS_ATTR_PROJID;
+ rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, NULL,
+ 0, &req);
+ ptlrpc_req_finished(req);
out_fsxattr1:
- ll_finish_md_op_data(op_data);
- OBD_FREE(fsxattr, alloc_size);
- RETURN(rc);
- }
- default:
- LASSERT(0);
- }
-
+ ll_finish_md_op_data(op_data);
RETURN(rc);
+
+
}
static long
RETURN(rc);
}
case LL_IOC_FSGETXATTR:
+ RETURN(ll_ioctl_fsgetxattr(inode, cmd, arg));
case LL_IOC_FSSETXATTR:
- RETURN(ll_ioctl_projid(inode, cmd, arg));
+ RETURN(ll_ioctl_fssetxattr(inode, cmd, arg));
default: {
int err;