只是尝试在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;
^
答案 0 :(得分:1)
编辑: IBM提供符合TPM 2.0标准的TPM模拟器,here
在git repo中,您链接了一个user对您的问题提出了修复请求。这对我有用(有一些我没有使用的空白修复。如果修补程序出现问题只需手动修改)。
--- 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: %d\n", 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: %d\n", 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,
};