[libvirt PATCH v2 23/56] src: stop using O_DIRECTORY in resctrl

Daniel P. Berrangé posted 56 patches 6 years ago
There is a newer version of this series
[libvirt PATCH v2 23/56] src: stop using O_DIRECTORY in resctrl
Posted by Daniel P. Berrangé 6 years ago
The O_DIRECTORY flag causes open() to return an error
if the filename is a directory. There's no obvious
reason why resctrl needs to use this, while the rest of
libvirt code does not. Removing it avoids build issues
on platforms where O_DIRECTORY is not defined, once we
remove GNULIB.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/util/virresctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
index 684d2ce398..e9bcdb44b1 100644
--- a/src/util/virresctrl.c
+++ b/src/util/virresctrl.c
@@ -455,7 +455,7 @@ VIR_ONCE_GLOBAL_INIT(virResctrl);
 static int
 virResctrlLockWrite(void)
 {
-    int fd = open(SYSFS_RESCTRL_PATH, O_DIRECTORY | O_CLOEXEC);
+    int fd = open(SYSFS_RESCTRL_PATH, O_RDWR | O_CLOEXEC);
 
     if (fd < 0) {
         virReportSystemError(errno, "%s", _("Cannot open resctrl"));
-- 
2.24.1

Re: [libvirt PATCH v2 23/56] src: stop using O_DIRECTORY in resctrl
Posted by Pavel Hrdina 6 years ago
On Tue, Jan 28, 2020 at 01:11:04PM +0000, Daniel P. Berrangé wrote:
> The O_DIRECTORY flag causes open() to return an error
> if the filename is a directory. There's no obvious
> reason why resctrl needs to use this, while the rest of
> libvirt code does not. Removing it avoids build issues
> on platforms where O_DIRECTORY is not defined, once we
> remove GNULIB.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  src/util/virresctrl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>