Revision 74bc02b2 hw/virtio-9p.c

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