Revision df0973a4

b/hw/virtio-9p-debug.c
502 502
        fprintf(llogfile, "RMKNOD: )");
503 503
        pprint_qid(pdu, 0, &offset, "qid");
504 504
        break;
505
    case P9_TREADLINK:
506
	fprintf(llogfile, "TREADLINK: (");
507
        pprint_int32(pdu, 0, &offset, "fid");
508
        break;
509
    case P9_RREADLINK:
510
	fprintf(llogfile, "RREADLINK: (");
511
        pprint_str(pdu, 0, &offset, "target");
512
        break;
505 513
    case P9_TREAD:
506 514
        fprintf(llogfile, "TREAD: (");
507 515
        pprint_int32(pdu, 0, &offset, "fid");
b/hw/virtio-9p.c
3520 3520
    qemu_free(vs);
3521 3521
}
3522 3522

  
3523
static void v9fs_readlink_post_readlink(V9fsState *s, V9fsReadLinkState *vs,
3524
                                                    int err)
3525
{
3526
    if (err < 0) {
3527
        err = -errno;
3528
        goto out;
3529
    }
3530
    vs->offset += pdu_marshal(vs->pdu, vs->offset, "s", &vs->target);
3531
    err = vs->offset;
3532
out:
3533
    complete_pdu(s, vs->pdu, err);
3534
    v9fs_string_free(&vs->target);
3535
    qemu_free(vs);
3536
}
3537

  
3538
static void v9fs_readlink(V9fsState *s, V9fsPDU *pdu)
3539
{
3540
    int32_t fid;
3541
    V9fsReadLinkState *vs;
3542
    int err = 0;
3543
    V9fsFidState *fidp;
3544

  
3545
    vs = qemu_malloc(sizeof(*vs));
3546
    vs->pdu = pdu;
3547
    vs->offset = 7;
3548

  
3549
    pdu_unmarshal(vs->pdu, vs->offset, "d", &fid);
3550

  
3551
    fidp = lookup_fid(s, fid);
3552
    if (fidp == NULL) {
3553
        err = -ENOENT;
3554
        goto out;
3555
    }
3556

  
3557
    v9fs_string_init(&vs->target);
3558
    err = v9fs_do_readlink(s, &fidp->path, &vs->target);
3559
    v9fs_readlink_post_readlink(s, vs, err);
3560
    return;
3561
out:
3562
    complete_pdu(s, vs->pdu, err);
3563
    qemu_free(vs);
3564
}
3565

  
3523 3566
typedef void (pdu_handler_t)(V9fsState *s, V9fsPDU *pdu);
3524 3567

  
3525 3568
static pdu_handler_t *pdu_handlers[] = {
......
3533 3576
    [P9_TRENAME] = v9fs_rename,
3534 3577
    [P9_TLOCK] = v9fs_lock,
3535 3578
    [P9_TGETLOCK] = v9fs_getlock,
3579
    [P9_TREADLINK] = v9fs_readlink,
3536 3580
    [P9_TMKDIR] = v9fs_mkdir,
3537 3581
    [P9_TVERSION] = v9fs_version,
3538 3582
    [P9_TLOPEN] = v9fs_open,
b/hw/virtio-9p.h
27 27
    P9_RMKNOD,
28 28
    P9_TRENAME = 20,
29 29
    P9_RRENAME,
30
    P9_TREADLINK = 22,
31
    P9_RREADLINK,
30 32
    P9_TGETATTR = 24,
31 33
    P9_RGETATTR,
32 34
    P9_TSETATTR = 26,
......
486 488
    V9fsGetlock *glock;
487 489
} V9fsGetlockState;
488 490

  
491
typedef struct V9fsReadLinkState
492
{
493
    V9fsPDU *pdu;
494
    size_t offset;
495
    V9fsString target;
496
} V9fsReadLinkState;
489 497

  
490 498
extern size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count,
491 499
                            size_t offset, size_t size, int pack);

Also available in: Unified diff