qemu/hw/9pfs/virtio-9p-debug.c

647 lines
19 KiB
C
Raw Normal View History

/*
* Virtio 9p PDU debug
*
* Copyright IBM, Corp. 2010
*
* Authors:
* Anthony Liguori <aliguori@us.ibm.com>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*
*/
#include "hw/virtio.h"
#include "hw/pc.h"
#include "virtio-9p.h"
#include "virtio-9p-debug.h"
#define BUG_ON(cond) assert(!(cond))
static FILE *llogfile;
static struct iovec *get_sg(V9fsPDU *pdu, int rx)
{
if (rx) {
return pdu->elem.in_sg;
}
return pdu->elem.out_sg;
}
static int get_sg_count(V9fsPDU *pdu, int rx)
{
if (rx) {
return pdu->elem.in_num;
}
return pdu->elem.out_num;
}
static void pprint_int8(V9fsPDU *pdu, int rx, size_t *offsetp,
const char *name)
{
size_t copied;
int count = get_sg_count(pdu, rx);
size_t offset = *offsetp;
struct iovec *sg = get_sg(pdu, rx);
int8_t value;
copied = do_pdu_unpack(&value, sg, count, offset, sizeof(value));
BUG_ON(copied != sizeof(value));
offset += sizeof(value);
fprintf(llogfile, "%s=0x%x", name, value);
*offsetp = offset;
}
static void pprint_int16(V9fsPDU *pdu, int rx, size_t *offsetp,
const char *name)
{
size_t copied;
int count = get_sg_count(pdu, rx);
struct iovec *sg = get_sg(pdu, rx);
size_t offset = *offsetp;
int16_t value;
copied = do_pdu_unpack(&value, sg, count, offset, sizeof(value));
BUG_ON(copied != sizeof(value));
offset += sizeof(value);
fprintf(llogfile, "%s=0x%x", name, value);
*offsetp = offset;
}
static void pprint_int32(V9fsPDU *pdu, int rx, size_t *offsetp,
const char *name)
{
size_t copied;
int count = get_sg_count(pdu, rx);
struct iovec *sg = get_sg(pdu, rx);
size_t offset = *offsetp;
int32_t value;
copied = do_pdu_unpack(&value, sg, count, offset, sizeof(value));
BUG_ON(copied != sizeof(value));
offset += sizeof(value);
fprintf(llogfile, "%s=0x%x", name, value);
*offsetp = offset;
}
static void pprint_int64(V9fsPDU *pdu, int rx, size_t *offsetp,
const char *name)
{
size_t copied;
int count = get_sg_count(pdu, rx);
struct iovec *sg = get_sg(pdu, rx);
size_t offset = *offsetp;
int64_t value;
copied = do_pdu_unpack(&value, sg, count, offset, sizeof(value));
BUG_ON(copied != sizeof(value));
offset += sizeof(value);
fprintf(llogfile, "%s=0x%" PRIx64, name, value);
*offsetp = offset;
}
static void pprint_str(V9fsPDU *pdu, int rx, size_t *offsetp, const char *name)
{
int sg_count = get_sg_count(pdu, rx);
struct iovec *sg = get_sg(pdu, rx);
size_t offset = *offsetp;
uint16_t tmp_size, size;
size_t result;
size_t copied = 0;
int i = 0;
/* get the size */
copied = do_pdu_unpack(&tmp_size, sg, sg_count, offset, sizeof(tmp_size));
BUG_ON(copied != sizeof(tmp_size));
size = le16_to_cpupu(&tmp_size);
offset += copied;
fprintf(llogfile, "%s=", name);
for (i = 0; size && i < sg_count; i++) {
size_t len;
if (offset >= sg[i].iov_len) {
/* skip this sg */
offset -= sg[i].iov_len;
continue;
} else {
len = MIN(sg[i].iov_len - offset, size);
result = fwrite(sg[i].iov_base + offset, 1, len, llogfile);
BUG_ON(result != len);
size -= len;
copied += len;
if (size) {
offset = 0;
continue;
}
}
}
*offsetp += copied;
}
static void pprint_qid(V9fsPDU *pdu, int rx, size_t *offsetp, const char *name)
{
fprintf(llogfile, "%s={", name);
pprint_int8(pdu, rx, offsetp, "type");
pprint_int32(pdu, rx, offsetp, ", version");
pprint_int64(pdu, rx, offsetp, ", path");
fprintf(llogfile, "}");
}
static void pprint_stat(V9fsPDU *pdu, int rx, size_t *offsetp, const char *name)
{
fprintf(llogfile, "%s={", name);
pprint_int16(pdu, rx, offsetp, "size");
pprint_int16(pdu, rx, offsetp, ", type");
pprint_int32(pdu, rx, offsetp, ", dev");
pprint_qid(pdu, rx, offsetp, ", qid");
pprint_int32(pdu, rx, offsetp, ", mode");
pprint_int32(pdu, rx, offsetp, ", atime");
pprint_int32(pdu, rx, offsetp, ", mtime");
pprint_int64(pdu, rx, offsetp, ", length");
pprint_str(pdu, rx, offsetp, ", name");
pprint_str(pdu, rx, offsetp, ", uid");
pprint_str(pdu, rx, offsetp, ", gid");
pprint_str(pdu, rx, offsetp, ", muid");
pprint_str(pdu, rx, offsetp, ", extension");
pprint_int32(pdu, rx, offsetp, ", uid");
pprint_int32(pdu, rx, offsetp, ", gid");
pprint_int32(pdu, rx, offsetp, ", muid");
fprintf(llogfile, "}");
}
virtio-9p: getattr server implementation for 9P2000.L protocol. SYNOPSIS size[4] Tgetattr tag[2] fid[4] request_mask[8] size[4] Rgetattr tag[2] lstat[n] DESCRIPTION The getattr transaction inquires about the file identified by fid. request_mask is a bit mask that specifies which fields of the stat structure is the client interested in. The reply will contain a machine-independent directory entry, laid out as follows: st_result_mask[8] Bit mask that indicates which fields in the stat structure have been populated by the server qid.type[1] the type of the file (directory, etc.), represented as a bit vector corresponding to the high 8 bits of the file's mode word. qid.vers[4] version number for given path qid.path[8] the file server's unique identification for the file st_mode[4] Permission and flags st_uid[4] User id of owner st_gid[4] Group ID of owner st_nlink[8] Number of hard links st_rdev[8] Device ID (if special file) st_size[8] Size, in bytes st_blksize[8] Block size for file system IO st_blocks[8] Number of file system blocks allocated st_atime_sec[8] Time of last access, seconds st_atime_nsec[8] Time of last access, nanoseconds st_mtime_sec[8] Time of last modification, seconds st_mtime_nsec[8] Time of last modification, nanoseconds st_ctime_sec[8] Time of last status change, seconds st_ctime_nsec[8] Time of last status change, nanoseconds st_btime_sec[8] Time of creation (birth) of file, seconds st_btime_nsec[8] Time of creation (birth) of file, nanoseconds st_gen[8] Inode generation st_data_version[8] Data version number request_mask and result_mask bit masks contain the following bits #define P9_STATS_MODE 0x00000001ULL #define P9_STATS_NLINK 0x00000002ULL #define P9_STATS_UID 0x00000004ULL #define P9_STATS_GID 0x00000008ULL #define P9_STATS_RDEV 0x00000010ULL #define P9_STATS_ATIME 0x00000020ULL #define P9_STATS_MTIME 0x00000040ULL #define P9_STATS_CTIME 0x00000080ULL #define P9_STATS_INO 0x00000100ULL #define P9_STATS_SIZE 0x00000200ULL #define P9_STATS_BLOCKS 0x00000400ULL #define P9_STATS_BTIME 0x00000800ULL #define P9_STATS_GEN 0x00001000ULL #define P9_STATS_DATA_VERSION 0x00002000ULL #define P9_STATS_BASIC 0x000007ffULL #define P9_STATS_ALL 0x00003fffULL This patch implements the client side of getattr implementation for 9P2000.L. It introduces a new structure p9_stat_dotl for getting Linux stat information along with QID. The data layout is similar to stat structure in Linux user space with the following major differences: inode (st_ino) is not part of data. Instead qid is. device (st_dev) is not part of data because this doesn't make sense on the client. All time variables are 64 bit wide on the wire. The kernel seems to use 32 bit variables for these variables. However, some of the architectures have used 64 bit variables and glibc exposes 64 bit variables to user space on some architectures. Hence to be on the safer side we have made these 64 bit in the protocol. Refer to the comments in include/asm-generic/stat.h There are some additional fields: st_btime_sec, st_btime_nsec, st_gen, st_data_version apart from the bitmask, st_result_mask. The bit mask is filled by the server to indicate which stat fields have been populated by the server. Currently there is no clean way for the server to obtain these additional fields, so it sends back just the basic fields. Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com> Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
2010-07-20 10:14:41 +04:00
static void pprint_stat_dotl(V9fsPDU *pdu, int rx, size_t *offsetp,
const char *name)
{
fprintf(llogfile, "%s={", name);
pprint_qid(pdu, rx, offsetp, "qid");
pprint_int32(pdu, rx, offsetp, ", st_mode");
pprint_int64(pdu, rx, offsetp, ", st_nlink");
pprint_int32(pdu, rx, offsetp, ", st_uid");
pprint_int32(pdu, rx, offsetp, ", st_gid");
pprint_int64(pdu, rx, offsetp, ", st_rdev");
pprint_int64(pdu, rx, offsetp, ", st_size");
pprint_int64(pdu, rx, offsetp, ", st_blksize");
pprint_int64(pdu, rx, offsetp, ", st_blocks");
pprint_int64(pdu, rx, offsetp, ", atime");
pprint_int64(pdu, rx, offsetp, ", atime_nsec");
pprint_int64(pdu, rx, offsetp, ", mtime");
pprint_int64(pdu, rx, offsetp, ", mtime_nsec");
pprint_int64(pdu, rx, offsetp, ", ctime");
pprint_int64(pdu, rx, offsetp, ", ctime_nsec");
fprintf(llogfile, "}");
}
static void pprint_strs(V9fsPDU *pdu, int rx, size_t *offsetp, const char *name)
{
int sg_count = get_sg_count(pdu, rx);
struct iovec *sg = get_sg(pdu, rx);
size_t offset = *offsetp;
uint16_t tmp_count, count, i;
size_t copied = 0;
fprintf(llogfile, "%s={", name);
/* Get the count */
copied = do_pdu_unpack(&tmp_count, sg, sg_count, offset, sizeof(tmp_count));
BUG_ON(copied != sizeof(tmp_count));
count = le16_to_cpupu(&tmp_count);
offset += copied;
for (i = 0; i < count; i++) {
char str[512];
if (i) {
fprintf(llogfile, ", ");
}
snprintf(str, sizeof(str), "[%d]", i);
pprint_str(pdu, rx, &offset, str);
}
fprintf(llogfile, "}");
*offsetp = offset;
}
static void pprint_qids(V9fsPDU *pdu, int rx, size_t *offsetp, const char *name)
{
int sg_count = get_sg_count(pdu, rx);
struct iovec *sg = get_sg(pdu, rx);
size_t offset = *offsetp;
uint16_t tmp_count, count, i;
size_t copied = 0;
fprintf(llogfile, "%s={", name);
copied = do_pdu_unpack(&tmp_count, sg, sg_count, offset, sizeof(tmp_count));
BUG_ON(copied != sizeof(tmp_count));
count = le16_to_cpupu(&tmp_count);
offset += copied;
for (i = 0; i < count; i++) {
char str[512];
if (i) {
fprintf(llogfile, ", ");
}
snprintf(str, sizeof(str), "[%d]", i);
pprint_qid(pdu, rx, &offset, str);
}
fprintf(llogfile, "}");
*offsetp = offset;
}
static void pprint_sg(V9fsPDU *pdu, int rx, size_t *offsetp, const char *name)
{
struct iovec *sg = get_sg(pdu, rx);
unsigned int count;
int i;
if (rx) {
count = pdu->elem.in_num;
} else {
count = pdu->elem.out_num;
}
fprintf(llogfile, "%s={", name);
for (i = 0; i < count; i++) {
if (i) {
fprintf(llogfile, ", ");
}
fprintf(llogfile, "(%p, 0x%zx)", sg[i].iov_base, sg[i].iov_len);
}
fprintf(llogfile, "}");
}
/* FIXME: read from a directory fid returns serialized stat_t's */
#ifdef DEBUG_DATA
static void pprint_data(V9fsPDU *pdu, int rx, size_t *offsetp, const char *name)
{
struct iovec *sg = get_sg(pdu, rx);
size_t offset = *offsetp;
unsigned int count;
int32_t size;
int total, i, j;
ssize_t len;
if (rx) {
count = pdu->elem.in_num;
} else {
count = pdu->elem.out_num;
}
BUG_ON((offset + sizeof(size)) > sg[0].iov_len);
memcpy(&size, sg[0].iov_base + offset, sizeof(size));
offset += sizeof(size);
fprintf(llogfile, "size: %x\n", size);
sg[0].iov_base += 11; /* skip header */
sg[0].iov_len -= 11;
total = 0;
for (i = 0; i < count; i++) {
total += sg[i].iov_len;
if (total >= size) {
/* trim sg list so writev does the right thing */
sg[i].iov_len -= (total - size);
i++;
break;
}
}
fprintf(llogfile, "%s={\"", name);
fflush(llogfile);
for (j = 0; j < i; j++) {
if (j) {
fprintf(llogfile, "\", \"");
fflush(llogfile);
}
do {
len = writev(fileno(llogfile), &sg[j], 1);
} while (len == -1 && errno == EINTR);
fprintf(llogfile, "len == %ld: %m\n", len);
BUG_ON(len != sg[j].iov_len);
}
fprintf(llogfile, "\"}");
sg[0].iov_base -= 11;
sg[0].iov_len += 11;
}
#endif
void pprint_pdu(V9fsPDU *pdu)
{
size_t offset = 7;
if (llogfile == NULL) {
llogfile = fopen("/tmp/pdu.log", "w");
}
virtio-9p: Avoid SEGV when log file couldn't be opened While running in debug mode if 9P server is unable to open the log file it results in a SEGV deep down in glibc: Program received signal SIGSEGV, Segmentation fault. 0x008fca8c in fwrite () from /lib/libc.so.6 (gdb) bt #0 0x008fca8c in fwrite () from /lib/libc.so.6 #1 0x081eb87e in pprint_pdu (pdu=0x89a52e1c) at /data/sripathi/code/qemu/new/qemu-next-upstream/hw/virtio-9p-debug.c:380 #2 0x0806dad8 in submit_pdu (s=0x897dc008, pdu=0x89a52e1c) at /data/sripathi/code/qemu/new/qemu-next-upstream/hw/virtio-9p.c:3092 #3 0x0806dc63 in handle_9p_output (vdev=0x897dc008, vq=0x86d8218) at /data/sripathi/code/qemu/new/qemu-next-upstream/hw/virtio-9p.c:3122 #4 0x081ac728 in virtio_queue_notify (vdev=0x897dc008, n=0) at /data/sripathi/code/qemu/new/qemu-next-upstream/hw/virtio.c:563 #5 0x08063876 in virtio_ioport_write (opaque=0x86d7b98, addr=16, val=0) at /data/sripathi/code/qemu/new/qemu-next-upstream/hw/virtio-pci.c:222 #6 0x08063e26 in virtio_pci_config_writew (opaque=0x86d7b98, addr=16, val=0) at /data/sripathi/code/qemu/new/qemu-next-upstream/hw/virtio-pci.c:357 #7 0x080c881a in ioport_write (index=1, address=49296, data=0) at ioport.c:80 #8 0x080c8d4c in cpu_outw (addr=49296, val=0) at ioport.c:204 #9 0x08073010 in kvm_handle_io (port=49296, data=0xab393000, direction=1, size=2, count=1) at /data/sripathi/code/qemu/new/qemu-next-upstream/kvm-all.c:735 ... ... This is ugly and misleading. The following patch adds a BUG_ON to catch this error. With this patch we get an abort message like the following, which makes it easier to analyze: f12-kvm login: qemu: /data/sripathi/code/qemu/new/qemu-next-upstream/hw/virtio-9p-debug.c:353: pprint_pdu: Assertion `!(!llogfile)' failed. Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-30 15:02:00 +04:00
BUG_ON(!llogfile);
switch (pdu->id) {
case P9_TREADDIR:
fprintf(llogfile, "TREADDIR: (");
pprint_int32(pdu, 0, &offset, "fid");
pprint_int64(pdu, 0, &offset, ", initial offset");
pprint_int32(pdu, 0, &offset, ", max count");
break;
case P9_RREADDIR:
fprintf(llogfile, "RREADDIR: (");
pprint_int32(pdu, 1, &offset, "count");
#ifdef DEBUG_DATA
pprint_data(pdu, 1, &offset, ", data");
#endif
break;
case P9_TMKDIR:
fprintf(llogfile, "TMKDIR: (");
pprint_int32(pdu, 0, &offset, "fid");
pprint_str(pdu, 0, &offset, "name");
pprint_int32(pdu, 0, &offset, "mode");
pprint_int32(pdu, 0, &offset, "gid");
break;
case P9_RMKDIR:
fprintf(llogfile, "RMKDIR: (");
pprint_qid(pdu, 0, &offset, "qid");
break;
case P9_TVERSION:
fprintf(llogfile, "TVERSION: (");
pprint_int32(pdu, 0, &offset, "msize");
pprint_str(pdu, 0, &offset, ", version");
break;
case P9_RVERSION:
fprintf(llogfile, "RVERSION: (");
pprint_int32(pdu, 1, &offset, "msize");
pprint_str(pdu, 1, &offset, ", version");
break;
virtio-9p: getattr server implementation for 9P2000.L protocol. SYNOPSIS size[4] Tgetattr tag[2] fid[4] request_mask[8] size[4] Rgetattr tag[2] lstat[n] DESCRIPTION The getattr transaction inquires about the file identified by fid. request_mask is a bit mask that specifies which fields of the stat structure is the client interested in. The reply will contain a machine-independent directory entry, laid out as follows: st_result_mask[8] Bit mask that indicates which fields in the stat structure have been populated by the server qid.type[1] the type of the file (directory, etc.), represented as a bit vector corresponding to the high 8 bits of the file's mode word. qid.vers[4] version number for given path qid.path[8] the file server's unique identification for the file st_mode[4] Permission and flags st_uid[4] User id of owner st_gid[4] Group ID of owner st_nlink[8] Number of hard links st_rdev[8] Device ID (if special file) st_size[8] Size, in bytes st_blksize[8] Block size for file system IO st_blocks[8] Number of file system blocks allocated st_atime_sec[8] Time of last access, seconds st_atime_nsec[8] Time of last access, nanoseconds st_mtime_sec[8] Time of last modification, seconds st_mtime_nsec[8] Time of last modification, nanoseconds st_ctime_sec[8] Time of last status change, seconds st_ctime_nsec[8] Time of last status change, nanoseconds st_btime_sec[8] Time of creation (birth) of file, seconds st_btime_nsec[8] Time of creation (birth) of file, nanoseconds st_gen[8] Inode generation st_data_version[8] Data version number request_mask and result_mask bit masks contain the following bits #define P9_STATS_MODE 0x00000001ULL #define P9_STATS_NLINK 0x00000002ULL #define P9_STATS_UID 0x00000004ULL #define P9_STATS_GID 0x00000008ULL #define P9_STATS_RDEV 0x00000010ULL #define P9_STATS_ATIME 0x00000020ULL #define P9_STATS_MTIME 0x00000040ULL #define P9_STATS_CTIME 0x00000080ULL #define P9_STATS_INO 0x00000100ULL #define P9_STATS_SIZE 0x00000200ULL #define P9_STATS_BLOCKS 0x00000400ULL #define P9_STATS_BTIME 0x00000800ULL #define P9_STATS_GEN 0x00001000ULL #define P9_STATS_DATA_VERSION 0x00002000ULL #define P9_STATS_BASIC 0x000007ffULL #define P9_STATS_ALL 0x00003fffULL This patch implements the client side of getattr implementation for 9P2000.L. It introduces a new structure p9_stat_dotl for getting Linux stat information along with QID. The data layout is similar to stat structure in Linux user space with the following major differences: inode (st_ino) is not part of data. Instead qid is. device (st_dev) is not part of data because this doesn't make sense on the client. All time variables are 64 bit wide on the wire. The kernel seems to use 32 bit variables for these variables. However, some of the architectures have used 64 bit variables and glibc exposes 64 bit variables to user space on some architectures. Hence to be on the safer side we have made these 64 bit in the protocol. Refer to the comments in include/asm-generic/stat.h There are some additional fields: st_btime_sec, st_btime_nsec, st_gen, st_data_version apart from the bitmask, st_result_mask. The bit mask is filled by the server to indicate which stat fields have been populated by the server. Currently there is no clean way for the server to obtain these additional fields, so it sends back just the basic fields. Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com> Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
2010-07-20 10:14:41 +04:00
case P9_TGETATTR:
fprintf(llogfile, "TGETATTR: (");
pprint_int32(pdu, 0, &offset, "fid");
break;
case P9_RGETATTR:
fprintf(llogfile, "RGETATTR: (");
pprint_stat_dotl(pdu, 1, &offset, "getattr");
break;
case P9_TAUTH:
fprintf(llogfile, "TAUTH: (");
pprint_int32(pdu, 0, &offset, "afid");
pprint_str(pdu, 0, &offset, ", uname");
pprint_str(pdu, 0, &offset, ", aname");
pprint_int32(pdu, 0, &offset, ", n_uname");
break;
case P9_RAUTH:
fprintf(llogfile, "RAUTH: (");
pprint_qid(pdu, 1, &offset, "qid");
break;
case P9_TATTACH:
fprintf(llogfile, "TATTACH: (");
pprint_int32(pdu, 0, &offset, "fid");
pprint_int32(pdu, 0, &offset, ", afid");
pprint_str(pdu, 0, &offset, ", uname");
pprint_str(pdu, 0, &offset, ", aname");
pprint_int32(pdu, 0, &offset, ", n_uname");
break;
case P9_RATTACH:
fprintf(llogfile, "RATTACH: (");
pprint_qid(pdu, 1, &offset, "qid");
break;
case P9_TERROR:
fprintf(llogfile, "TERROR: (");
break;
case P9_RERROR:
fprintf(llogfile, "RERROR: (");
pprint_str(pdu, 1, &offset, "ename");
pprint_int32(pdu, 1, &offset, ", ecode");
break;
case P9_TFLUSH:
fprintf(llogfile, "TFLUSH: (");
pprint_int16(pdu, 0, &offset, "oldtag");
break;
case P9_RFLUSH:
fprintf(llogfile, "RFLUSH: (");
break;
case P9_TWALK:
fprintf(llogfile, "TWALK: (");
pprint_int32(pdu, 0, &offset, "fid");
pprint_int32(pdu, 0, &offset, ", newfid");
pprint_strs(pdu, 0, &offset, ", wnames");
break;
case P9_RWALK:
fprintf(llogfile, "RWALK: (");
pprint_qids(pdu, 1, &offset, "wqids");
break;
case P9_TOPEN:
fprintf(llogfile, "TOPEN: (");
pprint_int32(pdu, 0, &offset, "fid");
pprint_int8(pdu, 0, &offset, ", mode");
break;
case P9_ROPEN:
fprintf(llogfile, "ROPEN: (");
pprint_qid(pdu, 1, &offset, "qid");
pprint_int32(pdu, 1, &offset, ", iounit");
break;
case P9_TCREATE:
fprintf(llogfile, "TCREATE: (");
pprint_int32(pdu, 0, &offset, "fid");
pprint_str(pdu, 0, &offset, ", name");
pprint_int32(pdu, 0, &offset, ", perm");
pprint_int8(pdu, 0, &offset, ", mode");
pprint_str(pdu, 0, &offset, ", extension");
break;
case P9_RCREATE:
fprintf(llogfile, "RCREATE: (");
pprint_qid(pdu, 1, &offset, "qid");
pprint_int32(pdu, 1, &offset, ", iounit");
break;
case P9_TSYMLINK:
fprintf(llogfile, "TSYMLINK: (");
pprint_int32(pdu, 0, &offset, "fid");
pprint_str(pdu, 0, &offset, ", name");
pprint_str(pdu, 0, &offset, ", symname");
pprint_int32(pdu, 0, &offset, ", gid");
break;
case P9_RSYMLINK:
fprintf(llogfile, "RSYMLINK: (");
pprint_qid(pdu, 1, &offset, "qid");
break;
case P9_TLCREATE:
fprintf(llogfile, "TLCREATE: (");
pprint_int32(pdu, 0, &offset, "dfid");
pprint_str(pdu, 0, &offset, ", name");
pprint_int32(pdu, 0, &offset, ", flags");
pprint_int32(pdu, 0, &offset, ", mode");
pprint_int32(pdu, 0, &offset, ", gid");
break;
case P9_RLCREATE:
fprintf(llogfile, "RLCREATE: (");
pprint_qid(pdu, 1, &offset, "qid");
pprint_int32(pdu, 1, &offset, ", iounit");
break;
case P9_TMKNOD:
fprintf(llogfile, "TMKNOD: (");
pprint_int32(pdu, 0, &offset, "fid");
pprint_str(pdu, 0, &offset, "name");
pprint_int32(pdu, 0, &offset, "mode");
pprint_int32(pdu, 0, &offset, "major");
pprint_int32(pdu, 0, &offset, "minor");
pprint_int32(pdu, 0, &offset, "gid");
break;
case P9_RMKNOD:
fprintf(llogfile, "RMKNOD: )");
pprint_qid(pdu, 0, &offset, "qid");
break;
case P9_TREADLINK:
fprintf(llogfile, "TREADLINK: (");
pprint_int32(pdu, 0, &offset, "fid");
break;
case P9_RREADLINK:
fprintf(llogfile, "RREADLINK: (");
pprint_str(pdu, 0, &offset, "target");
break;
case P9_TREAD:
fprintf(llogfile, "TREAD: (");
pprint_int32(pdu, 0, &offset, "fid");
pprint_int64(pdu, 0, &offset, ", offset");
pprint_int32(pdu, 0, &offset, ", count");
pprint_sg(pdu, 0, &offset, ", sg");
break;
case P9_RREAD:
fprintf(llogfile, "RREAD: (");
pprint_int32(pdu, 1, &offset, "count");
pprint_sg(pdu, 1, &offset, ", sg");
offset = 7;
#ifdef DEBUG_DATA
pprint_data(pdu, 1, &offset, ", data");
#endif
break;
case P9_TWRITE:
fprintf(llogfile, "TWRITE: (");
pprint_int32(pdu, 0, &offset, "fid");
pprint_int64(pdu, 0, &offset, ", offset");
pprint_int32(pdu, 0, &offset, ", count");
break;
case P9_RWRITE:
fprintf(llogfile, "RWRITE: (");
pprint_int32(pdu, 1, &offset, "count");
break;
case P9_TCLUNK:
fprintf(llogfile, "TCLUNK: (");
pprint_int32(pdu, 0, &offset, "fid");
break;
case P9_RCLUNK:
fprintf(llogfile, "RCLUNK: (");
break;
case P9_TFSYNC:
fprintf(llogfile, "TFSYNC: (");
pprint_int32(pdu, 0, &offset, "fid");
break;
case P9_RFSYNC:
fprintf(llogfile, "RFSYNC: (");
break;
case P9_TLINK:
fprintf(llogfile, "TLINK: (");
pprint_int32(pdu, 0, &offset, "dfid");
pprint_int32(pdu, 0, &offset, ", fid");
pprint_str(pdu, 0, &offset, ", newpath");
break;
case P9_RLINK:
fprintf(llogfile, "RLINK: (");
break;
case P9_TREMOVE:
fprintf(llogfile, "TREMOVE: (");
pprint_int32(pdu, 0, &offset, "fid");
break;
case P9_RREMOVE:
fprintf(llogfile, "RREMOVE: (");
break;
case P9_TSTAT:
fprintf(llogfile, "TSTAT: (");
pprint_int32(pdu, 0, &offset, "fid");
break;
case P9_RSTAT:
fprintf(llogfile, "RSTAT: (");
offset += 2; /* ignored */
pprint_stat(pdu, 1, &offset, "stat");
break;
case P9_TWSTAT:
fprintf(llogfile, "TWSTAT: (");
pprint_int32(pdu, 0, &offset, "fid");
offset += 2; /* ignored */
pprint_stat(pdu, 0, &offset, ", stat");
break;
case P9_RWSTAT:
fprintf(llogfile, "RWSTAT: (");
break;
case P9_TXATTRWALK:
fprintf(llogfile, "TXATTRWALK: (");
pprint_int32(pdu, 0, &offset, "fid");
pprint_int32(pdu, 0, &offset, ", newfid");
pprint_str(pdu, 0, &offset, ", xattr name");
break;
case P9_RXATTRWALK:
fprintf(llogfile, "RXATTRWALK: (");
pprint_int64(pdu, 1, &offset, "xattrsize");
case P9_TXATTRCREATE:
fprintf(llogfile, "TXATTRCREATE: (");
pprint_int32(pdu, 0, &offset, "fid");
pprint_str(pdu, 0, &offset, ", name");
pprint_int64(pdu, 0, &offset, ", xattrsize");
pprint_int32(pdu, 0, &offset, ", flags");
break;
case P9_RXATTRCREATE:
fprintf(llogfile, "RXATTRCREATE: (");
break;
case P9_TLOCK:
fprintf(llogfile, "TLOCK: (");
pprint_int32(pdu, 0, &offset, "fid");
pprint_int8(pdu, 0, &offset, ", type");
pprint_int32(pdu, 0, &offset, ", flags");
pprint_int64(pdu, 0, &offset, ", start");
pprint_int64(pdu, 0, &offset, ", length");
pprint_int32(pdu, 0, &offset, ", proc_id");
pprint_str(pdu, 0, &offset, ", client_id");
break;
case P9_RLOCK:
fprintf(llogfile, "RLOCK: (");
pprint_int8(pdu, 0, &offset, "status");
break;
case P9_TGETLOCK:
fprintf(llogfile, "TGETLOCK: (");
pprint_int32(pdu, 0, &offset, "fid");
pprint_int8(pdu, 0, &offset, ", type");
pprint_int64(pdu, 0, &offset, ", start");
pprint_int64(pdu, 0, &offset, ", length");
pprint_int32(pdu, 0, &offset, ", proc_id");
pprint_str(pdu, 0, &offset, ", client_id");
break;
case P9_RGETLOCK:
fprintf(llogfile, "RGETLOCK: (");
pprint_int8(pdu, 0, &offset, "type");
pprint_int64(pdu, 0, &offset, ", start");
pprint_int64(pdu, 0, &offset, ", length");
pprint_int32(pdu, 0, &offset, ", proc_id");
pprint_str(pdu, 0, &offset, ", client_id");
break;
default:
fprintf(llogfile, "unknown(%d): (", pdu->id);
break;
}
fprintf(llogfile, ")\n");
/* Flush the log message out */
fflush(llogfile);
}