Commit 1b8328de authored by Demi Marie Obenour's avatar Demi Marie Obenour Committed by Demi Marie Obenour
Browse files

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.
parent a0ed054e
Pipeline #366250 passed with stages
in 1 minute and 23 seconds
......@@ -45,6 +45,7 @@ in this Software without prior written authorization from The Open Group.
#define X_ShmCreatePixmap 5
#define X_ShmAttachFd 6
#define X_ShmCreateSegment 7
#define X_ShmAttachFdExt 8
typedef struct _ShmQueryVersion {
CARD8 reqType; /* always ShmReqCode */
......@@ -220,6 +221,21 @@ typedef struct {
/* File descriptor is passed with this reply */
#define sz_xShmCreateSegmentReply 32
/* Version 1.3 additions */
typedef struct _ShmAttachFdExt {
CARD8 reqType; /* always ShmReqCode */
CARD8 shmReqType; /* always X_ShmAttachFdExt */
CARD16 length;
ShmSeg shmseg;
BOOL readOnly;
BYTE pad0;
CARD16 pad1;
CARD32 size; /* size of the buffer */
CARD64 offset; /* offset to pass to mmap() */
} xShmAttachFdExtReq;
/* File descriptor is passed with this request */
#define sz_xShmAttachFdExtReq 32
#undef ShmSeg
#undef Drawable
#undef VisualID
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment