1
0
Fork 0

device-pool: Add way to open files read-only

Will be used by libinput's tablet device led device files.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
This commit is contained in:
Jonas Ådahl 2021-04-06 17:51:59 +02:00
parent a845a07a92
commit b4cf839e87
2 changed files with 10 additions and 1 deletions

View file

@ -247,9 +247,17 @@ meta_device_pool_open (MetaDevicePool *pool,
}
else
{
int open_flags;
if (flags & META_DEVICE_FILE_FLAG_READ_ONLY)
open_flags = O_RDONLY;
else
open_flags = O_RDWR;
open_flags |= O_CLOEXEC;
do
{
fd = open (path, O_RDWR | O_CLOEXEC);
fd = open (path, open_flags);
}
while (fd == -1 && errno == EINTR);

View file

@ -27,6 +27,7 @@ typedef enum _MetaDeviceFileFlags
{
META_DEVICE_FILE_FLAG_NONE = 0,
META_DEVICE_FILE_FLAG_TAKE_CONTROL = 1 << 0,
META_DEVICE_FILE_FLAG_READ_ONLY = 1 << 1,
} MetaDeviceFileFlags;
typedef struct _MetaDeviceFile MetaDeviceFile;