VIR_LOG_INIT("util.file");
+#ifndef S_ISUID
+# define S_ISUID 04000
+#endif
+#ifndef S_ISGID
+# define S_ISGID 02000
+#endif
+#ifndef S_ISVTX
+# define S_ISVTX 01000
+#endif
+
+
#ifndef O_DIRECT
# define O_DIRECT 0
#endif
virFileWrapperFdFree(ret);
return NULL;
}
-#else
+#else /* WIN32 */
virFileWrapperFdPtr
virFileWrapperFdNew(int *fd G_GNUC_UNUSED,
const char *name G_GNUC_UNUSED,
_("virFileWrapperFd unsupported on this platform"));
return NULL;
}
-#endif
+#endif /* WIN32 */
/**
* virFileWrapperFdClose:
return flock(fd, LOCK_UN);
}
-#else
+#else /* WIN32 */
int virFileLock(int fd G_GNUC_UNUSED,
bool shared G_GNUC_UNUSED,
return -1;
}
-#endif
+#endif /* WIN32 */
int
if (g_lstat(linkpath, &st) < 0)
return -1;
+#ifndef WIN32
if (!S_ISLNK(st.st_mode)) {
*resultpath = g_strdup(linkpath);
return 0;
}
+#endif /* WIN32 */
}
*resultpath = virFileCanonicalizePath(linkpath);
{
GStatBuf st;
+ /* Still do this on Windows so we report
+ * errors like ENOENT, etc
+ */
if (g_lstat(linkpath, &st) < 0)
return -errno;
+#ifndef WIN32
return S_ISLNK(st.st_mode) != 0;
+#else /* WIN32 */
+ return 0;
+#endif /* WIN32 */
}
/*
virReportSystemError(errno, _("stat of '%s' failed"), path);
goto error;
}
+# ifndef WIN32
if (((uid != (uid_t) -1 && st.st_uid != uid) ||
(gid != (gid_t) -1 && st.st_gid != gid))
&& (chown(path, uid, gid) < 0)) {
path, (unsigned int) uid, (unsigned int) gid);
goto error;
}
+# endif /* !WIN32 */
if (mode != (mode_t) -1 && chmod(path, mode) < 0) {
ret = -errno;
virReportSystemError(errno,
*
* Returns -1 on error, with error already reported, 0 on success.
*/
+#ifndef WIN32
int virFileChownFiles(const char *name,
uid_t uid,
gid_t gid)
return ret;
}
+#else /* WIN32 */
+
+int virFileChownFiles(const char *name,
+ uid_t uid,
+ gid_t gid)
+{
+ virReportSystemError(ENOSYS,
+ _("cannot chown '%s' to (%u, %u)"),
+ name, (unsigned int) uid,
+ (unsigned int) gid);
+ return -1;
+}
+#endif /* WIN32 */
static int
virFileMakePathHelper(char *path, mode_t mode)