int server_name2index(const char *svname, __u32 *idx, const char **endptr);
/* linux-module.c */
-int obd_ioctl_getdata(char **buf, int *len, void __user *arg);
+struct obd_ioctl_data;
+int obd_ioctl_getdata(struct obd_ioctl_data **data, int *len, void __user *arg);
int class_procfs_init(void);
int class_procfs_clean(void);
struct dentry *dentry = file_dentry(file);
struct inode *inode = file_inode(file);
struct ll_sb_info *sbi = ll_i2sbi(inode);
- struct obd_ioctl_data *data;
+ struct obd_ioctl_data *data = NULL;
int rc = 0;
ENTRY;
return 0;
}
case IOC_MDC_LOOKUP: {
- int namelen, len = 0;
- char *buf = NULL;
+ int namelen, len = 0;
char *filename;
- rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg);
+ rc = obd_ioctl_getdata(&data, &len, (void __user *)arg);
if (rc != 0)
RETURN(rc);
- data = (void *)buf;
filename = data->ioc_inlbuf1;
namelen = strlen(filename);
GOTO(out_free, rc);
}
out_free:
- OBD_FREE_LARGE(buf, len);
- return rc;
- }
+ OBD_FREE_LARGE(data, len);
+ return rc;
+ }
case LL_IOC_LMV_SETSTRIPE: {
struct lmv_user_md *lum;
- char *buf = NULL;
char *filename;
int namelen = 0;
int lumlen = 0;
int len;
int rc;
- rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg);
+ rc = obd_ioctl_getdata(&data, &len, (void __user *)arg);
if (rc)
RETURN(rc);
- data = (void *)buf;
if (data->ioc_inlbuf1 == NULL || data->ioc_inlbuf2 == NULL ||
data->ioc_inllen1 == 0 || data->ioc_inllen2 == 0)
GOTO(lmv_out_free, rc = -EINVAL);
mode = data->ioc_type;
rc = ll_dir_setdirstripe(dentry, lum, lumlen, filename, mode);
lmv_out_free:
- OBD_FREE_LARGE(buf, len);
+ OBD_FREE_LARGE(data, len);
RETURN(rc);
}
}
case LL_IOC_MIGRATE: {
struct lmv_user_md *lum;
- char *buf = NULL;
int len;
char *filename;
int namelen = 0;
int rc;
- rc = obd_ioctl_getdata(&buf, &len, (void __user *)arg);
+ rc = obd_ioctl_getdata(&data, &len, (void __user *)arg);
if (rc)
RETURN(rc);
- data = (struct obd_ioctl_data *)buf;
if (data->ioc_inlbuf1 == NULL || data->ioc_inlbuf2 == NULL ||
data->ioc_inllen1 == 0 || data->ioc_inllen2 == 0)
GOTO(migrate_free, rc = -EINVAL);
rc = ll_migrate(inode, file, lum, filename);
migrate_free:
- OBD_FREE_LARGE(buf, len);
+ OBD_FREE_LARGE(data, len);
RETURN(rc);
}
int ll_obd_statfs(struct inode *inode, void __user *arg)
{
- struct ll_sb_info *sbi = NULL;
- struct obd_export *exp;
- char *buf = NULL;
- struct obd_ioctl_data *data = NULL;
- __u32 type;
- int len = 0, rc;
-
- if (!inode || !(sbi = ll_i2sbi(inode)))
- GOTO(out_statfs, rc = -EINVAL);
-
- rc = obd_ioctl_getdata(&buf, &len, arg);
- if (rc)
- GOTO(out_statfs, rc);
-
- data = (void*)buf;
- if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 ||
- !data->ioc_pbuf1 || !data->ioc_pbuf2)
- GOTO(out_statfs, rc = -EINVAL);
-
- if (data->ioc_inllen1 != sizeof(__u32) ||
- data->ioc_inllen2 != sizeof(__u32) ||
- data->ioc_plen1 != sizeof(struct obd_statfs) ||
- data->ioc_plen2 != sizeof(struct obd_uuid))
- GOTO(out_statfs, rc = -EINVAL);
-
- memcpy(&type, data->ioc_inlbuf1, sizeof(__u32));
+ struct ll_sb_info *sbi = NULL;
+ struct obd_export *exp;
+ struct obd_ioctl_data *data = NULL;
+ __u32 type;
+ int len = 0, rc;
+
+ if (inode)
+ sbi = ll_i2sbi(inode);
+ if (!sbi)
+ GOTO(out_statfs, rc = -EINVAL);
+
+ rc = obd_ioctl_getdata(&data, &len, arg);
+ if (rc)
+ GOTO(out_statfs, rc);
+
+ if (!data->ioc_inlbuf1 || !data->ioc_inlbuf2 ||
+ !data->ioc_pbuf1 || !data->ioc_pbuf2)
+ GOTO(out_statfs, rc = -EINVAL);
+
+ if (data->ioc_inllen1 != sizeof(__u32) ||
+ data->ioc_inllen2 != sizeof(__u32) ||
+ data->ioc_plen1 != sizeof(struct obd_statfs) ||
+ data->ioc_plen2 != sizeof(struct obd_uuid))
+ GOTO(out_statfs, rc = -EINVAL);
+
+ memcpy(&type, data->ioc_inlbuf1, sizeof(__u32));
if (type & LL_STATFS_LMV)
- exp = sbi->ll_md_exp;
+ exp = sbi->ll_md_exp;
else if (type & LL_STATFS_LOV)
- exp = sbi->ll_dt_exp;
- else
- GOTO(out_statfs, rc = -ENODEV);
+ exp = sbi->ll_dt_exp;
+ else
+ GOTO(out_statfs, rc = -ENODEV);
- rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, buf, NULL);
- if (rc)
- GOTO(out_statfs, rc);
+ rc = obd_iocontrol(IOC_OBD_STATFS, exp, len, data, NULL);
+ if (rc)
+ GOTO(out_statfs, rc);
out_statfs:
- OBD_FREE_LARGE(buf, len);
+ OBD_FREE_LARGE(data, len);
return rc;
}
RETURN(-EFAULT);
break;
}
- case OBD_IOC_LOV_GET_CONFIG: {
- struct obd_ioctl_data *data;
- struct lov_desc *desc;
- char *buf = NULL;
- __u32 *genp;
-
- len = 0;
- if (obd_ioctl_getdata(&buf, &len, uarg))
- RETURN(-EINVAL);
+ case OBD_IOC_LOV_GET_CONFIG: {
+ struct obd_ioctl_data *data = NULL;
+ struct lov_desc *desc;
+ __u32 *genp;
- data = (struct obd_ioctl_data *)buf;
+ len = 0;
+ if (obd_ioctl_getdata(&data, &len, uarg))
+ RETURN(-EINVAL);
- if (sizeof(*desc) > data->ioc_inllen1) {
- OBD_FREE_LARGE(buf, len);
- RETURN(-EINVAL);
- }
+ if (sizeof(*desc) > data->ioc_inllen1) {
+ OBD_FREE_LARGE(data, len);
+ RETURN(-EINVAL);
+ }
- if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) {
- OBD_FREE_LARGE(buf, len);
- RETURN(-EINVAL);
- }
+ if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) {
+ OBD_FREE_LARGE(data, len);
+ RETURN(-EINVAL);
+ }
- if (sizeof(__u32) * count > data->ioc_inllen3) {
- OBD_FREE_LARGE(buf, len);
- RETURN(-EINVAL);
- }
+ if (sizeof(__u32) * count > data->ioc_inllen3) {
+ OBD_FREE_LARGE(data, len);
+ RETURN(-EINVAL);
+ }
- desc = (struct lov_desc *)data->ioc_inlbuf1;
- memcpy(desc, &(lov->desc), sizeof(*desc));
+ desc = (struct lov_desc *)data->ioc_inlbuf1;
+ memcpy(desc, &lov->desc, sizeof(*desc));
- uuidp = (struct obd_uuid *)data->ioc_inlbuf2;
- genp = (__u32 *)data->ioc_inlbuf3;
- /* the uuid will be empty for deleted OSTs */
- for (i = 0; i < count; i++, uuidp++, genp++) {
- if (!lov->lov_tgts[i])
- continue;
- *uuidp = lov->lov_tgts[i]->ltd_uuid;
- *genp = lov->lov_tgts[i]->ltd_gen;
- }
+ uuidp = (struct obd_uuid *)data->ioc_inlbuf2;
+ genp = (__u32 *)data->ioc_inlbuf3;
+ /* the uuid will be empty for deleted OSTs */
+ for (i = 0; i < count; i++, uuidp++, genp++) {
+ if (!lov->lov_tgts[i])
+ continue;
+ *uuidp = lov->lov_tgts[i]->ltd_uuid;
+ *genp = lov->lov_tgts[i]->ltd_gen;
+ }
- if (copy_to_user(uarg, buf, len))
- rc = -EFAULT;
- OBD_FREE_LARGE(buf, len);
- break;
- }
+ if (copy_to_user(uarg, data, len))
+ rc = -EFAULT;
+ OBD_FREE_LARGE(data, len);
+ break;
+ }
case OBD_IOC_QUOTACTL: {
struct if_quotactl *qctl = karg;
struct lov_tgt_desc *tgt = NULL;
}
/* buffer MUST be at least the size of obd_ioctl_hdr */
-int obd_ioctl_getdata(char **buf, int *len, void __user *arg)
+int obd_ioctl_getdata(struct obd_ioctl_data **datap, int *len, void __user *arg)
{
struct obd_ioctl_hdr hdr;
struct obd_ioctl_data *data;
* obdfilter-survey is an example, which relies on ioctl. So we'd
* better avoid vmalloc on ioctl path. LU-66
*/
- OBD_ALLOC_LARGE(*buf, hdr.ioc_len);
- if (!*buf) {
+ OBD_ALLOC_LARGE(data, hdr.ioc_len);
+ if (!data) {
CERROR("Cannot allocate control buffer of len %d\n",
hdr.ioc_len);
RETURN(-EINVAL);
}
*len = hdr.ioc_len;
- data = (struct obd_ioctl_data *)*buf;
- if (copy_from_user(*buf, arg, hdr.ioc_len)) {
- OBD_FREE_LARGE(*buf, hdr.ioc_len);
+ if (copy_from_user(data, arg, hdr.ioc_len)) {
+ OBD_FREE_LARGE(data, hdr.ioc_len);
RETURN(-EFAULT);
}
if (obd_ioctl_is_invalid(data)) {
CERROR("ioctl not correctly formatted\n");
- OBD_FREE_LARGE(*buf, hdr.ioc_len);
+ OBD_FREE_LARGE(data, hdr.ioc_len);
RETURN(-EINVAL);
}
if (data->ioc_inllen4)
data->ioc_inlbuf4 = &data->ioc_bulk[0] + offset;
+ *datap = data;
+
RETURN(0);
}
EXPORT_SYMBOL(obd_ioctl_getdata);
int class_handle_ioctl(unsigned int cmd, unsigned long arg)
{
- char *buf = NULL;
struct obd_ioctl_data *data;
struct obd_device *obd = NULL;
int err = 0, len = 0;
ENTRY;
CDEBUG(D_IOCTL, "cmd = %x\n", cmd);
- if (obd_ioctl_getdata(&buf, &len, (void __user *)arg)) {
+ if (obd_ioctl_getdata(&data, &len, (void __user *)arg)) {
CERROR("OBD ioctl: data error\n");
RETURN(-EINVAL);
}
- data = (struct obd_ioctl_data *)buf;
switch (cmd) {
case OBD_IOC_PROCESS_CFG: {
if (copy_to_user((void __user *)arg, data, len))
err = -EFAULT;
out:
- OBD_FREE_LARGE(buf, len);
+ OBD_FREE_LARGE(data, len);
RETURN(err);
} /* class_handle_ioctl */