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:
parent
a845a07a92
commit
b4cf839e87
2 changed files with 10 additions and 1 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue