Revision 7834cf77 hw/9pfs/virtio-9p.c

b/hw/9pfs/virtio-9p.c
2338 2338
    complete_pdu(pdu->s, pdu, err);
2339 2339
}
2340 2340

  
2341
static void v9fs_unlinkat(void *opaque)
2342
{
2343
    int err = 0;
2344
    V9fsString name;
2345
    int32_t dfid, flags;
2346
    size_t offset = 7;
2347
    V9fsFidState *dfidp;
2348
    V9fsPDU *pdu = opaque;
2349
    V9fsString full_name;
2350

  
2351
    pdu_unmarshal(pdu, offset, "dsd", &dfid, &name, &flags);
2352

  
2353
    dfidp = get_fid(pdu->s, dfid);
2354
    if (dfidp == NULL) {
2355
        err = -EINVAL;
2356
        goto out_nofid;
2357
    }
2358
    v9fs_string_init(&full_name);
2359
    v9fs_string_sprintf(&full_name, "%s/%s", dfidp->path.data, name.data);
2360
    /*
2361
     * IF the file is unlinked, we cannot reopen
2362
     * the file later. So don't reclaim fd
2363
     */
2364
    err = v9fs_mark_fids_unreclaim(pdu->s, &full_name);
2365
    if (err < 0) {
2366
        goto out_err;
2367
    }
2368
    err = v9fs_co_remove(pdu->s, &full_name);
2369
    if (!err) {
2370
        err = offset;
2371
    }
2372
out_err:
2373
    put_fid(pdu->s, dfidp);
2374
    v9fs_string_free(&full_name);
2375
out_nofid:
2376
    complete_pdu(pdu->s, pdu, err);
2377
    v9fs_string_free(&name);
2378
}
2379

  
2341 2380
static int v9fs_complete_rename(V9fsState *s, V9fsFidState *fidp,
2342 2381
                                int32_t newdirfid, V9fsString *name)
2343 2382
{
......
3040 3079
    [P9_TGETLOCK] = v9fs_getlock,
3041 3080
    [P9_TRENAMEAT] = v9fs_renameat,
3042 3081
    [P9_TREADLINK] = v9fs_readlink,
3082
    [P9_TUNLINKAT] = v9fs_unlinkat,
3043 3083
    [P9_TMKDIR] = v9fs_mkdir,
3044 3084
    [P9_TVERSION] = v9fs_version,
3045 3085
    [P9_TLOPEN] = v9fs_open,

Also available in: Unified diff