• Sebastian Wick's avatar
    shared: add read-only anonymous file abstraction · 178f17e2
    Sebastian Wick authored
    The ro_anonymous_file is an abstraction around anonymous read-only files.
    os_ro_anonymous_file_create creates such a file with the contents passed
    in data. Subsequent calls to os_ro_anonymous_file_get_fd return a fd
    that's ready to be send over the socket.
    When mapmode is RO_ANONYMOUS_FILE_MAPMODE_PRIVATE the fd is only
    guaranteed to be mmap-able readonly with MAP_PRIVATE but does not
    require duplicating the file for each resource when memfd_create is
    available. RO_ANONYMOUS_FILE_MAPMODE_SHARED may be used when the client
    must be able to map the file with MAP_SHARED but it also means that the
    file has to be duplicated even when memfd_create is available.
    See also:
    weston commit 76829fc4
    wayland commit 905c0a341ddf0a885811d19e2b79c65a3f1d210c
    Signed-off-by: Sebastian Wick's avatarSebastian Wick <sebastian@sebastianwick.net>