Revision 74bc02b2
b/hw/file-op-9p.h | ||
---|---|---|
52 | 52 |
int (*chmod)(FsContext *, const char *, FsCred *); |
53 | 53 |
int (*chown)(FsContext *, const char *, FsCred *); |
54 | 54 |
int (*mknod)(FsContext *, const char *, FsCred *); |
55 |
int (*utime)(FsContext *, const char *, const struct utimbuf *);
|
|
55 |
int (*utimensat)(FsContext *, const char *, const struct timespec *);
|
|
56 | 56 |
int (*remove)(FsContext *, const char *); |
57 | 57 |
int (*symlink)(FsContext *, const char *, const char *, FsCred *); |
58 | 58 |
int (*link)(FsContext *, const char *, const char *); |
b/hw/virtio-9p-local.c | ||
---|---|---|
450 | 450 |
return -1; |
451 | 451 |
} |
452 | 452 |
|
453 |
static int local_utime(FsContext *ctx, const char *path,
|
|
454 |
const struct utimbuf *buf)
|
|
453 |
static int local_utimensat(FsContext *s, const char *path,
|
|
454 |
const struct timespec *buf)
|
|
455 | 455 |
{ |
456 |
return utime(rpath(ctx, path), buf);
|
|
456 |
return utimensat(AT_FDCWD, rpath(s, path), buf, AT_SYMLINK_NOFOLLOW);
|
|
457 | 457 |
} |
458 | 458 |
|
459 | 459 |
static int local_remove(FsContext *ctx, const char *path) |
... | ... | |
495 | 495 |
.truncate = local_truncate, |
496 | 496 |
.rename = local_rename, |
497 | 497 |
.chown = local_chown, |
498 |
.utime = local_utime,
|
|
498 |
.utimensat = local_utimensat,
|
|
499 | 499 |
.remove = local_remove, |
500 | 500 |
.fsync = local_fsync, |
501 | 501 |
.statfs = local_statfs, |
b/hw/virtio-9p.c | ||
---|---|---|
237 | 237 |
return s->ops->chown(&s->ctx, path->data, &cred); |
238 | 238 |
} |
239 | 239 |
|
240 |
static int v9fs_do_utime(V9fsState *s, V9fsString *path, |
|
241 |
const struct utimbuf *buf) |
|
240 |
static int v9fs_do_utimensat(V9fsState *s, V9fsString *path, V9fsStat v9stat) |
|
242 | 241 |
{ |
243 |
return s->ops->utime(&s->ctx, path->data, buf); |
|
242 |
struct timespec ts[2]; |
|
243 |
|
|
244 |
if (v9stat.atime != -1) { |
|
245 |
ts[0].tv_sec = v9stat.atime; |
|
246 |
ts[0].tv_nsec = 0; |
|
247 |
} else { |
|
248 |
ts[0].tv_nsec = UTIME_OMIT; |
|
249 |
} |
|
250 |
|
|
251 |
if (v9stat.mtime != -1) { |
|
252 |
ts[1].tv_sec = v9stat.mtime; |
|
253 |
ts[1].tv_nsec = 0; |
|
254 |
} else { |
|
255 |
ts[1].tv_nsec = UTIME_OMIT; |
|
256 |
} |
|
257 |
|
|
258 |
return s->ops->utimensat(&s->ctx, path->data, ts); |
|
244 | 259 |
} |
245 | 260 |
|
246 | 261 |
static int v9fs_do_remove(V9fsState *s, V9fsString *path) |
... | ... | |
2325 | 2340 |
goto out; |
2326 | 2341 |
} |
2327 | 2342 |
|
2328 |
if (vs->v9stat.mtime != -1) { |
|
2329 |
struct utimbuf tb; |
|
2330 |
tb.actime = 0; |
|
2331 |
tb.modtime = vs->v9stat.mtime; |
|
2332 |
if (v9fs_do_utime(s, &vs->fidp->path, &tb)) { |
|
2343 |
if (vs->v9stat.mtime != -1 || vs->v9stat.atime != -1) { |
|
2344 |
if (v9fs_do_utimensat(s, &vs->fidp->path, vs->v9stat)) { |
|
2333 | 2345 |
err = -errno; |
2334 | 2346 |
} |
2335 | 2347 |
} |
Also available in: Unified diff