Add extended shared memory attach structure

This provides an extended version of `X_ShmAttachFd`, called
`X_ShmAttachFdExt`, which allows the client to specify two additional

1. The size of the mapping, in bytes.
2. The offset that should be passed to `mmap`, in bytes.

The intended use-case for this extension is when one needs to map
a drawable from a character special device, but it can also be
used with regular files if one needs to map with a nonzero offset.
Qubes OS needs the X server to map the `/dev/xen/gntdev` character
device, which represents memory shared from a different virtual
machine.  This is currently accomplished with an `LD_PRELOAD`’d
shared library that overrides `shmat`, `shmctl`, and `shmdt`, and
I have written a version that instead overrides `fstat` and `mmap`.
With this extension, the preloaded shared library will not be required.

Signed-off-by: Demi Marie Obenour <>
13 jobs for DemiMarie-master-patch-62720 in 1 minute and 19 seconds (queued for 4 seconds)