]> xenbits.xensource.com Git - libvirt.git/commitdiff
resctrl: Do not open directory for writing
authorMartin Kletzander <mkletzan@redhat.com>
Thu, 9 Jul 2020 07:27:41 +0000 (09:27 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 9 Jul 2020 11:45:01 +0000 (13:45 +0200)
When preparing for the removal of GNULIB commit 18dca21a32e9 removed the
unneeded O_DIRECTORY, but unfortunately started opening the directory for
writing which fails every time for a directory.  There is also no need for that
as flock() works on O_RDONLY file descriptor as well, even for LOCK_EX.

https://bugzilla.redhat.com/1852741

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
src/util/virresctrl.c

index e44f2ff30c84aa792e90dd2d2c8848125df8e179..3563fc560db5edc7ecd6d74b225b6691c5a4950d 100644 (file)
@@ -456,7 +456,7 @@ VIR_ONCE_GLOBAL_INIT(virResctrl);
 static int
 virResctrlLockWrite(void)
 {
-    int fd = open(SYSFS_RESCTRL_PATH, O_RDWR | O_CLOEXEC);
+    int fd = open(SYSFS_RESCTRL_PATH, O_RDONLY | O_CLOEXEC);
 
     if (fd < 0) {
         virReportSystemError(errno, "%s", _("Cannot open resctrl"));