]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
lxc_fuse: Prefer O_ACCMODE instead of & 3
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 28 Feb 2022 11:53:39 +0000 (12:53 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 7 Mar 2022 13:01:48 +0000 (14:01 +0100)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/lxc/lxc_fuse.c

index b6b653e8cd0f3850f4cdeb27b95f3c9ff2dbf922..683d01525fdf290fc3eef1dbed7f8d987979342d 100644 (file)
@@ -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;