提交 ae0f940e 编写于 作者: P Paolo Bonzini 提交者: Anthony Liguori

9pfs: improve portability to older systems

Small requirements on "new" features have percolated to virtio-9p-local.c.
In particular, the utimensat wrapper actually only supports dirfd = AT_FDCWD
and flags = AT_SYMLINK_NOFOLLOW in the fallback code.  Remove the arguments
so that virtio-9p-local.c will not use AT_* constants.

At the same time, fail local_ioc_getversion if the ioctl is not supported
by the host.
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 13bd0b50
...@@ -583,8 +583,7 @@ static int local_utimensat(FsContext *s, V9fsPath *fs_path, ...@@ -583,8 +583,7 @@ static int local_utimensat(FsContext *s, V9fsPath *fs_path,
char buffer[PATH_MAX]; char buffer[PATH_MAX];
char *path = fs_path->data; char *path = fs_path->data;
return qemu_utimensat(AT_FDCWD, rpath(s, path, buffer), buf, return qemu_utimens(rpath(s, path, buffer), buf);
AT_SYMLINK_NOFOLLOW);
} }
static int local_remove(FsContext *ctx, const char *path) static int local_remove(FsContext *ctx, const char *path)
...@@ -694,6 +693,7 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, ...@@ -694,6 +693,7 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path,
mode_t st_mode, uint64_t *st_gen) mode_t st_mode, uint64_t *st_gen)
{ {
int err; int err;
#ifdef FS_IOC_GETVERSION
V9fsFidOpenState fid_open; V9fsFidOpenState fid_open;
/* /*
...@@ -709,6 +709,9 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, ...@@ -709,6 +709,9 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path,
} }
err = ioctl(fid_open.fd, FS_IOC_GETVERSION, st_gen); err = ioctl(fid_open.fd, FS_IOC_GETVERSION, st_gen);
local_close(ctx, &fid_open); local_close(ctx, &fid_open);
#else
err = -ENOTTY;
#endif
return err; return err;
} }
......
...@@ -162,8 +162,7 @@ int qemu_pipe(int pipefd[2]) ...@@ -162,8 +162,7 @@ int qemu_pipe(int pipefd[2])
return ret; return ret;
} }
int qemu_utimensat(int dirfd, const char *path, const struct timespec *times, int qemu_utimens(const char *path, const struct timespec *times)
int flags)
{ {
struct timeval tv[2], tv_now; struct timeval tv[2], tv_now;
struct stat st; struct stat st;
...@@ -171,7 +170,7 @@ int qemu_utimensat(int dirfd, const char *path, const struct timespec *times, ...@@ -171,7 +170,7 @@ int qemu_utimensat(int dirfd, const char *path, const struct timespec *times,
#ifdef CONFIG_UTIMENSAT #ifdef CONFIG_UTIMENSAT
int ret; int ret;
ret = utimensat(dirfd, path, times, flags); ret = utimensat(AT_FDCWD, path, times, AT_SYMLINK_NOFOLLOW);
if (ret != -1 || errno != ENOSYS) { if (ret != -1 || errno != ENOSYS) {
return ret; return ret;
} }
......
...@@ -44,7 +44,6 @@ typedef struct timeval qemu_timeval; ...@@ -44,7 +44,6 @@ typedef struct timeval qemu_timeval;
#endif #endif
#endif #endif
typedef struct timespec qemu_timespec; typedef struct timespec qemu_timespec;
int qemu_utimensat(int dirfd, const char *path, const qemu_timespec *times, int qemu_utimens(const char *path, const qemu_timespec *times);
int flags);
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册