编译tpm模拟器错误



尝试在Ubuntu 32位下编译TPM-Emulator。设置export ARCH=i386,具有

tomasz@tomasz-VirtualBox:~/Git$ find /usr/include -name socket.h
/usr/include/asm-generic/socket.h
/usr/include/linux/socket.h
/usr/include/i386-linux-gnu/asm/socket.h
/usr/include/i386-linux-gnu/sys/socket.h
/usr/include/i386-linux-gnu/bits/socket.h

我得到了类似的错误

[ 98%] Generating linux/tpmd_dev.ko
/home/tomasz/Git/tpm-emulator/build/tpmd_dev/linux/tpmd_dev.c: In function ‘tpmd_handle_command’:
/home/tomasz/Git/tpm-emulator/build/tpmd_dev/linux/tpmd_dev.c:111:6: error: ‘struct msghdr’ has no member named ‘msg_iov’
   msg.msg_iov = &iov;
      ^

EDIT: IBM有一个兼容TPM 2.0的TPM模拟器,在这里

在git的repo中,你链接了一个用户为修复你的问题而发出的pull请求。这对我有用(有一些空白修复,我没有使用。如果补丁出现问题,请手动更改)。

--- tpmd_dev.c  2016-01-10 16:36:21.964858503 +0100
+++ tpmd_dev.c  2016-01-10 16:37:09.377204027 +0100
@@ -25,6 +25,8 @@
 #include <linux/net.h>
 #include <linux/un.h>
+#include <linux/version.h>
+
 #include "config.h"
 #define TPM_DEVICE_MINOR  224
@@ -81,7 +83,7 @@
   }
   addr.sun_family = AF_UNIX;
   strncpy(addr.sun_path, socket_name, sizeof(addr.sun_path));
-  res = tpmd_sock->ops->connect(tpmd_sock, 
+  res = tpmd_sock->ops->connect(tpmd_sock,
     (struct sockaddr*)&addr, sizeof(struct sockaddr_un), 0);
   if (res != 0) {
     error("sock_connect() failed: %dn", res);
@@ -108,9 +110,17 @@
   memset(&msg, 0, sizeof(msg));
   iov.iov_base = (void*)in;
   iov.iov_len = in_size;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
   msg.msg_iov = &iov;
   msg.msg_iovlen = 1;
+#else
+  iov_iter_init(&msg.msg_iter, WRITE, &iov, 1, 1);
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
   res = sock_sendmsg(tpmd_sock, &msg, in_size);
+#else
+  res = sock_sendmsg(tpmd_sock, &msg);
+#endif
   if (res < 0) {
     error("sock_sendmsg() failed: %dn", res);
     return res;
@@ -122,8 +132,12 @@
   memset(&msg, 0, sizeof(msg));
   iov.iov_base = (void*)tpm_response.data;
   iov.iov_len = tpm_response.size;
-  msg.msg_iov = &iov;
-  msg.msg_iovlen = 1;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
+   msg.msg_iov = &iov;
+   msg.msg_iovlen = 1;
+#else
+  iov_iter_init(&msg.msg_iter, WRITE, &iov, 1, 1);
+#endif
   oldmm = get_fs();
   set_fs(KERNEL_DS);
   res = sock_recvmsg(tpmd_sock, &msg, tpm_response.size, 0);
@@ -194,7 +208,7 @@
     kfree(tpm_response.data);
     tpm_response.data = NULL;
   }
-  if (tpmd_handle_command(buf, count) != 0) { 
+  if (tpmd_handle_command(buf, count) != 0) {
     count = -EILSEQ;
     tpm_response.data = NULL;
   }
@@ -241,8 +255,8 @@
 };
 static struct miscdevice tpm_dev = {
-  .minor      = TPM_DEVICE_MINOR, 
-  .name       = TPM_DEVICE_ID, 
+  .minor      = TPM_DEVICE_MINOR,
+  .name       = TPM_DEVICE_ID,
   .fops       = &fops,
 };

相关内容

  • 没有找到相关文章

最新更新