ncpfs: switch to sock_sendmsg()
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 10 Jan 2016 03:12:55 +0000 (22:12 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 27 Dec 2016 02:37:39 +0000 (21:37 -0500)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/ncpfs/sock.c

index a13c0b54f078e76c0558f5234561f4ab37719cc3..f013c92bb5d83e19731a4e06f88f6d3c6c075e90 100644 (file)
@@ -40,19 +40,12 @@ static int _recv(struct socket *sock, void *buf, int size, unsigned flags)
        return kernel_recvmsg(sock, &msg, &iov, 1, size, flags);
 }
 
-static inline int do_send(struct socket *sock, struct kvec *vec, int count,
-                         int len, unsigned flags)
-{
-       struct msghdr msg = { .msg_flags = flags };
-       return kernel_sendmsg(sock, &msg, vec, count, len);
-}
-
 static int _send(struct socket *sock, const void *buff, int len)
 {
-       struct kvec vec;
-       vec.iov_base = (void *) buff;
-       vec.iov_len = len;
-       return do_send(sock, &vec, 1, len, 0);
+       struct msghdr msg = { .msg_flags = 0 };
+       struct kvec vec = {.iov_base = (void *)buff, .iov_len = len};
+       iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &vec, 1, len);
+       return sock_sendmsg(sock, &msg);
 }
 
 struct ncp_request_reply {
@@ -345,18 +338,17 @@ static void __ncp_next_request(struct ncp_server *server)
 static void info_server(struct ncp_server *server, unsigned int id, const void * data, size_t len)
 {
        if (server->info_sock) {
-               struct kvec iov[2];
-               __be32 hdr[2];
-       
-               hdr[0] = cpu_to_be32(len + 8);
-               hdr[1] = cpu_to_be32(id);
-       
-               iov[0].iov_base = hdr;
-               iov[0].iov_len = 8;
-               iov[1].iov_base = (void *) data;
-               iov[1].iov_len = len;
+               struct msghdr msg = { .msg_flags = MSG_NOSIGNAL };
+               __be32 hdr[2] = {cpu_to_be32(len + 8), cpu_to_be32(id)};
+               struct kvec iov[2] = {
+                       {.iov_base = hdr, .iov_len = 8},
+                       {.iov_base = (void *)data, .iov_len = len},
+               };
+
+               iov_iter_kvec(&msg.msg_iter, ITER_KVEC | WRITE,
+                               iov, 2, len + 8);
 
-               do_send(server->info_sock, iov, 2, len + 8, MSG_NOSIGNAL);
+               sock_sendmsg(server->info_sock, &msg);
        }
 }