Whamcloud - gitweb
LU-11304 misc: update all url links to whamcloud
[fs/lustre-release.git] / libcfs / libcfs / util / l_ioctl.c
index 4fa4ab1..f1676aa 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
  *
- * Copyright (c) 2014, Intel Corporation.
+ * Copyright (c) 2014, 2017, Intel Corporation.
  *
- *   This file is part of Portals, http://www.sf.net/projects/lustre/
+ *   This file is part of Lustre, https://wiki.whamcloud.com/
  *
  *   Portals is free software; you can redistribute it and/or
  *   modify it under the terms of version 2 of the GNU General Public
 #include <linux/types.h>
 
 #include <libcfs/util/ioctl.h>
-#include <lnet/lnetctl.h>
+#include <linux/lnet/lnetctl.h>
 
 struct ioc_dev {
-        const char * dev_name;
-        int dev_fd;
-        int dev_major;
-        int dev_minor;
+       const char *dev_name;
+       int dev_fd;
 };
 
 static struct ioc_dev ioc_dev_list[10];
 
-struct dump_hdr {
-        int magic;
-        int dev_id;
-        unsigned int opc;
-};
-
-/* Catamount has no <linux/kdev_t.h>, so just define it here */
-#ifndef MKDEV
-# define MKDEV(a,b) (((a) << 8) | (b))
-#endif
-
 static int
 open_ioc_dev(int dev_id)
 {
@@ -75,17 +62,6 @@ open_ioc_dev(int dev_id)
         if (ioc_dev_list[dev_id].dev_fd < 0) {
                int fd = open(dev_name, O_RDWR);
 
-               /* Make the /dev/ node if we need to */
-               if (fd < 0 && errno == ENOENT) {
-                       if (mknod(dev_name, S_IFCHR|S_IWUSR|S_IRUSR,
-                                 MKDEV(ioc_dev_list[dev_id].dev_major,
-                                       ioc_dev_list[dev_id].dev_minor)) == 0)
-                               fd = open(dev_name, O_RDWR);
-                        else
-                                fprintf(stderr, "mknod %s failed: %s\n",
-                                        dev_name, strerror(errno));
-                }
-
                 if (fd < 0) {
                         fprintf(stderr, "opening %s failed: %s\n"
                                 "hint: the kernel modules may not be loaded\n",
@@ -114,9 +90,8 @@ int l_ioctl(int dev_id, unsigned int opc, void *buf)
 
 /* register a device to send ioctls to.  */
 int
-register_ioc_dev(int dev_id, const char *dev_name, int major, int minor)
+register_ioc_dev(int dev_id, const char *dev_name)
 {
-
        if (dev_id < 0 ||
             dev_id >= sizeof(ioc_dev_list) / sizeof(ioc_dev_list[0]))
                 return -EINVAL;
@@ -125,8 +100,6 @@ register_ioc_dev(int dev_id, const char *dev_name, int major, int minor)
 
         ioc_dev_list[dev_id].dev_name = dev_name;
         ioc_dev_list[dev_id].dev_fd = -1;
-        ioc_dev_list[dev_id].dev_major = major;
-        ioc_dev_list[dev_id].dev_minor = minor;
 
         return dev_id;
 }
@@ -146,6 +119,15 @@ unregister_ioc_dev(int dev_id)
        ioc_dev_list[dev_id].dev_fd = -1;
 }
 
+static inline size_t libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
+{
+       size_t len = sizeof(*data);
+
+       len += (data->ioc_inllen1 + 7) & ~7;
+       len += (data->ioc_inllen2 + 7) & ~7;
+       return len;
+}
+
 int libcfs_ioctl_pack(struct libcfs_ioctl_data *data, char **pbuf,
                                     int max)
 {
@@ -175,9 +157,6 @@ int libcfs_ioctl_pack(struct libcfs_ioctl_data *data, char **pbuf,
                ptr += ((data->ioc_inllen2 + 7) & ~7);
        }
 
-       if (libcfs_ioctl_is_invalid(overlay))
-               return 1;
-
        return 0;
 }