[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 17/18] Compile fixes for Windows.
From: |
Michael Fritscher |
Subject: |
[Qemu-devel] [PATCH 17/18] Compile fixes for Windows. |
Date: |
Fri, 29 Sep 2017 13:13:22 +0200 |
Signed-off-by: Michael Fritscher <address@hidden>
---
hw/9pfs/9p-local.c | 50 +++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 45 insertions(+), 5 deletions(-)
diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index bf6fb70b81..afe07dd142 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -17,22 +17,26 @@
#include "9p-xattr.h"
#include "9p-util.h"
#include "fsdev/qemu-fsdev.h" /* local_ops */
+#ifndef _WIN32
#include <arpa/inet.h>
#include <pwd.h>
#include <grp.h>
#include <sys/socket.h>
#include <sys/un.h>
+#endif
#ifndef _WIN32
-# include "qemu/xattr.h"
+#include "qemu/xattr.h"
#endif
#include "qemu/cutils.h"
#include "qemu/error-report.h"
#include <libgen.h>
+#ifndef _WIN32
#include <linux/fs.h>
+#endif
#ifdef CONFIG_LINUX_MAGIC_H
#include <linux/magic.h>
-#endif
#include <sys/ioctl.h>
+#endif
#ifndef XFS_SUPER_MAGIC
#define XFS_SUPER_MAGIC 0x58465342
@@ -300,8 +304,10 @@ update_map_file:
map_fd = fileno(fp);
assert(map_fd != -1);
+#ifndef _WIN32
ret = fchmod(map_fd, 0600);
assert(ret == 0);
+#endif
if (credp->fc_uid != -1) {
uid = credp->fc_uid;
@@ -309,7 +315,8 @@ update_map_file:
if (credp->fc_gid != -1) {
gid = credp->fc_gid;
}
- if (credp->fc_mode != -1) {
+ /* On Windows it is unsigned... */
+ if ((int16_t)(credp->fc_mode) != -1) {
mode = credp->fc_mode;
}
if (credp->fc_rdev != -1) {
@@ -368,8 +375,12 @@ static int fchmodat_nofollow(int dirfd, const char *name,
mode_t mode)
if (fd == -1) {
return -1;
}
+#ifndef _WIN32
ret = fchmod(fd, mode);
#else
+ ret = 0;
+#endif
+#else
/* Access modes are ignored when O_PATH is supported. If name is a symbolic
* link, O_PATH | O_NOFOLLOW causes openat(2) to return a file descriptor
* referring to the symbolic link.
@@ -418,7 +429,8 @@ static int local_set_xattrat(int dirfd, const char *path,
FsCred *credp)
return err;
}
}
- if (credp->fc_mode != -1) {
+ /* On Windows it is unsigned... */
+ if ((int16_t)(credp->fc_mode) != -1) {
uint32_t tmp_mode = cpu_to_le32(credp->fc_mode);
err = fsetxattrat_nofollow(dirfd, path, "user.virtfs.mode", &tmp_mode,
sizeof(mode_t), 0);
@@ -518,8 +530,23 @@ static int local_open(FsContext *ctx, V9fsPath *fs_path,
static int local_opendir(FsContext *ctx,
V9fsPath *fs_path, V9fsFidOpenState *fs)
{
+ DIR *stream;
+/* there is no fdopendir available on Windows... */
+#ifdef _WIN32
+ char *buffer;
+ char *path = fs_path->data;
+
+ buffer = rpath(ctx, path);
+ error_printf("Directory (opendir) which should be opened: %s\n", buffer);
+ stream = opendir(buffer);
+ g_free(buffer);
+ if (!stream) {
+ return -1;
+ }
+ fs->dir.stream = stream;
+ return 0;
+#else
int dirfd;
- DIR *stream;
dirfd = local_opendir_nofollow(ctx, fs_path->data);
if (dirfd == -1) {
@@ -533,6 +560,7 @@ static int local_opendir(FsContext *ctx,
}
fs->dir.stream = stream;
return 0;
+#endif
}
static void local_rewinddir(FsContext *ctx, V9fsFidOpenState *fs)
@@ -562,13 +590,17 @@ again:
}
if (ctx->export_flags & V9FS_SM_MAPPED) {
+#ifndef _WIN32
entry->d_type = DT_UNKNOWN;
+#endif
} else if (ctx->export_flags & V9FS_SM_MAPPED_FILE) {
if (local_is_mapped_file_metadata(ctx, entry->d_name)) {
/* skip the meta data */
goto again;
}
+#ifndef _WIN32
entry->d_type = DT_UNKNOWN;
+#endif
}
return entry;
@@ -763,7 +795,11 @@ static int local_fstat(FsContext *fs_ctx, int fid_type,
int err, fd;
if (fid_type == P9_FID_DIR) {
+#ifndef _WIN32
fd = dirfd(fs->dir.stream);
+#else
+ fd = fs->fd;
+#endif
} else {
fd = fs->fd;
}
@@ -1161,7 +1197,11 @@ static int local_fsync(FsContext *ctx, int fid_type,
int fd;
if (fid_type == P9_FID_DIR) {
+#ifndef _WIN32
fd = dirfd(fs->dir.stream);
+#else
+ fd = fs->fd;
+#endif
} else {
fd = fs->fd;
}
--
2.13.2.windows.1
- [Qemu-devel] [PATCH 01/18] Add definitions needed by file-op-9p.h for Windows, (continued)
- [Qemu-devel] [PATCH 01/18] Add definitions needed by file-op-9p.h for Windows, Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 04/18] Don't include sys/resource.h on Windows., Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 08/18] Stub 9pfs xattr functions for Windows., Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 05/18] Add definitions for 9p.c., Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 06/18] Stub out functions for 9pfs., Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 14/18] Disable rlimit under Windows, Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 15/18] Fix unavailable fields in stbuf under Windows., Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 16/18] Workaround for missing dent->d_type/d_off under Windows, Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 07/18] Fix unused variable error and unsuded function if FS_IOC_GETVERSION is not defined., Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 02/18] #include <sys/vfs.h> is not available under Windows., Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 17/18] Compile fixes for Windows.,
Michael Fritscher <=
- [Qemu-devel] [PATCH 12/18] Buildfix in 9p-util.c., Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 18/18] Enable 9pfs for Windows in configure / makefiles, Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 11/18] Sete ctx->xops to null on Windows., Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 10/18] dirent has no d_off on Windows., Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 13/18] fsetxattrat_nofollow doesn't seem to be defined on Windows - disable it., Michael Fritscher, 2017/09/29
- [Qemu-devel] [PATCH 09/18] Dont initialize fields which aren't available on Windows., Michael Fritscher, 2017/09/29
- Re: [Qemu-devel] Make 9pfs buildable for Windows, Paolo Bonzini, 2017/09/29