virFileFindMountPoint;
virFileFindResource;
virFileFindResourceFull;
-virFileFlock;
virFileFreeACLs;
virFileGetACLs;
virFileGetDefaultHugepage;
}
-/**
- * virFileFlock:
- * @fd: file descriptor to call flock on
- * @lock: true for lock, false for unlock
- * @shared: true if shared, false for exclusive, ignored if `@lock == false`
- *
- * This is just a simple wrapper around flock(2) that errors out on unsupported
- * platforms.
- *
- * The lock will be released when @fd is closed or this function is called with
- * `@lock == false`.
- *
- * Returns 0 on success, -1 otherwise (with errno set)
- */
-int virFileFlock(int fd, bool lock, bool shared)
-{
- if (lock)
- return flock(fd, shared ? LOCK_SH : LOCK_EX);
-
- return flock(fd, LOCK_UN);
-}
-
#else /* WIN32 */
+
int virFileLock(int fd G_GNUC_UNUSED,
bool shared G_GNUC_UNUSED,
off_t start G_GNUC_UNUSED,
}
-int virFileFlock(int fd G_GNUC_UNUSED,
- bool lock G_GNUC_UNUSED,
- bool shared G_GNUC_UNUSED)
-{
- errno = ENOSYS;
- return -1;
-}
-
#endif /* WIN32 */
int virFileUnlock(int fd, off_t start, off_t len)
G_GNUC_NO_INLINE;
-int virFileFlock(int fd, bool lock, bool shared);
-
typedef int (*virFileRewriteFunc)(int fd, const void *opaque);
int virFileRewrite(const char *path,
mode_t mode,
/* Common functions */
+#ifndef WIN32
+
static int
virResctrlLockWrite(void)
{
return -1;
}
- if (virFileFlock(fd, true, false) < 0) {
+ if (flock(fd, LOCK_EX) < 0) {
virReportSystemError(errno, "%s", _("Cannot lock resctrl"));
VIR_FORCE_CLOSE(fd);
return -1;
virReportSystemError(errno, "%s", _("Cannot close resctrl"));
/* Trying to save the already broken */
- if (virFileFlock(fd, false, false) < 0)
+ if (flock(fd, LOCK_UN) < 0)
virReportSystemError(errno, "%s", _("Cannot unlock resctrl"));
return -1;
return 0;
}
+#else /* WIN32 */
+
+static int
+virResctrlLockWrite(void)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("resctrl locking is not supported "
+ "on this platform"));
+ return -1;
+}
+
+
+static int
+virResctrlUnlock(int fd G_GNUC_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("resctrl locking is not supported "
+ "on this platform"));
+ return -1;
+}
+
+#endif /* WIN32 */
+
/* virResctrlInfo-related definitions */
static int