Whamcloud - gitweb
LU-5577 libcfs: fix warnings in libcfs/curproc.h
[fs/lustre-release.git] / libcfs / include / libcfs / libcfs_ioctl.h
index 3fb0539..d895926 100644 (file)
@@ -49,6 +49,9 @@ struct libcfs_ioctl_hdr {
        __u32 ioc_version;
 };
 
+/** max size to copy from userspace */
+#define LIBCFS_IOC_DATA_MAX    (128 * 1024)
+
 struct libcfs_ioctl_data {
        struct libcfs_ioctl_hdr ioc_hdr;
 
@@ -66,16 +69,15 @@ struct libcfs_ioctl_data {
        char *ioc_inlbuf2;
 
        __u32 ioc_plen1; /* buffers in userspace */
-       char *ioc_pbuf1;
+       char __user *ioc_pbuf1;
        __u32 ioc_plen2; /* buffers in userspace */
-       char *ioc_pbuf2;
+       char __user *ioc_pbuf2;
 
        char ioc_bulk[0];
 };
 
 #define ioc_priority ioc_u32[0]
 
-
 struct libcfs_debug_ioctl_data
 {
        struct libcfs_ioctl_hdr hdr;
@@ -125,7 +127,6 @@ struct libcfs_ioctl_handler {
 #define IOC_LIBCFS_CLEAR_DEBUG             _IOWR('e', 31, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_MARK_DEBUG              _IOWR('e', 32, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_MEMHOG                  _IOWR('e', 36, IOCTL_LIBCFS_TYPE)
-#define IOC_LIBCFS_PING_TEST               _IOWR('e', 37, IOCTL_LIBCFS_TYPE)
 /* lnet ioctls */
 #define IOC_LIBCFS_GET_NI                 _IOWR('e', 50, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_FAIL_NID               _IOWR('e', 51, IOCTL_LIBCFS_TYPE)
@@ -138,6 +139,7 @@ struct libcfs_ioctl_handler {
 #define IOC_LIBCFS_PING                           _IOWR('e', 61, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_DEBUG_PEER             _IOWR('e', 62, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_LNETST                 _IOWR('e', 63, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_LNET_FAULT             _IOWR('e', 64, IOCTL_LIBCFS_TYPE)
 /* lnd ioctls */
 #define IOC_LIBCFS_REGISTER_MYNID         _IOWR('e', 70, IOCTL_LIBCFS_TYPE)
 #define IOC_LIBCFS_CLOSE_CONNECTION       _IOWR('e', 71, IOCTL_LIBCFS_TYPE)
@@ -251,11 +253,22 @@ static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
 
 extern int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
 extern int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
-extern int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr *buf, __u32 buf_len,
-                               const void __user *arg);
-extern int libcfs_ioctl_getdata_len(const struct libcfs_ioctl_hdr __user *arg,
-                                   __u32 *buf_len);
-extern int libcfs_ioctl_popdata(void *arg, void *buf, int size);
+extern int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
+                               struct libcfs_ioctl_hdr __user *uparam);
+
+static inline int libcfs_ioctl_popdata(struct libcfs_ioctl_hdr *hdr,
+                                      struct libcfs_ioctl_hdr __user *uparam)
+{
+        if (copy_to_user(uparam, hdr, hdr->ioc_len))
+               return -EFAULT;
+        return 0;
+}
+
+static inline void libcfs_ioctl_freedata(struct libcfs_ioctl_hdr *hdr)
+{
+       LIBCFS_FREE(hdr, hdr->ioc_len);
+}
+
 #endif
 
 extern int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);