[PATCH 08/10] Add support for MIT-SHM AttachFd request

Mark Kettenis mark.kettenis at xs4all.nl
Fri Nov 1 20:52:14 CET 2013


> From: Keith Packard <keithp at keithp.com>
> Date: Thu, 31 Oct 2013 15:43:40 -0700
> 
> This passes a file descriptor from the client to the server, which is
> then mmap'd
> 
> +static int
> +ProcShmCreateSegment(ClientPtr client)
> +{
> +    int fd;
> +    ShmDescPtr shmdesc;
> +    REQUEST(xShmCreateSegmentReq);
> +    xShmCreateSegmentReply rep = {
> +        .type = X_Reply,
> +        .nfd = 1,
> +        .sequenceNumber = client->sequence,
> +        .length = 0,
> +    };
> +    char template[] = "/tmp/shm-XXXXXX";
> +
> +    REQUEST_SIZE_MATCH(xShmCreateSegmentReq);
> +    if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) {
> +        client->errorValue = stuff->readOnly;
> +        return BadValue;
> +    }
> +    fd = mkstemp(template);

Might make sense to use shm_mkstemp() here, but it seems that's an
OpenBSD-ism even though Debian has a bug report for it long before we
added it ;).


More information about the xorg-devel mailing list