user3272
user3272

Reputation: 103

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

I am writing unix socket in kernel module and when I try to compile, I get the following errors:

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

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

I try read the implementation of msghdr but I didn't find anything.

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

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

Upvotes: 1

Views: 2041

Answers (1)

red0ct
red0ct

Reputation: 5055

It seems that you use Linux kernel >= 3.19. Since 3.19 kernel struct msghdr is divided into struct msghdr and struct user_msghdr.

Now struct user_msghdr containes msg_iov and msg_iovlen. But struct iov_iter must be used instead of msg_iov and msg_iovlen.

Something like:

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() */

Upvotes: 2

Related Questions