[PATCH 07/17] lxc_fuse: Prefer O_ACCMODE instead of & 3

Michal Privoznik mprivozn at redhat.com
Mon Mar 7 09:00:57 UTC 2022


In lxcProcOpen() we want to check whether the /proc/memfile is
being opened only for read. For that we check the fi->flags which
correspond to flags open() call. Instead of explicitly masking
the last two bits use O_ACCMODE constant, which is deemed to be
more portable.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/lxc/lxc_fuse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c
index b6b653e8cd..683d01525f 100644
--- a/src/lxc/lxc_fuse.c
+++ b/src/lxc/lxc_fuse.c
@@ -114,7 +114,7 @@ lxcProcOpen(const char *path,
     if (STRNEQ(path, fuse_meminfo_path))
         return -ENOENT;
 
-    if ((fi->flags & 3) != O_RDONLY)
+    if ((fi->flags & O_ACCMODE) != O_RDONLY)
         return -EACCES;
 
     return 0;
-- 
2.34.1



More information about the libvir-list mailing list