lustre_idmap.h \
lustre_import.h \
lustre_intent.h \
- lustre_ioctl.h \
lustre_lfsck.h \
lustre_lib.h \
lustre_linkea.h \
extern int llapi_get_poolmembers(const char *poolname, char **members,
int list_size, char *buffer, int buffer_size);
extern int llapi_file_get_stripe(const char *path, struct lov_user_md *lum);
-#define HAVE_LLAPI_FILE_LOOKUP
extern int llapi_file_lookup(int dirfd, const char *name);
#define VERBOSE_COUNT 0x1
/* linux-module.c */
extern struct miscdevice obd_psdev;
+int obd_ioctl_getdata(char **buf, int *len, void __user *arg);
int class_procfs_init(void);
int class_procfs_clean(void);
#
EXTRA_DIST = \
- lustre_disk.h
+ lustre_disk.h \
+ lustre_ioctl.h
*
* Copyright (c) 2014, 2016, Intel Corporation.
*/
-#ifndef LUSTRE_IOCTL_H_
-#define LUSTRE_IOCTL_H_
+#ifndef _UAPI_LUSTRE_IOCTL_H
+#define _UAPI_LUSTRE_IOCTL_H
+#include <linux/ioctl.h>
+#include <linux/kernel.h>
#include <linux/types.h>
-#include <libcfs/libcfs.h>
#include <lustre/lustre_idl.h>
-#ifdef __KERNEL__
-# include <linux/ioctl.h>
-# include <linux/string.h>
-# include <obd_support.h>
-#else /* __KERNEL__ */
-# include <malloc.h>
-# include <string.h>
-#include <libcfs/util/ioctl.h>
-#endif /* !__KERNEL__ */
-
#if !defined(__KERNEL__) && !defined(LUSTRE_UTILS)
# error This file is for Lustre internal use only.
#endif
+/* Handle older distros */
+#ifndef __ALIGN_KERNEL
+# define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
+# define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
+#endif
+
enum md_echo_cmd {
ECHO_MD_CREATE = 1, /* Open/Create file on MDT */
ECHO_MD_MKDIR = 2, /* Mkdir on MDT */
static inline __u32 obd_ioctl_packlen(struct obd_ioctl_data *data)
{
- __u32 len = cfs_size_round(sizeof(*data));
+ __u32 len = __ALIGN_KERNEL(sizeof(*data), 8);
- len += cfs_size_round(data->ioc_inllen1);
- len += cfs_size_round(data->ioc_inllen2);
- len += cfs_size_round(data->ioc_inllen3);
- len += cfs_size_round(data->ioc_inllen4);
+ len += __ALIGN_KERNEL(data->ioc_inllen1, 8);
+ len += __ALIGN_KERNEL(data->ioc_inllen2, 8);
+ len += __ALIGN_KERNEL(data->ioc_inllen3, 8);
+ len += __ALIGN_KERNEL(data->ioc_inllen4, 8);
return len;
}
-static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data)
-{
- if (data->ioc_len > (1 << 30)) {
- CERROR("OBD ioctl: ioc_len larger than 1<<30\n");
- return 1;
- }
-
- if (data->ioc_inllen1 > (1 << 30)) {
- CERROR("OBD ioctl: ioc_inllen1 larger than 1<<30\n");
- return 1;
- }
-
- if (data->ioc_inllen2 > (1 << 30)) {
- CERROR("OBD ioctl: ioc_inllen2 larger than 1<<30\n");
- return 1;
- }
-
- if (data->ioc_inllen3 > (1 << 30)) {
- CERROR("OBD ioctl: ioc_inllen3 larger than 1<<30\n");
- return 1;
- }
-
- if (data->ioc_inllen4 > (1 << 30)) {
- CERROR("OBD ioctl: ioc_inllen4 larger than 1<<30\n");
- return 1;
- }
-
- if (data->ioc_inlbuf1 != NULL && data->ioc_inllen1 == 0) {
- CERROR("OBD ioctl: inlbuf1 pointer but 0 length\n");
- return 1;
- }
-
- if (data->ioc_inlbuf2 != NULL && data->ioc_inllen2 == 0) {
- CERROR("OBD ioctl: inlbuf2 pointer but 0 length\n");
- return 1;
- }
-
- if (data->ioc_inlbuf3 != NULL && data->ioc_inllen3 == 0) {
- CERROR("OBD ioctl: inlbuf3 pointer but 0 length\n");
- return 1;
- }
-
- if (data->ioc_inlbuf4 != NULL && data->ioc_inllen4 == 0) {
- CERROR("OBD ioctl: inlbuf4 pointer but 0 length\n");
- return 1;
- }
-
- if (data->ioc_pbuf1 != NULL && data->ioc_plen1 == 0) {
- CERROR("OBD ioctl: pbuf1 pointer but 0 length\n");
- return 1;
- }
-
- if (data->ioc_pbuf2 != NULL && data->ioc_plen2 == 0) {
- CERROR("OBD ioctl: pbuf2 pointer but 0 length\n");
- return 1;
- }
-
- if (data->ioc_pbuf1 == NULL && data->ioc_plen1 != 0) {
- CERROR("OBD ioctl: plen1 set but NULL pointer\n");
- return 1;
- }
-
- if (data->ioc_pbuf2 == NULL && data->ioc_plen2 != 0) {
- CERROR("OBD ioctl: plen2 set but NULL pointer\n");
- return 1;
- }
-
- if (obd_ioctl_packlen(data) > data->ioc_len) {
- CERROR("OBD ioctl: packlen exceeds ioc_len (%d > %d)\n",
- obd_ioctl_packlen(data), data->ioc_len);
- return 1;
- }
-
- return 0;
-}
-
-#ifdef __KERNEL__
-
-int obd_ioctl_getdata(char **buf, int *len, void __user *arg);
-int obd_ioctl_popdata(void __user *arg, void *data, int len);
-
-static inline void obd_ioctl_freedata(char *buf, size_t len)
-{
- ENTRY;
-
- OBD_FREE_LARGE(buf, len);
- EXIT;
-}
-
-#else /* __KERNEL__ */
-
-static inline int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf,
- int max_len)
-{
- char *ptr;
- struct obd_ioctl_data *overlay;
-
- data->ioc_len = obd_ioctl_packlen(data);
- data->ioc_version = OBD_IOCTL_VERSION;
-
- if (*pbuf != NULL && data->ioc_len > max_len) {
- fprintf(stderr, "pbuf = %p, ioc_len = %u, max_len = %d\n",
- *pbuf, data->ioc_len, max_len);
- return -EINVAL;
- }
-
- if (*pbuf == NULL)
- *pbuf = malloc(data->ioc_len);
-
- if (*pbuf == NULL)
- return -ENOMEM;
-
- overlay = (struct obd_ioctl_data *)*pbuf;
- memcpy(*pbuf, data, sizeof(*data));
-
- ptr = overlay->ioc_bulk;
- if (data->ioc_inlbuf1) {
- memcpy(ptr, data->ioc_inlbuf1, data->ioc_inllen1);
- ptr += cfs_size_round(data->ioc_inllen1);
- }
-
- if (data->ioc_inlbuf2) {
- memcpy(ptr, data->ioc_inlbuf2, data->ioc_inllen2);
- ptr += cfs_size_round(data->ioc_inllen2);
- }
-
- if (data->ioc_inlbuf3) {
- memcpy(ptr, data->ioc_inlbuf3, data->ioc_inllen3);
- ptr += cfs_size_round(data->ioc_inllen3);
- }
-
- if (data->ioc_inlbuf4) {
- memcpy(ptr, data->ioc_inlbuf4, data->ioc_inllen4);
- ptr += cfs_size_round(data->ioc_inllen4);
- }
-
- if (obd_ioctl_is_invalid(overlay)) {
- fprintf(stderr, "invalid ioctl data: ioc_len = %u, "
- "max_len = %d\n",
- data->ioc_len, max_len);
- return -EINVAL;
- }
-
- return 0;
-}
-
-static inline int
-obd_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf, int max_len)
-{
- char *ptr;
- struct obd_ioctl_data *overlay;
-
- if (pbuf == NULL)
- return 1;
-
- overlay = (struct obd_ioctl_data *)pbuf;
-
- /* Preserve the caller's buffer pointers */
- overlay->ioc_inlbuf1 = data->ioc_inlbuf1;
- overlay->ioc_inlbuf2 = data->ioc_inlbuf2;
- overlay->ioc_inlbuf3 = data->ioc_inlbuf3;
- overlay->ioc_inlbuf4 = data->ioc_inlbuf4;
-
- memcpy(data, pbuf, sizeof(*data));
-
- ptr = overlay->ioc_bulk;
- if (data->ioc_inlbuf1) {
- memcpy(data->ioc_inlbuf1, ptr, data->ioc_inllen1);
- ptr += cfs_size_round(data->ioc_inllen1);
- }
-
- if (data->ioc_inlbuf2) {
- memcpy(data->ioc_inlbuf2, ptr, data->ioc_inllen2);
- ptr += cfs_size_round(data->ioc_inllen2);
- }
-
- if (data->ioc_inlbuf3) {
- memcpy(data->ioc_inlbuf3, ptr, data->ioc_inllen3);
- ptr += cfs_size_round(data->ioc_inllen3);
- }
-
- if (data->ioc_inlbuf4) {
- memcpy(data->ioc_inlbuf4, ptr, data->ioc_inllen4);
- ptr += cfs_size_round(data->ioc_inllen4);
- }
-
- return 0;
-}
-
-#endif /* !__KERNEL__ */
-
-/* OBD_IOC_DATA_TYPE is only for compatibility reasons with older
+/*
+ * OBD_IOC_DATA_TYPE is only for compatibility reasons with older
* Linux Lustre user tools. New ioctls should NOT use this macro as
* the ioctl "size". Instead the ioctl should get a "size" argument
* which is the actual data type used by the ioctl, to ensure the
- * ioctl interface is versioned correctly. */
+ * ioctl interface is versioned correctly.
+ */
#define OBD_IOC_DATA_TYPE long
/* IOC_LDLM_TEST _IOWR('f', 40, long) */
/* IOC_LDLM_REGRESS_STOP _IOWR('f', 43, long) */
#define OBD_IOC_CREATE _IOWR('f', 101, OBD_IOC_DATA_TYPE)
-#define OBD_IOC_DESTROY _IOW ('f', 104, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_DESTROY _IOW('f', 104, OBD_IOC_DATA_TYPE)
/* OBD_IOC_PREALLOCATE _IOWR('f', 105, OBD_IOC_DATA_TYPE) */
-#define OBD_IOC_SETATTR _IOW ('f', 107, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_SETATTR _IOW('f', 107, OBD_IOC_DATA_TYPE)
#define OBD_IOC_GETATTR _IOWR('f', 108, OBD_IOC_DATA_TYPE)
#define OBD_IOC_READ _IOWR('f', 109, OBD_IOC_DATA_TYPE)
#define OBD_IOC_WRITE _IOWR('f', 110, OBD_IOC_DATA_TYPE)
#define OBD_IOC_STATFS _IOWR('f', 113, OBD_IOC_DATA_TYPE)
-#define OBD_IOC_SYNC _IOW ('f', 114, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_SYNC _IOW('f', 114, OBD_IOC_DATA_TYPE)
/* OBD_IOC_READ2 _IOWR('f', 115, OBD_IOC_DATA_TYPE) */
/* OBD_IOC_FORMAT _IOWR('f', 116, OBD_IOC_DATA_TYPE) */
/* OBD_IOC_PARTITION _IOWR('f', 117, OBD_IOC_DATA_TYPE) */
#define OBD_IOC_NAME2DEV _IOWR('f', 127, OBD_IOC_DATA_TYPE)
#define OBD_IOC_UUID2DEV _IOWR('f', 130, OBD_IOC_DATA_TYPE)
#define OBD_IOC_GETNAME _IOWR('f', 131, OBD_IOC_DATA_TYPE)
-#define OBD_IOC_GETMDNAME _IOR ('f', 131, char[MAX_OBD_NAME])
+#define OBD_IOC_GETMDNAME _IOR('f', 131, char[MAX_OBD_NAME])
#define OBD_IOC_GETDTNAME OBD_IOC_GETNAME
#define OBD_IOC_LOV_GET_CONFIG _IOWR('f', 132, OBD_IOC_DATA_TYPE)
-#define OBD_IOC_CLIENT_RECOVER _IOW ('f', 133, OBD_IOC_DATA_TYPE)
-#define OBD_IOC_PING_TARGET _IOW ('f', 136, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_CLIENT_RECOVER _IOW('f', 133, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_PING_TARGET _IOW('f', 136, OBD_IOC_DATA_TYPE)
/* OBD_IOC_DEC_FS_USE_COUNT _IO('f', 139) */
-#define OBD_IOC_NO_TRANSNO _IOW ('f', 140, OBD_IOC_DATA_TYPE)
-#define OBD_IOC_SET_READONLY _IOW ('f', 141, OBD_IOC_DATA_TYPE)
-#define OBD_IOC_ABORT_RECOVERY _IOR ('f', 142, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_NO_TRANSNO _IOW('f', 140, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_SET_READONLY _IOW('f', 141, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_ABORT_RECOVERY _IOR('f', 142, OBD_IOC_DATA_TYPE)
/* OBD_IOC_ROOT_SQUASH _IOWR('f', 143, OBD_IOC_DATA_TYPE) */
#define OBD_GET_VERSION _IOWR('f', 144, OBD_IOC_DATA_TYPE)
/* OBD_IOC_GSS_SUPPORT _IOWR('f', 145, OBD_IOC_DATA_TYPE) */
/* OBD_IOC_CLOSE_UUID _IOWR('f', 147, OBD_IOC_DATA_TYPE) */
-/* OBD_IOC_CHANGELOG_SEND _IOW ('f', 148, OBD_IOC_DATA_TYPE) */
+/* OBD_IOC_CHANGELOG_SEND _IOW('f', 148, OBD_IOC_DATA_TYPE) */
#define OBD_IOC_GETDEVICE _IOWR('f', 149, OBD_IOC_DATA_TYPE)
#define OBD_IOC_FID2PATH _IOWR('f', 150, OBD_IOC_DATA_TYPE)
/* lustre/lustre_user.h 151-153 */
/* OBD_IOC_LOV_GETSTRIPE 155 LL_IOC_LOV_GETSTRIPE */
/* OBD_IOC_LOV_SETEA 156 LL_IOC_LOV_SETEA */
/* lustre/lustre_user.h 157-159 */
-/* OBD_IOC_QUOTACHECK _IOW ('f', 160, int) */
-/* OBD_IOC_POLL_QUOTACHECK _IOR ('f', 161, struct if_quotacheck *) */
+/* OBD_IOC_QUOTACHECK _IOW('f', 160, int) */
+/* OBD_IOC_POLL_QUOTACHECK _IOR('f', 161, struct if_quotacheck *) */
#define OBD_IOC_QUOTACTL _IOWR('f', 162, struct if_quotactl)
/* lustre/lustre_user.h 163-176 */
-#define OBD_IOC_CHANGELOG_REG _IOW ('f', 177, struct obd_ioctl_data)
-#define OBD_IOC_CHANGELOG_DEREG _IOW ('f', 178, struct obd_ioctl_data)
-#define OBD_IOC_CHANGELOG_CLEAR _IOW ('f', 179, struct obd_ioctl_data)
+#define OBD_IOC_CHANGELOG_REG _IOW('f', 177, struct obd_ioctl_data)
+#define OBD_IOC_CHANGELOG_DEREG _IOW('f', 178, struct obd_ioctl_data)
+#define OBD_IOC_CHANGELOG_CLEAR _IOW('f', 179, struct obd_ioctl_data)
/* OBD_IOC_RECORD _IOWR('f', 180, OBD_IOC_DATA_TYPE) */
/* OBD_IOC_ENDRECORD _IOWR('f', 181, OBD_IOC_DATA_TYPE) */
/* OBD_IOC_PARSE _IOWR('f', 182, OBD_IOC_DATA_TYPE) */
#define OBD_IOC_PROCESS_CFG _IOWR('f', 184, OBD_IOC_DATA_TYPE)
/* OBD_IOC_DUMP_LOG _IOWR('f', 185, OBD_IOC_DATA_TYPE) */
/* OBD_IOC_CLEAR_LOG _IOWR('f', 186, OBD_IOC_DATA_TYPE) */
-#define OBD_IOC_PARAM _IOW ('f', 187, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_PARAM _IOW('f', 187, OBD_IOC_DATA_TYPE)
#define OBD_IOC_POOL _IOWR('f', 188, OBD_IOC_DATA_TYPE)
#define OBD_IOC_REPLACE_NIDS _IOWR('f', 189, OBD_IOC_DATA_TYPE)
#define OBD_IOC_LCFG_FORK _IOWR('f', 208, OBD_IOC_DATA_TYPE)
#define OBD_IOC_LCFG_ERASE _IOWR('f', 209, OBD_IOC_DATA_TYPE)
-#define OBD_IOC_GET_OBJ_VERSION _IOR ('f', 210, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_GET_OBJ_VERSION _IOR('f', 210, OBD_IOC_DATA_TYPE)
/* lustre/lustre_user.h 212-217 */
-#define OBD_IOC_GET_MNTOPT _IOW ('f', 220, mntopt_t)
-#define OBD_IOC_ECHO_MD _IOR ('f', 221, struct obd_ioctl_data)
+#define OBD_IOC_GET_MNTOPT _IOW('f', 220, mntopt_t)
+#define OBD_IOC_ECHO_MD _IOR('f', 221, struct obd_ioctl_data)
#define OBD_IOC_ECHO_ALLOC_SEQ _IOWR('f', 222, struct obd_ioctl_data)
#define OBD_IOC_START_LFSCK _IOWR('f', 230, OBD_IOC_DATA_TYPE)
-#define OBD_IOC_STOP_LFSCK _IOW ('f', 231, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_STOP_LFSCK _IOW('f', 231, OBD_IOC_DATA_TYPE)
#define OBD_IOC_QUERY_LFSCK _IOR('f', 232, struct obd_ioctl_data)
/* lustre/lustre_user.h 240-249 */
/* LIBCFS_IOC_DEBUG_MASK 250 */
#define IOC_OSC_SET_ACTIVE _IOWR('h', 21, void *)
-#endif /* LUSTRE_IOCTL_H_ */
+#endif /* _UAPI_LUSTRE_IOCTL_H */
#include <obd_support.h>
#include <obd_class.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_lib.h>
#include <lustre_dlm.h>
#include <lustre_fid.h>
GOTO(out_free, rc);
}
out_free:
- obd_ioctl_freedata(buf, len);
+ OBD_FREE_LARGE(buf, len);
return rc;
}
case LL_IOC_LMV_SETSTRIPE: {
#endif
rc = ll_dir_setdirstripe(dentry, lum, filename, mode);
lmv_out_free:
- obd_ioctl_freedata(buf, len);
+ OBD_FREE_LARGE(buf, len);
RETURN(rc);
}
rc = ll_migrate(inode, file, mdtidx, filename, namelen - 1);
migrate_free:
- obd_ioctl_freedata(buf, len);
+ OBD_FREE_LARGE(buf, len);
RETURN(rc);
}
#endif
#include <lustre/ll_fiemap.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_swab.h>
#include "cl_object.h"
#endif
#include <linux/security.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_ha.h>
#include <lustre_dlm.h>
#include <lprocfs_status.h>
if (rc)
GOTO(out_statfs, rc);
out_statfs:
- if (buf)
- obd_ioctl_freedata(buf, len);
- return rc;
+ OBD_FREE_LARGE(buf, len);
+ return rc;
}
int ll_process_config(struct lustre_cfg *lcfg)
#include <lprocfs_status.h>
#include <cl_object.h>
#include <lustre_fid.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_kernelcomm.h>
#include "lmv_internal.h"
#include <cl_object.h>
#include <lustre_dlm.h>
#include <lustre_fid.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_lib.h>
#include <lustre_mds.h>
#include <lustre_net.h>
data = (struct obd_ioctl_data *)buf;
if (sizeof(*desc) > data->ioc_inllen1) {
- obd_ioctl_freedata(buf, len);
+ OBD_FREE_LARGE(buf, len);
RETURN(-EINVAL);
}
if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) {
- obd_ioctl_freedata(buf, len);
+ OBD_FREE_LARGE(buf, len);
RETURN(-EINVAL);
}
if (sizeof(__u32) * count > data->ioc_inllen3) {
- obd_ioctl_freedata(buf, len);
+ OBD_FREE_LARGE(buf, len);
RETURN(-EINVAL);
}
if (copy_to_user(uarg, buf, len))
rc = -EFAULT;
- obd_ioctl_freedata(buf, len);
+ OBD_FREE_LARGE(buf, len);
break;
}
case OBD_IOC_QUOTACTL: {
#include <lprocfs_status.h>
#include <lustre_acl.h>
#include <lustre_fid.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_kernelcomm.h>
#include <lustre_lmv.h>
#include <lustre_log.h>
#include <linux/module.h>
#include <linux/kthread.h>
#include <obd_class.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_mds.h>
#include <obd_support.h>
#include <lu_object.h>
#include <dt_object.h>
#include <lustre_acl.h>
#include <lustre_export.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_lfsck.h>
#include <lustre_log.h>
#include <lustre_net.h>
#define DEBUG_SUBSYSTEM S_MGS
#define D_MGS D_CONFIG
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_swab.h>
#include <lustre/lustre_barrier_user.h>
#include <obd_class.h>
#include <lprocfs_status.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_param.h>
#include <lustre/lustre_barrier_user.h>
#define D_MGS D_CONFIG
#include <obd.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_param.h>
#include <lustre_sec.h>
#include <lustre_quota.h>
# include <dt_object.h>
# include <md_object.h>
#endif /* HAVE_SERVER_SUPPORT */
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include "llog_internal.h"
#ifdef CONFIG_PROC_FS
memcpy(data->ioc_bulk, LUSTRE_VERSION_STRING,
strlen(LUSTRE_VERSION_STRING) + 1);
- err = obd_ioctl_popdata((void __user *)arg, data, len);
- if (err)
+ if (copy_to_user((void __user *)arg, data, len))
err = -EFAULT;
GOTO(out, err);
if (dev < 0)
GOTO(out, err = -EINVAL);
- err = obd_ioctl_popdata((void __user *)arg, data,
- sizeof(*data));
- if (err)
+ if (copy_to_user((void __user *)arg, data, sizeof(*data)))
err = -EFAULT;
GOTO(out, err);
}
CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1,
dev);
- err = obd_ioctl_popdata((void __user *)arg, data,
- sizeof(*data));
- if (err)
+ if (copy_to_user((void __user *)arg, data, sizeof(*data)))
err = -EFAULT;
GOTO(out, err);
}
(int)index, status, obd->obd_type->typ_name,
obd->obd_name, obd->obd_uuid.uuid,
atomic_read(&obd->obd_refcount));
- err = obd_ioctl_popdata((void __user *)arg, data, len);
- GOTO(out, err = 0);
+ if (copy_to_user((void __user *)arg, data, len))
+ err = -EFAULT;
+
+ GOTO(out, err);
}
}
if (err)
GOTO(out, err);
- err = obd_ioctl_popdata((void __user *)arg, data, len);
- if (err)
+ if (copy_to_user((void __user *)arg, data, len))
err = -EFAULT;
GOTO(out, err);
}
}
- out:
- if (buf)
- obd_ioctl_freedata(buf, len);
- RETURN(err);
+out:
+ OBD_FREE_LARGE(buf, len);
+ RETURN(err);
} /* class_handle_ioctl */
#define OBD_INIT_CHECK
#include <obd_class.h>
#include <lnet/lnetctl.h>
#include <lprocfs_status.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_ver.h>
+static int obd_ioctl_is_invalid(struct obd_ioctl_data *data)
+{
+ if (data->ioc_len > BIT(30)) {
+ CERROR("OBD ioctl: ioc_len larger than 1<<30\n");
+ return 1;
+ }
+
+ if (data->ioc_inllen1 > BIT(30)) {
+ CERROR("OBD ioctl: ioc_inllen1 larger than 1<<30\n");
+ return 1;
+ }
+
+ if (data->ioc_inllen2 > BIT(30)) {
+ CERROR("OBD ioctl: ioc_inllen2 larger than 1<<30\n");
+ return 1;
+ }
+
+ if (data->ioc_inllen3 > BIT(30)) {
+ CERROR("OBD ioctl: ioc_inllen3 larger than 1<<30\n");
+ return 1;
+ }
+
+ if (data->ioc_inllen4 > BIT(30)) {
+ CERROR("OBD ioctl: ioc_inllen4 larger than 1<<30\n");
+ return 1;
+ }
+
+ if (data->ioc_inlbuf1 && data->ioc_inllen1 == 0) {
+ CERROR("OBD ioctl: inlbuf1 pointer but 0 length\n");
+ return 1;
+ }
+
+ if (data->ioc_inlbuf2 && data->ioc_inllen2 == 0) {
+ CERROR("OBD ioctl: inlbuf2 pointer but 0 length\n");
+ return 1;
+ }
+
+ if (data->ioc_inlbuf3 && data->ioc_inllen3 == 0) {
+ CERROR("OBD ioctl: inlbuf3 pointer but 0 length\n");
+ return 1;
+ }
+
+ if (data->ioc_inlbuf4 && data->ioc_inllen4 == 0) {
+ CERROR("OBD ioctl: inlbuf4 pointer but 0 length\n");
+ return 1;
+ }
+
+ if (data->ioc_pbuf1 && data->ioc_plen1 == 0) {
+ CERROR("OBD ioctl: pbuf1 pointer but 0 length\n");
+ return 1;
+ }
+
+ if (data->ioc_pbuf2 && data->ioc_plen2 == 0) {
+ CERROR("OBD ioctl: pbuf2 pointer but 0 length\n");
+ return 1;
+ }
+
+ if (!data->ioc_pbuf1 && data->ioc_plen1 != 0) {
+ CERROR("OBD ioctl: plen1 set but NULL pointer\n");
+ return 1;
+ }
+
+ if (!data->ioc_pbuf2 && data->ioc_plen2 != 0) {
+ CERROR("OBD ioctl: plen2 set but NULL pointer\n");
+ return 1;
+ }
+
+ if (obd_ioctl_packlen(data) > data->ioc_len) {
+ CERROR("OBD ioctl: packlen exceeds ioc_len (%d > %d)\n",
+ obd_ioctl_packlen(data), data->ioc_len);
+ return 1;
+ }
+
+ return 0;
+}
+
/* buffer MUST be at least the size of obd_ioctl_hdr */
int obd_ioctl_getdata(char **buf, int *len, void __user *arg)
{
}
EXPORT_SYMBOL(obd_ioctl_getdata);
-int obd_ioctl_popdata(void __user *arg, void *data, int len)
-{
- int err;
- ENTRY;
-
- err = copy_to_user(arg, data, len) ? -EFAULT : 0;
- RETURN(err);
-}
-
/* opening /dev/obd */
static int obd_class_open(struct inode * inode, struct file * file)
{
#define DEBUG_SUBSYSTEM S_LOG
#include <obd_class.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_log.h>
#include "llog_internal.h"
#include <llog_swab.h>
#include <lprocfs_status.h>
#include <lustre_disk.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_log.h>
#include <lustre_param.h>
#include <obd_class.h>
#include <llog_swab.h>
#include <lustre_disk.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_log.h>
#include <lustre_param.h>
#include <obd.h>
#include <cl_object.h>
#include <lustre_fid.h>
#include <lustre_acl.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_net.h>
#ifdef HAVE_SERVER_SUPPORT
# include <md_object.h>
#include <lustre/lustre_idl.h>
#include "ofd_internal.h"
#include <obd_cksum.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_quota.h>
#include <lustre_lfsck.h>
#include <lustre_nodemap.h>
#include <lustre_dlm.h>
#include <lustre_fid.h>
#include <lustre_ha.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_net.h>
#include <lustre_obdo.h>
#include <lustre_param.h>
#include <linux/kthread.h>
-#include <lustre_ioctl.h>
+#include <uapi/linux/lustre_ioctl.h>
#include <lustre_log.h>
#include <lustre_obdo.h>
#include <lustre_param.h>
llapi_fid_test_LDADD=$(LIBLUSTREAPI)
sendfile_grouplock_LDADD=$(LIBLUSTREAPI)
swap_lock_test_LDADD=$(LIBLUSTREAPI)
+statmany_LDADD=$(LIBLUSTREAPI)
+statone_LDADD=$(LIBLUSTREAPI)
it_test_LDADD=$(LIBCFS)
rwv_LDADD=$(LIBCFS)
alarm_caught++;
}
-/* HAVE_LLAPI_FILE_LOOKUP is defined by liblustreapi.h if this function is
- * defined therein. Otherwise we can do the equivalent operation via ioctl
- * if we have access to a complete lustre build tree to get the various
- * definitions - then compile with USE_MDC_LOOKUP defined. */
-#if defined(HAVE_LLAPI_FILE_LOOKUP)
-#define HAVE_MDC_LOOKUP
-#elif defined(USE_MDC_LOOKUP)
-#include <config.h>
-#include <lustre_ioctl.h>
-
-int llapi_file_lookup(int dirfd, const char *name)
-{
- struct obd_ioctl_data data = { 0 };
- char rawbuf[8192];
- char *buf = rawbuf;
- int rc;
-
- if (dirfd < 0 || name == NULL)
- return -EINVAL;
-
- data.ioc_version = OBD_IOCTL_VERSION;
- data.ioc_len = sizeof(data);
- data.ioc_inlbuf1 = name;
- data.ioc_inllen1 = strlen(name) + 1;
-
- rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
- if (rc) {
- fatal(myrank, "ioctl_pack failed: rc = %d\n", rc);
- return rc;
- }
-
- return ioctl(fd, IOC_MDC_LOOKUP, buf);
-}
-#define HAVE_MDC_LOOKUP
-#endif
-
static void
process_args(int argc, char *argv[])
{
case OPEN:
openflags &= ~(O_CREAT|O_EXCL);
case CREATE:
-#ifdef HAVE_MDC_LOOKUP
case LOOKUP:
-#endif
case MKNOD:
case STAT:
case UNLINK:
(order == RANDOM) ? "random_order" : "readdir_order");
} else {
usage(stderr, "one --create, --mknod, --open, --stat,"
-#ifdef HAVE_MDC_LOOKUP
" --lookup,"
-#endif
" --unlink or --setxattr must be specifed.");
}
dmesg("%d: created %d files, last file '%s'.\n",
myrank, nops, filename);
break;
-#ifdef HAVE_MDC_LOOKUP
case LOOKUP:
fd = open(dir, O_RDONLY);
if (fd < 0) {
DISPLAY_PROGRESS();
}
break;
-#endif
case MKNOD:
for (; begin <= end && !alarm_caught; begin += dirthreads) {
snprintf(filename, sizeof(filename), filefmt, begin);
#include <unistd.h>
#include <time.h>
#include <limits.h>
-#include <sys/ioctl.h>
-#include <lustre_ioctl.h>
+#include <lustre/lustreapi.h>
struct option longopts[] = {
{ .name = "lookup", .has_arg = no_argument, .val = 'l' },
break;
}
} else if (mode == 'l') {
- struct obd_ioctl_data data;
- char rawbuf[8192];
- char *buf = rawbuf;
- int max = sizeof(rawbuf);
-
- memset(&data, 0, sizeof(data));
- data.ioc_version = OBD_IOCTL_VERSION;
- data.ioc_len = sizeof(data);
- if (offset >= 0)
- data.ioc_inlbuf1 = filename + offset;
- else
- data.ioc_inlbuf1 = filename;
- data.ioc_inllen1 = strlen(data.ioc_inlbuf1) + 1;
-
- if (obd_ioctl_pack(&data, &buf, max)) {
- printf("ioctl_pack failed.\n");
- break;
- }
+ char *name = filename;
- rc = ioctl(fd, IOC_MDC_LOOKUP, buf);
+ if (offset >= 0)
+ name += offset;
+
+ rc = llapi_file_lookup(fd, name);
if (rc < 0) {
- printf("ioctl(%s) error: %s\n", filename,
- strerror(errno));
+ printf("llapi_file_lookup for (%s) error: %s\n",
+ filename, strerror(errno));
break;
}
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <lustre_ioctl.h>
+#include <lustre/lustreapi.h>
int main(int argc, char **argv)
{
- struct obd_ioctl_data data = { 0 };
- char rawbuf[8192], parent[4096], *buf = rawbuf, *base, *t;
- int max = sizeof(rawbuf), fd, offset, rc;
+ char parent[4096], *base, *name, *t;
+ int fd, offset, rc;
if (argc != 2) {
printf("usage: %s filename\n", argv[0]);
exit(errno);
}
- data.ioc_version = OBD_IOCTL_VERSION;
- data.ioc_len = sizeof(data);
+ name = base;
if (offset >= 0)
- data.ioc_inlbuf1 = base + offset + 2;
- else
- data.ioc_inlbuf1 = base;
- data.ioc_inllen1 = strlen(data.ioc_inlbuf1) + 1;
-
- if (obd_ioctl_pack(&data, &buf, max)) {
- printf("ioctl_pack failed.\n");
- exit(1);
- }
-
- rc = ioctl(fd, IOC_MDC_LOOKUP, buf);
+ name += offset + 2;
+
+ rc = llapi_file_lookup(fd, name);
if (rc < 0) {
- printf("ioctl(%s/%s) error: %s\n", parent,
- data.ioc_inlbuf1, strerror(errno));
+ printf("llapi_file_lookup (%s/%s) error: %s\n", parent,
+ name, strerror(errno));
exit(errno);
}
#endif
#include <poll.h>
+#include <libcfs/util/ioctl.h>
#include <libcfs/util/param.h>
#include <libcfs/util/string.h>
#include <lnet/lnetctl.h>
#include <lustre/lustreapi.h>
#include <lustre/lustre_ostid.h>
-#include <lustre_ioctl.h>
+#include <linux/lustre_ioctl.h>
#include "lustreapi_internal.h"
static int llapi_msg_level = LLAPI_MSG_MAX;
return 0;
}
+int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf, int max_len)
+{
+ struct obd_ioctl_data *overlay;
+ char *ptr;
+
+ data->ioc_len = obd_ioctl_packlen(data);
+ data->ioc_version = OBD_IOCTL_VERSION;
+
+ if (*pbuf != NULL && data->ioc_len > max_len) {
+ fprintf(stderr, "pbuf = %p, ioc_len = %u, max_len = %d\n",
+ *pbuf, data->ioc_len, max_len);
+ return -EINVAL;
+ }
+
+ if (*pbuf == NULL)
+ *pbuf = malloc(data->ioc_len);
+
+ if (*pbuf == NULL)
+ return -ENOMEM;
+
+ overlay = (struct obd_ioctl_data *)*pbuf;
+ memcpy(*pbuf, data, sizeof(*data));
+
+ ptr = overlay->ioc_bulk;
+ if (data->ioc_inlbuf1) {
+ memcpy(ptr, data->ioc_inlbuf1, data->ioc_inllen1);
+ ptr += cfs_size_round(data->ioc_inllen1);
+ }
+
+ if (data->ioc_inlbuf2) {
+ memcpy(ptr, data->ioc_inlbuf2, data->ioc_inllen2);
+ ptr += cfs_size_round(data->ioc_inllen2);
+ }
+
+ if (data->ioc_inlbuf3) {
+ memcpy(ptr, data->ioc_inlbuf3, data->ioc_inllen3);
+ ptr += cfs_size_round(data->ioc_inllen3);
+ }
+
+ if (data->ioc_inlbuf4) {
+ memcpy(ptr, data->ioc_inlbuf4, data->ioc_inllen4);
+ ptr += cfs_size_round(data->ioc_inllen4);
+ }
+
+ return 0;
+}
+
+int obd_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf, int max_len)
+{
+ struct obd_ioctl_data *overlay;
+ char *ptr;
+
+ if (pbuf == NULL)
+ return 1;
+
+ overlay = (struct obd_ioctl_data *)pbuf;
+
+ /* Preserve the caller's buffer pointers */
+ overlay->ioc_inlbuf1 = data->ioc_inlbuf1;
+ overlay->ioc_inlbuf2 = data->ioc_inlbuf2;
+ overlay->ioc_inlbuf3 = data->ioc_inlbuf3;
+ overlay->ioc_inlbuf4 = data->ioc_inlbuf4;
+
+ memcpy(data, pbuf, sizeof(*data));
+
+ ptr = overlay->ioc_bulk;
+ if (data->ioc_inlbuf1) {
+ memcpy(data->ioc_inlbuf1, ptr, data->ioc_inllen1);
+ ptr += cfs_size_round(data->ioc_inllen1);
+ }
+
+ if (data->ioc_inlbuf2) {
+ memcpy(data->ioc_inlbuf2, ptr, data->ioc_inllen2);
+ ptr += cfs_size_round(data->ioc_inllen2);
+ }
+
+ if (data->ioc_inlbuf3) {
+ memcpy(data->ioc_inlbuf3, ptr, data->ioc_inllen3);
+ ptr += cfs_size_round(data->ioc_inllen3);
+ }
+
+ if (data->ioc_inlbuf4) {
+ memcpy(data->ioc_inlbuf4, ptr, data->ioc_inllen4);
+ ptr += cfs_size_round(data->ioc_inllen4);
+ }
+
+ return 0;
+}
+
/* XXX: llapi_xxx() functions return negative values upon failure */
int llapi_stripe_limit_check(unsigned long long stripe_size, int stripe_offset,
#include <ctype.h>
#include <libcfs/util/list.h>
-#include <lustre_ioctl.h>
+#include <libcfs/util/ioctl.h>
+#include <linux/lustre_ioctl.h>
#include <lustre/lustre_barrier_user.h>
#include "obdctl.h"
#include <stdarg.h>
#include <ctype.h>
+#include <libcfs/util/ioctl.h>
#include <libcfs/util/string.h>
#include <libcfs/util/param.h>
#include <libcfs/util/parser.h>
#include <lnet/nidstr.h>
#include <lustre_cfg.h>
-#include <lustre_ioctl.h>
+#include <linux/lustre_ioctl.h>
#include <lustre_ver.h>
#include <sys/un.h>
#include <time.h>
#include "obdctl.h"
+#include "lustreapi_internal.h"
#include <lustre/lustre_lfsck_user.h>
#include <lnet/lnetctl.h>
-#include <lustre_ioctl.h>
+#include <linux/lustre_ioctl.h>
/* Needs to be last to avoid clashes */
#include <libcfs/util/ioctl.h>
#include <libcfs/util/param.h>
#ifndef _LUSTREAPI_INTERNAL_H_
#define _LUSTREAPI_INTERNAL_H_
+#include <limits.h>
+#include <stdint.h>
+
+#include <libcfs/util/ioctl.h>
#include <libcfs/util/param.h>
+
+#include <linux/lustre_ioctl.h>
#include <uapi_kernelcomm.h>
#define WANT_PATH 0x1
int get_root_path(int want, char *fsname, int *outfd, char *path, int index);
int root_ioctl(const char *mdtname, int opc, void *data, int *mdtidxp,
int want_error);
+int obd_ioctl_pack(struct obd_ioctl_data *data, char **pbuf, int max_len);
+int obd_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf, int max_len);
int sattr_cache_get_defaults(const char *const fsname,
const char *const pathname, unsigned int *scount,
unsigned int *ssize, unsigned int *soffset);
#include <limits.h>
#include "obdctl.h"
+#include "lustreapi_internal.h"
#include <libcfs/util/list.h>
#include <libcfs/util/ioctl.h>
#include <libcfs/util/param.h>
#include <lnet/nidstr.h>
#include <lustre/lustre_ostid.h>
#include <lustre_cfg.h>
-#include <lustre_ioctl.h>
+#include <linux/lustre_ioctl.h>
#include <lustre_ver.h>
#include <lnet/lnetctl.h>