gpt4 book ai didi

c - 错误: ‘struct msghdr’ has no member named ‘msg_iov’

转载 作者:行者123 更新时间:2023-11-30 14:37:22 33 4
gpt4 key购买 nike

我正在内核模块中编写unix套接字,当我尝试编译时,出现以下错误:

error: ‘struct msghdr’ has no member named ‘msg_iov’

error: ‘struct msghdr’ has no member named ‘msg_iovlen’

我尝试阅读 msghdr 的实现,但没有找到任何内容。

ret = kernel_recvmsg(sock, msg, vec, BUFFER_SIZE, BUFFER_SIZE, 0);

msg_iov = msg->msg_iov;
msg_iovlen = msg->msg_iovlen;

最佳答案

看来您使用的 Linux 内核 >= 3.19。自 3.19 内核起 struct msghdr分为struct msghdrstruct user_msghdr

现在struct user_msghdr包含msg_iovmsg_iovlen。但是struct iov_iter必须使用 代替 msg_iovmsg_iovlen

类似于:

struct msghdr msg;
struct iovec iov;
iov.iov_base = buffer;
iov.iov_len = length;

/* fill in msg */

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
#else
iov_iter_init(&msg.msg_iter, READ, &iov, 1, length);
#endif

/* ... */
/* call sock_recvmsg() or kernel_recvmsg() */

关于c - 错误: ‘struct msghdr’ has no member named ‘msg_iov’ ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57388814/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com