aboutsummaryrefslogtreecommitdiffstats
path: root/net/9p
diff options
context:
space:
mode:
authorEric Van Hensbergen <ericvh@gmail.com>2011-06-19 17:38:21 -0400
committerEric Van Hensbergen <ericvh@gmail.com>2011-07-23 10:32:47 -0400
commite660a828f017991468ce322742586e8ebb047ae6 (patch)
tree1b1353fd7e7e87acd544956665515071228bfc1e /net/9p
parent2053d67c5451d92a3ddf58d944e1d6b0efc9c419 (diff)
9p: clean up packet dump code
Switch to generic kernel hexdump library and cleanup macros to be more consistent with the way we do normal debug prints. Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net/9p')
-rw-r--r--net/9p/client.c39
-rw-r--r--net/9p/protocol.c44
2 files changed, 37 insertions, 46 deletions
diff --git a/net/9p/client.c b/net/9p/client.c
index 81e667b6bbbd..332f97e0385e 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -750,7 +750,7 @@ static int p9_client_version(struct p9_client *c)
750 err = p9pdu_readf(req->rc, c->proto_version, "ds", &msize, &version); 750 err = p9pdu_readf(req->rc, c->proto_version, "ds", &msize, &version);
751 if (err) { 751 if (err) {
752 P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err); 752 P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err);
753 p9pdu_dump(1, req->rc); 753 P9_DUMP_PKT(1, req->rc);
754 goto error; 754 goto error;
755 } 755 }
756 756
@@ -912,7 +912,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
912 912
913 err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid); 913 err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid);
914 if (err) { 914 if (err) {
915 p9pdu_dump(1, req->rc); 915 P9_DUMP_PKT(1, req->rc);
916 p9_free_req(clnt, req); 916 p9_free_req(clnt, req);
917 goto error; 917 goto error;
918 } 918 }
@@ -972,7 +972,7 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname,
972 972
973 err = p9pdu_readf(req->rc, clnt->proto_version, "R", &nwqids, &wqids); 973 err = p9pdu_readf(req->rc, clnt->proto_version, "R", &nwqids, &wqids);
974 if (err) { 974 if (err) {
975 p9pdu_dump(1, req->rc); 975 P9_DUMP_PKT(1, req->rc);
976 p9_free_req(clnt, req); 976 p9_free_req(clnt, req);
977 goto clunk_fid; 977 goto clunk_fid;
978 } 978 }
@@ -1039,7 +1039,7 @@ int p9_client_open(struct p9_fid *fid, int mode)
1039 1039
1040 err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit); 1040 err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit);
1041 if (err) { 1041 if (err) {
1042 p9pdu_dump(1, req->rc); 1042 P9_DUMP_PKT(1, req->rc);
1043 goto free_and_error; 1043 goto free_and_error;
1044 } 1044 }
1045 1045
@@ -1082,7 +1082,7 @@ int p9_client_create_dotl(struct p9_fid *ofid, char *name, u32 flags, u32 mode,
1082 1082
1083 err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", qid, &iounit); 1083 err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", qid, &iounit);
1084 if (err) { 1084 if (err) {
1085 p9pdu_dump(1, req->rc); 1085 P9_DUMP_PKT(1, req->rc);
1086 goto free_and_error; 1086 goto free_and_error;
1087 } 1087 }
1088 1088
@@ -1127,7 +1127,7 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
1127 1127
1128 err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit); 1128 err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit);
1129 if (err) { 1129 if (err) {
1130 p9pdu_dump(1, req->rc); 1130 P9_DUMP_PKT(1, req->rc);
1131 goto free_and_error; 1131 goto free_and_error;
1132 } 1132 }
1133 1133
@@ -1166,7 +1166,7 @@ int p9_client_symlink(struct p9_fid *dfid, char *name, char *symtgt, gid_t gid,
1166 1166
1167 err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); 1167 err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid);
1168 if (err) { 1168 if (err) {
1169 p9pdu_dump(1, req->rc); 1169 P9_DUMP_PKT(1, req->rc);
1170 goto free_and_error; 1170 goto free_and_error;
1171 } 1171 }
1172 1172
@@ -1319,11 +1319,12 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset,
1319 1319
1320 err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr); 1320 err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr);
1321 if (err) { 1321 if (err) {
1322 p9pdu_dump(1, req->rc); 1322 P9_DUMP_PKT(1, req->rc);
1323 goto free_and_error; 1323 goto free_and_error;
1324 } 1324 }
1325 1325
1326 P9_DPRINTK(P9_DEBUG_9P, "<<< RREAD count %d\n", count); 1326 P9_DPRINTK(P9_DEBUG_9P, "<<< RREAD count %d\n", count);
1327 P9_DUMP_PKT(1, req->rc);
1327 1328
1328 if (!req->tc->pbuf_size) { 1329 if (!req->tc->pbuf_size) {
1329 if (data) { 1330 if (data) {
@@ -1387,7 +1388,7 @@ p9_client_write(struct p9_fid *fid, char *data, const char __user *udata,
1387 1388
1388 err = p9pdu_readf(req->rc, clnt->proto_version, "d", &count); 1389 err = p9pdu_readf(req->rc, clnt->proto_version, "d", &count);
1389 if (err) { 1390 if (err) {
1390 p9pdu_dump(1, req->rc); 1391 P9_DUMP_PKT(1, req->rc);
1391 goto free_and_error; 1392 goto free_and_error;
1392 } 1393 }
1393 1394
@@ -1427,7 +1428,7 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid)
1427 1428
1428 err = p9pdu_readf(req->rc, clnt->proto_version, "wS", &ignored, ret); 1429 err = p9pdu_readf(req->rc, clnt->proto_version, "wS", &ignored, ret);
1429 if (err) { 1430 if (err) {
1430 p9pdu_dump(1, req->rc); 1431 P9_DUMP_PKT(1, req->rc);
1431 p9_free_req(clnt, req); 1432 p9_free_req(clnt, req);
1432 goto error; 1433 goto error;
1433 } 1434 }
@@ -1478,7 +1479,7 @@ struct p9_stat_dotl *p9_client_getattr_dotl(struct p9_fid *fid,
1478 1479
1479 err = p9pdu_readf(req->rc, clnt->proto_version, "A", ret); 1480 err = p9pdu_readf(req->rc, clnt->proto_version, "A", ret);
1480 if (err) { 1481 if (err) {
1481 p9pdu_dump(1, req->rc); 1482 P9_DUMP_PKT(1, req->rc);
1482 p9_free_req(clnt, req); 1483 p9_free_req(clnt, req);
1483 goto error; 1484 goto error;
1484 } 1485 }
@@ -1626,7 +1627,7 @@ int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb)
1626 &sb->bsize, &sb->blocks, &sb->bfree, &sb->bavail, 1627 &sb->bsize, &sb->blocks, &sb->bfree, &sb->bavail,
1627 &sb->files, &sb->ffree, &sb->fsid, &sb->namelen); 1628 &sb->files, &sb->ffree, &sb->fsid, &sb->namelen);
1628 if (err) { 1629 if (err) {
1629 p9pdu_dump(1, req->rc); 1630 P9_DUMP_PKT(1, req->rc);
1630 p9_free_req(clnt, req); 1631 p9_free_req(clnt, req);
1631 goto error; 1632 goto error;
1632 } 1633 }
@@ -1702,7 +1703,7 @@ struct p9_fid *p9_client_xattrwalk(struct p9_fid *file_fid,
1702 } 1703 }
1703 err = p9pdu_readf(req->rc, clnt->proto_version, "q", attr_size); 1704 err = p9pdu_readf(req->rc, clnt->proto_version, "q", attr_size);
1704 if (err) { 1705 if (err) {
1705 p9pdu_dump(1, req->rc); 1706 P9_DUMP_PKT(1, req->rc);
1706 p9_free_req(clnt, req); 1707 p9_free_req(clnt, req);
1707 goto clunk_fid; 1708 goto clunk_fid;
1708 } 1709 }
@@ -1781,7 +1782,7 @@ int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset)
1781 1782
1782 err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr); 1783 err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr);
1783 if (err) { 1784 if (err) {
1784 p9pdu_dump(1, req->rc); 1785 P9_DUMP_PKT(1, req->rc);
1785 goto free_and_error; 1786 goto free_and_error;
1786 } 1787 }
1787 1788
@@ -1818,7 +1819,7 @@ int p9_client_mknod_dotl(struct p9_fid *fid, char *name, int mode,
1818 1819
1819 err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); 1820 err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid);
1820 if (err) { 1821 if (err) {
1821 p9pdu_dump(1, req->rc); 1822 P9_DUMP_PKT(1, req->rc);
1822 goto error; 1823 goto error;
1823 } 1824 }
1824 P9_DPRINTK(P9_DEBUG_9P, "<<< RMKNOD qid %x.%llx.%x\n", qid->type, 1825 P9_DPRINTK(P9_DEBUG_9P, "<<< RMKNOD qid %x.%llx.%x\n", qid->type,
@@ -1849,7 +1850,7 @@ int p9_client_mkdir_dotl(struct p9_fid *fid, char *name, int mode,
1849 1850
1850 err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); 1851 err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid);
1851 if (err) { 1852 if (err) {
1852 p9pdu_dump(1, req->rc); 1853 P9_DUMP_PKT(1, req->rc);
1853 goto error; 1854 goto error;
1854 } 1855 }
1855 P9_DPRINTK(P9_DEBUG_9P, "<<< RMKDIR qid %x.%llx.%x\n", qid->type, 1856 P9_DPRINTK(P9_DEBUG_9P, "<<< RMKDIR qid %x.%llx.%x\n", qid->type,
@@ -1884,7 +1885,7 @@ int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status)
1884 1885
1885 err = p9pdu_readf(req->rc, clnt->proto_version, "b", status); 1886 err = p9pdu_readf(req->rc, clnt->proto_version, "b", status);
1886 if (err) { 1887 if (err) {
1887 p9pdu_dump(1, req->rc); 1888 P9_DUMP_PKT(1, req->rc);
1888 goto error; 1889 goto error;
1889 } 1890 }
1890 P9_DPRINTK(P9_DEBUG_9P, "<<< RLOCK status %i\n", *status); 1891 P9_DPRINTK(P9_DEBUG_9P, "<<< RLOCK status %i\n", *status);
@@ -1917,7 +1918,7 @@ int p9_client_getlock_dotl(struct p9_fid *fid, struct p9_getlock *glock)
1917 &glock->start, &glock->length, &glock->proc_id, 1918 &glock->start, &glock->length, &glock->proc_id,
1918 &glock->client_id); 1919 &glock->client_id);
1919 if (err) { 1920 if (err) {
1920 p9pdu_dump(1, req->rc); 1921 P9_DUMP_PKT(1, req->rc);
1921 goto error; 1922 goto error;
1922 } 1923 }
1923 P9_DPRINTK(P9_DEBUG_9P, "<<< RGETLOCK type %i start %lld length %lld " 1924 P9_DPRINTK(P9_DEBUG_9P, "<<< RGETLOCK type %i start %lld length %lld "
@@ -1945,7 +1946,7 @@ int p9_client_readlink(struct p9_fid *fid, char **target)
1945 1946
1946 err = p9pdu_readf(req->rc, clnt->proto_version, "s", target); 1947 err = p9pdu_readf(req->rc, clnt->proto_version, "s", target);
1947 if (err) { 1948 if (err) {
1948 p9pdu_dump(1, req->rc); 1949 P9_DUMP_PKT(1, req->rc);
1949 goto error; 1950 goto error;
1950 } 1951 }
1951 P9_DPRINTK(P9_DEBUG_9P, "<<< RREADLINK target %s\n", *target); 1952 P9_DPRINTK(P9_DEBUG_9P, "<<< RREADLINK target %s\n", *target);
diff --git a/net/9p/protocol.c b/net/9p/protocol.c
index a873277cb996..df58375ea6b3 100644
--- a/net/9p/protocol.c
+++ b/net/9p/protocol.c
@@ -44,30 +44,24 @@ p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...);
44void 44void
45p9pdu_dump(int way, struct p9_fcall *pdu) 45p9pdu_dump(int way, struct p9_fcall *pdu)
46{ 46{
47 int i, n; 47 int len = pdu->size;
48 u8 *data = pdu->sdata; 48
49 int datalen = pdu->size; 49 if ((p9_debug_level & P9_DEBUG_VPKT) != P9_DEBUG_VPKT) {
50 char buf[255]; 50 if ((p9_debug_level & P9_DEBUG_PKT) == P9_DEBUG_PKT) {
51 int buflen = 255; 51 if (len > 32)
52 52 len = 32;
53 i = n = 0; 53 } else {
54 if (datalen > (buflen-16)) 54 /* shouldn't happen */
55 datalen = buflen-16; 55 return;
56 while (i < datalen) { 56 }
57 n += scnprintf(buf + n, buflen - n, "%02x ", data[i]);
58 if (i%4 == 3)
59 n += scnprintf(buf + n, buflen - n, " ");
60 if (i%32 == 31)
61 n += scnprintf(buf + n, buflen - n, "\n");
62
63 i++;
64 } 57 }
65 n += scnprintf(buf + n, buflen - n, "\n");
66 58
67 if (way) 59 if (way)
68 P9_DPRINTK(P9_DEBUG_PKT, "[[[(%d) %s\n", datalen, buf); 60 print_hex_dump_bytes("[9P] ", DUMP_PREFIX_OFFSET, pdu->sdata,
61 len);
69 else 62 else
70 P9_DPRINTK(P9_DEBUG_PKT, "]]](%d) %s\n", datalen, buf); 63 print_hex_dump_bytes("]9P[ ", DUMP_PREFIX_OFFSET, pdu->sdata,
64 len);
71} 65}
72#else 66#else
73void 67void
@@ -610,7 +604,7 @@ int p9stat_read(char *buf, int len, struct p9_wstat *st, int proto_version)
610 ret = p9pdu_readf(&fake_pdu, proto_version, "S", st); 604 ret = p9pdu_readf(&fake_pdu, proto_version, "S", st);
611 if (ret) { 605 if (ret) {
612 P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret); 606 P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret);
613 p9pdu_dump(1, &fake_pdu); 607 P9_DUMP_PKT(0, &fake_pdu);
614 } 608 }
615 609
616 return ret; 610 return ret;
@@ -632,11 +626,7 @@ int p9pdu_finalize(struct p9_fcall *pdu)
632 err = p9pdu_writef(pdu, 0, "d", size); 626 err = p9pdu_writef(pdu, 0, "d", size);
633 pdu->size = size; 627 pdu->size = size;
634 628
635#ifdef CONFIG_NET_9P_DEBUG 629 P9_DUMP_PKT(0, pdu);
636 if ((p9_debug_level & P9_DEBUG_PKT) == P9_DEBUG_PKT)
637 p9pdu_dump(0, pdu);
638#endif
639
640 P9_DPRINTK(P9_DEBUG_9P, ">>> size=%d type: %d tag: %d\n", pdu->size, 630 P9_DPRINTK(P9_DEBUG_9P, ">>> size=%d type: %d tag: %d\n", pdu->size,
641 pdu->id, pdu->tag); 631 pdu->id, pdu->tag);
642 632
@@ -669,7 +659,7 @@ int p9dirent_read(char *buf, int len, struct p9_dirent *dirent,
669 &dirent->d_off, &dirent->d_type, &nameptr); 659 &dirent->d_off, &dirent->d_type, &nameptr);
670 if (ret) { 660 if (ret) {
671 P9_DPRINTK(P9_DEBUG_9P, "<<< p9dirent_read failed: %d\n", ret); 661 P9_DPRINTK(P9_DEBUG_9P, "<<< p9dirent_read failed: %d\n", ret);
672 p9pdu_dump(1, &fake_pdu); 662 P9_DUMP_PKT(1, &fake_pdu);
673 goto out; 663 goto out;
674 } 664 }
675 665