Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Jan 1999 23:53:25 -0500 (EST)
From:      Brian Feldman <green@unixhelp.org>
To:        freebsd-emulation@FreeBSD.ORG
Subject:   sendmsg() not working?!
Message-ID:  <Pine.BSF.4.05.9901082350060.19067-100000@janus.syracuse.net>

next in thread | raw e-mail | index | archive | help
  I'm working on getting WINE to play properly, using clone() and all,
but after resolving how to set the LDT (I added two new LINUX syscalls instead
of trying to fix the current Linux ldt syscall's stub), I run into a new block:
sendmsg() returns EINVAL (!) for some reason. I've got all the code in an
archive if anyone wants to try it, and I'm including the output with
my instrumentation added to it as well.

 Brian Feldman						  _ __  ___ ___ ___  
 green@unixhelp.org				      _ __ ___ | _ ) __|   \ 
		      http://www.freebsd.org/	 _ __ ___ ____ | _ \__ \ |) |
 FreeBSD: The Power to Serve!		   _ __ ___ ____ _____ |___/___/___/ 

/***********************************************************************
 *           CLIENT_SendRequest_v
 *
 * Send a request to the server.
 */
static void CLIENT_SendRequest_v( enum request req, int pass_fd,
                                  struct iovec *vec, int veclen )
{
    THDB *thdb = THREAD_Current();
#ifndef HAVE_MSGHDR_ACCRIGHTS
    struct cmsg_fd cmsg  = { sizeof(cmsg), SOL_SOCKET, SCM_RIGHTS, pass_fd };
#endif
    struct msghdr msghdr = { NULL, 0, vec, veclen, NULL, 0, 0};
    struct header head;
    int i, ret, len;

    assert( veclen > 0 );
    vec[0].iov_base = &head;
    vec[0].iov_len  = sizeof(head);
    for (i = len = 0; i < veclen; i++) len += vec[i].iov_len;

    assert( len <= MAX_MSG_LENGTH );
    head.type = req;
    head.len  = len;
    head.seq  = thdb->seq++;

    if (pass_fd != -1)  /* we have an fd to send */
    {
#ifdef HAVE_MSGHDR_ACCRIGHTS
        msghdr.msg_accrights = (void *)&pass_fd;
        msghdr.msg_accrightslen = sizeof(pass_fd);
#else
        msghdr.msg_control    = &cmsg;
        msghdr.msg_controllen = sizeof(cmsg);
#endif
    }

    printf("socket: %d\n"
	"struct msghdr:\n"
	"msg_name = %p\n"
	"msg_namelen = %d\n"
	"msg_iov = %p\n"
	"msg_iovlen = %d\n"
	"msg_control = %p\n"
	"msg_controllen = %d\n"
	"msg_flags = %d\n", thdb->socket, msghdr.msg_name, msghdr.msg_namelen,
	msghdr.msg_iov, msghdr.msg_iovlen, msghdr.msg_control,
	msghdr.msg_controllen, msghdr.msg_flags);
	
	{
	register struct iovec *iov = msghdr.msg_iov;
	int c;

	for (c = 0; c < msghdr.msg_iovlen; c++)
		printf("msghdr.msg_iov[%d].iov_base = %p\n"
			"msghdr.msg_iov[%d].iov_len = %d\n", c, iov[c].iov_base,
			c, iov[c].iov_len);
	
	}
    if ((ret = sendmsg( thdb->socket, &msghdr, 0 )) < len)
    {
        if (ret == -1) perror( "sendmsg" );
        CLIENT_ProtocolError( "partial msg sent %d/%d\n", ret, len );
    }
    /* we passed the fd now we can close it */
    if (pass_fd != -1) close( pass_fd );
}

{"/home/green/wine-990103"}$ ./wine
socket: 3
struct msghdr:
msg_name = (nil)
msg_namelen = 0
msg_iov = 0xefbfd6e8
msg_iovlen = 2
msg_control = 0xefbfd6b0
msg_controllen = 16
msg_flags = 0
msghdr.msg_iov[0].iov_base = 0xefbfd688
msghdr.msg_iov[0].iov_len = 12
msghdr.msg_iov[1].iov_base = 0xefbfd790
msghdr.msg_iov[1].iov_len = 4
sendmsg: Invalid argument
Client protocol error:(nil): partial msg sent -1/16
Memory fault (core dumped) 



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-emulation" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9901082350060.19067-100000>