Whamcloud - gitweb
LU-6068 misc: update Intel copyright messages 2014
[fs/lustre-release.git] / libcfs / libcfs / util / l_ioctl.c
index e27c404..89b1626 100644 (file)
@@ -1,6 +1,8 @@
 /*
  * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
  *
+ * Copyright (c) 2014, Intel Corporation.
+ *
  *   This file is part of Portals, http://www.sf.net/projects/lustre/
  *
  *   Portals is free software; you can redistribute it and/or
@@ -20,6 +22,8 @@
 
 #define __USE_FILE_OFFSET64
 
+#include <sys/ioctl.h>
+#include <sys/mman.h>
 #include <libcfs/libcfsutil.h>
 #include <lnet/lnetctl.h>
 
@@ -340,3 +344,21 @@ int libcfs_ioctl_pack(struct libcfs_ioctl_data *data, char **pbuf,
        return 0;
 }
 
+void
+libcfs_ioctl_unpack(struct libcfs_ioctl_data *data, char *pbuf)
+{
+       struct libcfs_ioctl_data *overlay = (struct libcfs_ioctl_data *)pbuf;
+       char *ptr;
+
+       /* Preserve the caller's buffer pointers */
+       overlay->ioc_inlbuf1 = data->ioc_inlbuf1;
+       overlay->ioc_inlbuf2 = data->ioc_inlbuf2;
+
+       memcpy(data, pbuf, sizeof(*data));
+       ptr = &overlay->ioc_bulk[0];
+
+       if (data->ioc_inlbuf1 != NULL)
+               LOGU(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
+       if (data->ioc_inlbuf2 != NULL)
+               LOGU(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
+}