[mutter] device-pool: Add way to open files read-only
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] device-pool: Add way to open files read-only
- Date: Wed, 7 Jul 2021 19:45:12 +0000 (UTC)
commit b4cf839e87db695f01a179d92c1ff47f134d5b27
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Tue Apr 6 17:51:59 2021 +0200
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>
src/backends/native/meta-device-pool.c | 10 +++++++++-
src/backends/native/meta-device-pool.h | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/backends/native/meta-device-pool.c b/src/backends/native/meta-device-pool.c
index 8aa2c194fc..ba1cdbaaad 100644
--- a/src/backends/native/meta-device-pool.c
+++ b/src/backends/native/meta-device-pool.c
@@ -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);
diff --git a/src/backends/native/meta-device-pool.h b/src/backends/native/meta-device-pool.h
index 5889ac7f17..f37fc7302c 100644
--- a/src/backends/native/meta-device-pool.h
+++ b/src/backends/native/meta-device-pool.h
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]