mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-04-05 11:30:41 +02:00
util/memfile: use MAP_SHARED to create the map
Using MAP_PRIVATE means copy-on-write so our data written into the map immediately disappears again. This leads to a empty string when sending a keymap to a client.
This commit is contained in:
parent
dc153c50ed
commit
6ea468c823
2 changed files with 8 additions and 2 deletions
|
|
@ -78,7 +78,7 @@ memfile_new(const char *data, size_t sz) {
|
|||
memfile->size = sz;
|
||||
fd = -1;
|
||||
|
||||
void *map = mmap(NULL, sz, PROT_READ|PROT_WRITE, MAP_PRIVATE, memfile->fd, 0);
|
||||
void *map = mmap(NULL, sz, PROT_READ|PROT_WRITE, MAP_SHARED, memfile->fd, 0);
|
||||
if (map == MAP_FAILED)
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,11 +31,13 @@
|
|||
#include "util-io.h"
|
||||
#include "util-munit.h"
|
||||
#include "util-memfile.h"
|
||||
#include "util-memmap.h"
|
||||
|
||||
#include "eierpecken.h"
|
||||
|
||||
#if HAVE_MEMFD_CREATE
|
||||
DEFINE_UNREF_CLEANUP_FUNC(memfile);
|
||||
DEFINE_UNREF_CLEANUP_FUNC(memmap);
|
||||
#endif
|
||||
|
||||
MUNIT_TEST(test_ei_device_basics)
|
||||
|
|
@ -1295,7 +1297,11 @@ MUNIT_TEST(test_ei_keymap_set)
|
|||
munit_assert_int(fd, !=, -1);
|
||||
munit_assert_uint(ei_keymap_get_size(ei_keymap), ==, memfile_get_size(fd1));
|
||||
munit_assert_uint(ei_keymap_get_type(ei_keymap), ==, EI_KEYMAP_TYPE_XKB);
|
||||
/* FIXME: read and compare buffer */
|
||||
|
||||
_unref_(memmap) *keymap = memmap_new(ei_keymap_get_fd(ei_keymap),
|
||||
ei_keymap_get_size(ei_keymap));
|
||||
char *buf = memmap_get_data(keymap);
|
||||
munit_assert_true(memcmp(buf, data, memmap_get_size(keymap)) == 0);
|
||||
ei_device_close(ei_device);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue