diff --git a/src/backends/native/meta-device-pool.c b/src/backends/native/meta-device-pool.c index 8aa2c194f..ba1cdbaaa 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 5889ac7f1..f37fc7302 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;