Revision f7613bee

b/hw/file-op-9p.h
50 50
    int (*lstat)(FsContext *, const char *, struct stat *);
51 51
    ssize_t (*readlink)(FsContext *, const char *, char *, size_t);
52 52
    int (*chmod)(FsContext *, const char *, FsCred *);
53
    int (*chown)(FsContext *, const char *, uid_t, gid_t);
53
    int (*chown)(FsContext *, const char *, FsCred *);
54 54
    int (*mknod)(FsContext *, const char *, mode_t, dev_t);
55 55
    int (*mksock)(FsContext *, const char *);
56 56
    int (*utime)(FsContext *, const char *, const struct utimbuf *);
b/hw/virtio-9p-local.c
240 240

  
241 241
}
242 242

  
243
static int local_chown(FsContext *ctx, const char *path, uid_t uid, gid_t gid)
243
static int local_chown(FsContext *fs_ctx, const char *path, FsCred *credp)
244 244
{
245
    return chown(rpath(ctx, path), uid, gid);
245
    if (fs_ctx->fs_sm == SM_MAPPED) {
246
        return local_set_xattr(rpath(fs_ctx, path), credp);
247
    } else if (fs_ctx->fs_sm == SM_PASSTHROUGH) {
248
        return lchown(rpath(fs_ctx, path), credp->fc_uid, credp->fc_gid);
249
    }
250
    return -1;
246 251
}
247 252

  
248 253
static int local_utime(FsContext *ctx, const char *path,
b/hw/virtio-9p.c
209 209

  
210 210
static int v9fs_do_chown(V9fsState *s, V9fsString *path, uid_t uid, gid_t gid)
211 211
{
212
    return s->ops->chown(&s->ctx, path->data, uid, gid);
212
    FsCred cred;
213
    cred_init(&cred);
214
    cred.fc_uid = uid;
215
    cred.fc_gid = gid;
216

  
217
    return s->ops->chown(&s->ctx, path->data, &cred);
213 218
}
214 219

  
215 220
static int v9fs_do_utime(V9fsState *s, V9fsString *path,
......
2014 2019
        goto out;
2015 2020
    }
2016 2021

  
2017
    if (vs->v9stat.n_gid != -1) {
2022
    if (vs->v9stat.n_gid != -1 || vs->v9stat.n_uid != -1) {
2018 2023
        if (v9fs_do_chown(s, &vs->fidp->path, vs->v9stat.n_uid,
2019 2024
                    vs->v9stat.n_gid)) {
2020 2025
            err = -errno;

Also available in: Unified diff