diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/9p/client.c | 393 | ||||
-rw-r--r-- | net/9p/protocol.c | 72 | ||||
-rw-r--r-- | net/9p/trans_fd.c | 2 |
3 files changed, 456 insertions, 11 deletions
diff --git a/net/9p/client.c b/net/9p/client.c index 37c8da07a80b..dc6f2f26d023 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -460,7 +460,8 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req) | |||
460 | return err; | 460 | return err; |
461 | } | 461 | } |
462 | 462 | ||
463 | if (p9_is_proto_dotu(c)) | 463 | if (p9_is_proto_dotu(c) || |
464 | p9_is_proto_dotl(c)) | ||
464 | err = -ecode; | 465 | err = -ecode; |
465 | 466 | ||
466 | if (!err || !IS_ERR_VALUE(err)) | 467 | if (!err || !IS_ERR_VALUE(err)) |
@@ -1015,14 +1016,18 @@ int p9_client_open(struct p9_fid *fid, int mode) | |||
1015 | struct p9_qid qid; | 1016 | struct p9_qid qid; |
1016 | int iounit; | 1017 | int iounit; |
1017 | 1018 | ||
1018 | P9_DPRINTK(P9_DEBUG_9P, ">>> TOPEN fid %d mode %d\n", fid->fid, mode); | ||
1019 | err = 0; | ||
1020 | clnt = fid->clnt; | 1019 | clnt = fid->clnt; |
1020 | P9_DPRINTK(P9_DEBUG_9P, ">>> %s fid %d mode %d\n", | ||
1021 | p9_is_proto_dotl(clnt) ? "TLOPEN" : "TOPEN", fid->fid, mode); | ||
1022 | err = 0; | ||
1021 | 1023 | ||
1022 | if (fid->mode != -1) | 1024 | if (fid->mode != -1) |
1023 | return -EINVAL; | 1025 | return -EINVAL; |
1024 | 1026 | ||
1025 | req = p9_client_rpc(clnt, P9_TOPEN, "db", fid->fid, mode); | 1027 | if (p9_is_proto_dotl(clnt)) |
1028 | req = p9_client_rpc(clnt, P9_TLOPEN, "dd", fid->fid, mode); | ||
1029 | else | ||
1030 | req = p9_client_rpc(clnt, P9_TOPEN, "db", fid->fid, mode); | ||
1026 | if (IS_ERR(req)) { | 1031 | if (IS_ERR(req)) { |
1027 | err = PTR_ERR(req); | 1032 | err = PTR_ERR(req); |
1028 | goto error; | 1033 | goto error; |
@@ -1034,10 +1039,9 @@ int p9_client_open(struct p9_fid *fid, int mode) | |||
1034 | goto free_and_error; | 1039 | goto free_and_error; |
1035 | } | 1040 | } |
1036 | 1041 | ||
1037 | P9_DPRINTK(P9_DEBUG_9P, "<<< ROPEN qid %x.%llx.%x iounit %x\n", | 1042 | P9_DPRINTK(P9_DEBUG_9P, "<<< %s qid %x.%llx.%x iounit %x\n", |
1038 | qid.type, | 1043 | p9_is_proto_dotl(clnt) ? "RLOPEN" : "ROPEN", qid.type, |
1039 | (unsigned long long)qid.path, | 1044 | (unsigned long long)qid.path, qid.version, iounit); |
1040 | qid.version, iounit); | ||
1041 | 1045 | ||
1042 | fid->mode = mode; | 1046 | fid->mode = mode; |
1043 | fid->iounit = iounit; | 1047 | fid->iounit = iounit; |
@@ -1049,6 +1053,50 @@ error: | |||
1049 | } | 1053 | } |
1050 | EXPORT_SYMBOL(p9_client_open); | 1054 | EXPORT_SYMBOL(p9_client_open); |
1051 | 1055 | ||
1056 | int p9_client_create_dotl(struct p9_fid *ofid, char *name, u32 flags, u32 mode, | ||
1057 | gid_t gid, struct p9_qid *qid) | ||
1058 | { | ||
1059 | int err = 0; | ||
1060 | struct p9_client *clnt; | ||
1061 | struct p9_req_t *req; | ||
1062 | int iounit; | ||
1063 | |||
1064 | P9_DPRINTK(P9_DEBUG_9P, | ||
1065 | ">>> TLCREATE fid %d name %s flags %d mode %d gid %d\n", | ||
1066 | ofid->fid, name, flags, mode, gid); | ||
1067 | clnt = ofid->clnt; | ||
1068 | |||
1069 | if (ofid->mode != -1) | ||
1070 | return -EINVAL; | ||
1071 | |||
1072 | req = p9_client_rpc(clnt, P9_TLCREATE, "dsddd", ofid->fid, name, flags, | ||
1073 | mode, gid); | ||
1074 | if (IS_ERR(req)) { | ||
1075 | err = PTR_ERR(req); | ||
1076 | goto error; | ||
1077 | } | ||
1078 | |||
1079 | err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", qid, &iounit); | ||
1080 | if (err) { | ||
1081 | p9pdu_dump(1, req->rc); | ||
1082 | goto free_and_error; | ||
1083 | } | ||
1084 | |||
1085 | P9_DPRINTK(P9_DEBUG_9P, "<<< RLCREATE qid %x.%llx.%x iounit %x\n", | ||
1086 | qid->type, | ||
1087 | (unsigned long long)qid->path, | ||
1088 | qid->version, iounit); | ||
1089 | |||
1090 | ofid->mode = mode; | ||
1091 | ofid->iounit = iounit; | ||
1092 | |||
1093 | free_and_error: | ||
1094 | p9_free_req(clnt, req); | ||
1095 | error: | ||
1096 | return err; | ||
1097 | } | ||
1098 | EXPORT_SYMBOL(p9_client_create_dotl); | ||
1099 | |||
1052 | int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, | 1100 | int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, |
1053 | char *extension) | 1101 | char *extension) |
1054 | { | 1102 | { |
@@ -1094,6 +1142,59 @@ error: | |||
1094 | } | 1142 | } |
1095 | EXPORT_SYMBOL(p9_client_fcreate); | 1143 | EXPORT_SYMBOL(p9_client_fcreate); |
1096 | 1144 | ||
1145 | int p9_client_symlink(struct p9_fid *dfid, char *name, char *symtgt, gid_t gid, | ||
1146 | struct p9_qid *qid) | ||
1147 | { | ||
1148 | int err = 0; | ||
1149 | struct p9_client *clnt; | ||
1150 | struct p9_req_t *req; | ||
1151 | |||
1152 | P9_DPRINTK(P9_DEBUG_9P, ">>> TSYMLINK dfid %d name %s symtgt %s\n", | ||
1153 | dfid->fid, name, symtgt); | ||
1154 | clnt = dfid->clnt; | ||
1155 | |||
1156 | req = p9_client_rpc(clnt, P9_TSYMLINK, "dssd", dfid->fid, name, symtgt, | ||
1157 | gid); | ||
1158 | if (IS_ERR(req)) { | ||
1159 | err = PTR_ERR(req); | ||
1160 | goto error; | ||
1161 | } | ||
1162 | |||
1163 | err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); | ||
1164 | if (err) { | ||
1165 | p9pdu_dump(1, req->rc); | ||
1166 | goto free_and_error; | ||
1167 | } | ||
1168 | |||
1169 | P9_DPRINTK(P9_DEBUG_9P, "<<< RSYMLINK qid %x.%llx.%x\n", | ||
1170 | qid->type, (unsigned long long)qid->path, qid->version); | ||
1171 | |||
1172 | free_and_error: | ||
1173 | p9_free_req(clnt, req); | ||
1174 | error: | ||
1175 | return err; | ||
1176 | } | ||
1177 | EXPORT_SYMBOL(p9_client_symlink); | ||
1178 | |||
1179 | int p9_client_link(struct p9_fid *dfid, struct p9_fid *oldfid, char *newname) | ||
1180 | { | ||
1181 | struct p9_client *clnt; | ||
1182 | struct p9_req_t *req; | ||
1183 | |||
1184 | P9_DPRINTK(P9_DEBUG_9P, ">>> TLINK dfid %d oldfid %d newname %s\n", | ||
1185 | dfid->fid, oldfid->fid, newname); | ||
1186 | clnt = dfid->clnt; | ||
1187 | req = p9_client_rpc(clnt, P9_TLINK, "dds", dfid->fid, oldfid->fid, | ||
1188 | newname); | ||
1189 | if (IS_ERR(req)) | ||
1190 | return PTR_ERR(req); | ||
1191 | |||
1192 | P9_DPRINTK(P9_DEBUG_9P, "<<< RLINK\n"); | ||
1193 | p9_free_req(clnt, req); | ||
1194 | return 0; | ||
1195 | } | ||
1196 | EXPORT_SYMBOL(p9_client_link); | ||
1197 | |||
1097 | int p9_client_clunk(struct p9_fid *fid) | 1198 | int p9_client_clunk(struct p9_fid *fid) |
1098 | { | 1199 | { |
1099 | int err; | 1200 | int err; |
@@ -1139,9 +1240,8 @@ int p9_client_remove(struct p9_fid *fid) | |||
1139 | P9_DPRINTK(P9_DEBUG_9P, "<<< RREMOVE fid %d\n", fid->fid); | 1240 | P9_DPRINTK(P9_DEBUG_9P, "<<< RREMOVE fid %d\n", fid->fid); |
1140 | 1241 | ||
1141 | p9_free_req(clnt, req); | 1242 | p9_free_req(clnt, req); |
1142 | p9_fid_destroy(fid); | ||
1143 | |||
1144 | error: | 1243 | error: |
1244 | p9_fid_destroy(fid); | ||
1145 | return err; | 1245 | return err; |
1146 | } | 1246 | } |
1147 | EXPORT_SYMBOL(p9_client_remove); | 1247 | EXPORT_SYMBOL(p9_client_remove); |
@@ -1302,6 +1402,65 @@ error: | |||
1302 | } | 1402 | } |
1303 | EXPORT_SYMBOL(p9_client_stat); | 1403 | EXPORT_SYMBOL(p9_client_stat); |
1304 | 1404 | ||
1405 | struct p9_stat_dotl *p9_client_getattr_dotl(struct p9_fid *fid, | ||
1406 | u64 request_mask) | ||
1407 | { | ||
1408 | int err; | ||
1409 | struct p9_client *clnt; | ||
1410 | struct p9_stat_dotl *ret = kmalloc(sizeof(struct p9_stat_dotl), | ||
1411 | GFP_KERNEL); | ||
1412 | struct p9_req_t *req; | ||
1413 | |||
1414 | P9_DPRINTK(P9_DEBUG_9P, ">>> TGETATTR fid %d, request_mask %lld\n", | ||
1415 | fid->fid, request_mask); | ||
1416 | |||
1417 | if (!ret) | ||
1418 | return ERR_PTR(-ENOMEM); | ||
1419 | |||
1420 | err = 0; | ||
1421 | clnt = fid->clnt; | ||
1422 | |||
1423 | req = p9_client_rpc(clnt, P9_TGETATTR, "dq", fid->fid, request_mask); | ||
1424 | if (IS_ERR(req)) { | ||
1425 | err = PTR_ERR(req); | ||
1426 | goto error; | ||
1427 | } | ||
1428 | |||
1429 | err = p9pdu_readf(req->rc, clnt->proto_version, "A", ret); | ||
1430 | if (err) { | ||
1431 | p9pdu_dump(1, req->rc); | ||
1432 | p9_free_req(clnt, req); | ||
1433 | goto error; | ||
1434 | } | ||
1435 | |||
1436 | P9_DPRINTK(P9_DEBUG_9P, | ||
1437 | "<<< RGETATTR st_result_mask=%lld\n" | ||
1438 | "<<< qid=%x.%llx.%x\n" | ||
1439 | "<<< st_mode=%8.8x st_nlink=%llu\n" | ||
1440 | "<<< st_uid=%d st_gid=%d\n" | ||
1441 | "<<< st_rdev=%llx st_size=%llx st_blksize=%llu st_blocks=%llu\n" | ||
1442 | "<<< st_atime_sec=%lld st_atime_nsec=%lld\n" | ||
1443 | "<<< st_mtime_sec=%lld st_mtime_nsec=%lld\n" | ||
1444 | "<<< st_ctime_sec=%lld st_ctime_nsec=%lld\n" | ||
1445 | "<<< st_btime_sec=%lld st_btime_nsec=%lld\n" | ||
1446 | "<<< st_gen=%lld st_data_version=%lld", | ||
1447 | ret->st_result_mask, ret->qid.type, ret->qid.path, | ||
1448 | ret->qid.version, ret->st_mode, ret->st_nlink, ret->st_uid, | ||
1449 | ret->st_gid, ret->st_rdev, ret->st_size, ret->st_blksize, | ||
1450 | ret->st_blocks, ret->st_atime_sec, ret->st_atime_nsec, | ||
1451 | ret->st_mtime_sec, ret->st_mtime_nsec, ret->st_ctime_sec, | ||
1452 | ret->st_ctime_nsec, ret->st_btime_sec, ret->st_btime_nsec, | ||
1453 | ret->st_gen, ret->st_data_version); | ||
1454 | |||
1455 | p9_free_req(clnt, req); | ||
1456 | return ret; | ||
1457 | |||
1458 | error: | ||
1459 | kfree(ret); | ||
1460 | return ERR_PTR(err); | ||
1461 | } | ||
1462 | EXPORT_SYMBOL(p9_client_getattr_dotl); | ||
1463 | |||
1305 | static int p9_client_statsize(struct p9_wstat *wst, int proto_version) | 1464 | static int p9_client_statsize(struct p9_wstat *wst, int proto_version) |
1306 | { | 1465 | { |
1307 | int ret; | 1466 | int ret; |
@@ -1366,6 +1525,36 @@ error: | |||
1366 | } | 1525 | } |
1367 | EXPORT_SYMBOL(p9_client_wstat); | 1526 | EXPORT_SYMBOL(p9_client_wstat); |
1368 | 1527 | ||
1528 | int p9_client_setattr(struct p9_fid *fid, struct p9_iattr_dotl *p9attr) | ||
1529 | { | ||
1530 | int err; | ||
1531 | struct p9_req_t *req; | ||
1532 | struct p9_client *clnt; | ||
1533 | |||
1534 | err = 0; | ||
1535 | clnt = fid->clnt; | ||
1536 | P9_DPRINTK(P9_DEBUG_9P, ">>> TSETATTR fid %d\n", fid->fid); | ||
1537 | P9_DPRINTK(P9_DEBUG_9P, | ||
1538 | " valid=%x mode=%x uid=%d gid=%d size=%lld\n" | ||
1539 | " atime_sec=%lld atime_nsec=%lld\n" | ||
1540 | " mtime_sec=%lld mtime_nsec=%lld\n", | ||
1541 | p9attr->valid, p9attr->mode, p9attr->uid, p9attr->gid, | ||
1542 | p9attr->size, p9attr->atime_sec, p9attr->atime_nsec, | ||
1543 | p9attr->mtime_sec, p9attr->mtime_nsec); | ||
1544 | |||
1545 | req = p9_client_rpc(clnt, P9_TSETATTR, "dI", fid->fid, p9attr); | ||
1546 | |||
1547 | if (IS_ERR(req)) { | ||
1548 | err = PTR_ERR(req); | ||
1549 | goto error; | ||
1550 | } | ||
1551 | P9_DPRINTK(P9_DEBUG_9P, "<<< RSETATTR fid %d\n", fid->fid); | ||
1552 | p9_free_req(clnt, req); | ||
1553 | error: | ||
1554 | return err; | ||
1555 | } | ||
1556 | EXPORT_SYMBOL(p9_client_setattr); | ||
1557 | |||
1369 | int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb) | 1558 | int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb) |
1370 | { | 1559 | { |
1371 | int err; | 1560 | int err; |
@@ -1432,3 +1621,187 @@ error: | |||
1432 | } | 1621 | } |
1433 | EXPORT_SYMBOL(p9_client_rename); | 1622 | EXPORT_SYMBOL(p9_client_rename); |
1434 | 1623 | ||
1624 | /* | ||
1625 | * An xattrwalk without @attr_name gives the fid for the lisxattr namespace | ||
1626 | */ | ||
1627 | struct p9_fid *p9_client_xattrwalk(struct p9_fid *file_fid, | ||
1628 | const char *attr_name, u64 *attr_size) | ||
1629 | { | ||
1630 | int err; | ||
1631 | struct p9_req_t *req; | ||
1632 | struct p9_client *clnt; | ||
1633 | struct p9_fid *attr_fid; | ||
1634 | |||
1635 | err = 0; | ||
1636 | clnt = file_fid->clnt; | ||
1637 | attr_fid = p9_fid_create(clnt); | ||
1638 | if (IS_ERR(attr_fid)) { | ||
1639 | err = PTR_ERR(attr_fid); | ||
1640 | attr_fid = NULL; | ||
1641 | goto error; | ||
1642 | } | ||
1643 | P9_DPRINTK(P9_DEBUG_9P, | ||
1644 | ">>> TXATTRWALK file_fid %d, attr_fid %d name %s\n", | ||
1645 | file_fid->fid, attr_fid->fid, attr_name); | ||
1646 | |||
1647 | req = p9_client_rpc(clnt, P9_TXATTRWALK, "dds", | ||
1648 | file_fid->fid, attr_fid->fid, attr_name); | ||
1649 | if (IS_ERR(req)) { | ||
1650 | err = PTR_ERR(req); | ||
1651 | goto error; | ||
1652 | } | ||
1653 | err = p9pdu_readf(req->rc, clnt->proto_version, "q", attr_size); | ||
1654 | if (err) { | ||
1655 | p9pdu_dump(1, req->rc); | ||
1656 | p9_free_req(clnt, req); | ||
1657 | goto clunk_fid; | ||
1658 | } | ||
1659 | p9_free_req(clnt, req); | ||
1660 | P9_DPRINTK(P9_DEBUG_9P, "<<< RXATTRWALK fid %d size %llu\n", | ||
1661 | attr_fid->fid, *attr_size); | ||
1662 | return attr_fid; | ||
1663 | clunk_fid: | ||
1664 | p9_client_clunk(attr_fid); | ||
1665 | attr_fid = NULL; | ||
1666 | error: | ||
1667 | if (attr_fid && (attr_fid != file_fid)) | ||
1668 | p9_fid_destroy(attr_fid); | ||
1669 | |||
1670 | return ERR_PTR(err); | ||
1671 | } | ||
1672 | EXPORT_SYMBOL_GPL(p9_client_xattrwalk); | ||
1673 | |||
1674 | int p9_client_xattrcreate(struct p9_fid *fid, const char *name, | ||
1675 | u64 attr_size, int flags) | ||
1676 | { | ||
1677 | int err; | ||
1678 | struct p9_req_t *req; | ||
1679 | struct p9_client *clnt; | ||
1680 | |||
1681 | P9_DPRINTK(P9_DEBUG_9P, | ||
1682 | ">>> TXATTRCREATE fid %d name %s size %lld flag %d\n", | ||
1683 | fid->fid, name, (long long)attr_size, flags); | ||
1684 | err = 0; | ||
1685 | clnt = fid->clnt; | ||
1686 | req = p9_client_rpc(clnt, P9_TXATTRCREATE, "dsqd", | ||
1687 | fid->fid, name, attr_size, flags); | ||
1688 | if (IS_ERR(req)) { | ||
1689 | err = PTR_ERR(req); | ||
1690 | goto error; | ||
1691 | } | ||
1692 | P9_DPRINTK(P9_DEBUG_9P, "<<< RXATTRCREATE fid %d\n", fid->fid); | ||
1693 | p9_free_req(clnt, req); | ||
1694 | error: | ||
1695 | return err; | ||
1696 | } | ||
1697 | EXPORT_SYMBOL_GPL(p9_client_xattrcreate); | ||
1698 | |||
1699 | int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset) | ||
1700 | { | ||
1701 | int err, rsize, total; | ||
1702 | struct p9_client *clnt; | ||
1703 | struct p9_req_t *req; | ||
1704 | char *dataptr; | ||
1705 | |||
1706 | P9_DPRINTK(P9_DEBUG_9P, ">>> TREADDIR fid %d offset %llu count %d\n", | ||
1707 | fid->fid, (long long unsigned) offset, count); | ||
1708 | |||
1709 | err = 0; | ||
1710 | clnt = fid->clnt; | ||
1711 | total = 0; | ||
1712 | |||
1713 | rsize = fid->iounit; | ||
1714 | if (!rsize || rsize > clnt->msize-P9_READDIRHDRSZ) | ||
1715 | rsize = clnt->msize - P9_READDIRHDRSZ; | ||
1716 | |||
1717 | if (count < rsize) | ||
1718 | rsize = count; | ||
1719 | |||
1720 | req = p9_client_rpc(clnt, P9_TREADDIR, "dqd", fid->fid, offset, rsize); | ||
1721 | if (IS_ERR(req)) { | ||
1722 | err = PTR_ERR(req); | ||
1723 | goto error; | ||
1724 | } | ||
1725 | |||
1726 | err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr); | ||
1727 | if (err) { | ||
1728 | p9pdu_dump(1, req->rc); | ||
1729 | goto free_and_error; | ||
1730 | } | ||
1731 | |||
1732 | P9_DPRINTK(P9_DEBUG_9P, "<<< RREADDIR count %d\n", count); | ||
1733 | |||
1734 | if (data) | ||
1735 | memmove(data, dataptr, count); | ||
1736 | |||
1737 | p9_free_req(clnt, req); | ||
1738 | return count; | ||
1739 | |||
1740 | free_and_error: | ||
1741 | p9_free_req(clnt, req); | ||
1742 | error: | ||
1743 | return err; | ||
1744 | } | ||
1745 | EXPORT_SYMBOL(p9_client_readdir); | ||
1746 | |||
1747 | int p9_client_mknod_dotl(struct p9_fid *fid, char *name, int mode, | ||
1748 | dev_t rdev, gid_t gid, struct p9_qid *qid) | ||
1749 | { | ||
1750 | int err; | ||
1751 | struct p9_client *clnt; | ||
1752 | struct p9_req_t *req; | ||
1753 | |||
1754 | err = 0; | ||
1755 | clnt = fid->clnt; | ||
1756 | P9_DPRINTK(P9_DEBUG_9P, ">>> TMKNOD fid %d name %s mode %d major %d " | ||
1757 | "minor %d\n", fid->fid, name, mode, MAJOR(rdev), MINOR(rdev)); | ||
1758 | req = p9_client_rpc(clnt, P9_TMKNOD, "dsdddd", fid->fid, name, mode, | ||
1759 | MAJOR(rdev), MINOR(rdev), gid); | ||
1760 | if (IS_ERR(req)) | ||
1761 | return PTR_ERR(req); | ||
1762 | |||
1763 | err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); | ||
1764 | if (err) { | ||
1765 | p9pdu_dump(1, req->rc); | ||
1766 | goto error; | ||
1767 | } | ||
1768 | P9_DPRINTK(P9_DEBUG_9P, "<<< RMKNOD qid %x.%llx.%x\n", qid->type, | ||
1769 | (unsigned long long)qid->path, qid->version); | ||
1770 | |||
1771 | error: | ||
1772 | p9_free_req(clnt, req); | ||
1773 | return err; | ||
1774 | |||
1775 | } | ||
1776 | EXPORT_SYMBOL(p9_client_mknod_dotl); | ||
1777 | |||
1778 | int p9_client_mkdir_dotl(struct p9_fid *fid, char *name, int mode, | ||
1779 | gid_t gid, struct p9_qid *qid) | ||
1780 | { | ||
1781 | int err; | ||
1782 | struct p9_client *clnt; | ||
1783 | struct p9_req_t *req; | ||
1784 | |||
1785 | err = 0; | ||
1786 | clnt = fid->clnt; | ||
1787 | P9_DPRINTK(P9_DEBUG_9P, ">>> TMKDIR fid %d name %s mode %d gid %d\n", | ||
1788 | fid->fid, name, mode, gid); | ||
1789 | req = p9_client_rpc(clnt, P9_TMKDIR, "dsdd", fid->fid, name, mode, | ||
1790 | gid); | ||
1791 | if (IS_ERR(req)) | ||
1792 | return PTR_ERR(req); | ||
1793 | |||
1794 | err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); | ||
1795 | if (err) { | ||
1796 | p9pdu_dump(1, req->rc); | ||
1797 | goto error; | ||
1798 | } | ||
1799 | P9_DPRINTK(P9_DEBUG_9P, "<<< RMKDIR qid %x.%llx.%x\n", qid->type, | ||
1800 | (unsigned long long)qid->path, qid->version); | ||
1801 | |||
1802 | error: | ||
1803 | p9_free_req(clnt, req); | ||
1804 | return err; | ||
1805 | |||
1806 | } | ||
1807 | EXPORT_SYMBOL(p9_client_mkdir_dotl); | ||
diff --git a/net/9p/protocol.c b/net/9p/protocol.c index 149f82160130..3acd3afb20c8 100644 --- a/net/9p/protocol.c +++ b/net/9p/protocol.c | |||
@@ -141,6 +141,7 @@ pdu_write_u(struct p9_fcall *pdu, const char __user *udata, size_t size) | |||
141 | D - data blob (int32_t size followed by void *, results are not freed) | 141 | D - data blob (int32_t size followed by void *, results are not freed) |
142 | T - array of strings (int16_t count, followed by strings) | 142 | T - array of strings (int16_t count, followed by strings) |
143 | R - array of qids (int16_t count, followed by qids) | 143 | R - array of qids (int16_t count, followed by qids) |
144 | A - stat for 9p2000.L (p9_stat_dotl) | ||
144 | ? - if optional = 1, continue parsing | 145 | ? - if optional = 1, continue parsing |
145 | */ | 146 | */ |
146 | 147 | ||
@@ -340,6 +341,33 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt, | |||
340 | } | 341 | } |
341 | } | 342 | } |
342 | break; | 343 | break; |
344 | case 'A': { | ||
345 | struct p9_stat_dotl *stbuf = | ||
346 | va_arg(ap, struct p9_stat_dotl *); | ||
347 | |||
348 | memset(stbuf, 0, sizeof(struct p9_stat_dotl)); | ||
349 | errcode = | ||
350 | p9pdu_readf(pdu, proto_version, | ||
351 | "qQdddqqqqqqqqqqqqqqq", | ||
352 | &stbuf->st_result_mask, | ||
353 | &stbuf->qid, | ||
354 | &stbuf->st_mode, | ||
355 | &stbuf->st_uid, &stbuf->st_gid, | ||
356 | &stbuf->st_nlink, | ||
357 | &stbuf->st_rdev, &stbuf->st_size, | ||
358 | &stbuf->st_blksize, &stbuf->st_blocks, | ||
359 | &stbuf->st_atime_sec, | ||
360 | &stbuf->st_atime_nsec, | ||
361 | &stbuf->st_mtime_sec, | ||
362 | &stbuf->st_mtime_nsec, | ||
363 | &stbuf->st_ctime_sec, | ||
364 | &stbuf->st_ctime_nsec, | ||
365 | &stbuf->st_btime_sec, | ||
366 | &stbuf->st_btime_nsec, | ||
367 | &stbuf->st_gen, | ||
368 | &stbuf->st_data_version); | ||
369 | } | ||
370 | break; | ||
343 | case '?': | 371 | case '?': |
344 | if ((proto_version != p9_proto_2000u) && | 372 | if ((proto_version != p9_proto_2000u) && |
345 | (proto_version != p9_proto_2000L)) | 373 | (proto_version != p9_proto_2000L)) |
@@ -488,6 +516,23 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt, | |||
488 | } | 516 | } |
489 | } | 517 | } |
490 | break; | 518 | break; |
519 | case 'I':{ | ||
520 | struct p9_iattr_dotl *p9attr = va_arg(ap, | ||
521 | struct p9_iattr_dotl *); | ||
522 | |||
523 | errcode = p9pdu_writef(pdu, proto_version, | ||
524 | "ddddqqqqq", | ||
525 | p9attr->valid, | ||
526 | p9attr->mode, | ||
527 | p9attr->uid, | ||
528 | p9attr->gid, | ||
529 | p9attr->size, | ||
530 | p9attr->atime_sec, | ||
531 | p9attr->atime_nsec, | ||
532 | p9attr->mtime_sec, | ||
533 | p9attr->mtime_nsec); | ||
534 | } | ||
535 | break; | ||
491 | case '?': | 536 | case '?': |
492 | if ((proto_version != p9_proto_2000u) && | 537 | if ((proto_version != p9_proto_2000u) && |
493 | (proto_version != p9_proto_2000L)) | 538 | (proto_version != p9_proto_2000L)) |
@@ -580,3 +625,30 @@ void p9pdu_reset(struct p9_fcall *pdu) | |||
580 | pdu->offset = 0; | 625 | pdu->offset = 0; |
581 | pdu->size = 0; | 626 | pdu->size = 0; |
582 | } | 627 | } |
628 | |||
629 | int p9dirent_read(char *buf, int len, struct p9_dirent *dirent, | ||
630 | int proto_version) | ||
631 | { | ||
632 | struct p9_fcall fake_pdu; | ||
633 | int ret; | ||
634 | char *nameptr; | ||
635 | |||
636 | fake_pdu.size = len; | ||
637 | fake_pdu.capacity = len; | ||
638 | fake_pdu.sdata = buf; | ||
639 | fake_pdu.offset = 0; | ||
640 | |||
641 | ret = p9pdu_readf(&fake_pdu, proto_version, "Qqbs", &dirent->qid, | ||
642 | &dirent->d_off, &dirent->d_type, &nameptr); | ||
643 | if (ret) { | ||
644 | P9_DPRINTK(P9_DEBUG_9P, "<<< p9dirent_read failed: %d\n", ret); | ||
645 | p9pdu_dump(1, &fake_pdu); | ||
646 | goto out; | ||
647 | } | ||
648 | |||
649 | strcpy(dirent->d_name, nameptr); | ||
650 | |||
651 | out: | ||
652 | return fake_pdu.offset; | ||
653 | } | ||
654 | EXPORT_SYMBOL(p9dirent_read); | ||
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index 98ce9bcb0e15..c85109d809ca 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c | |||
@@ -948,7 +948,7 @@ p9_fd_create_unix(struct p9_client *client, const char *addr, char *args) | |||
948 | 948 | ||
949 | csocket = NULL; | 949 | csocket = NULL; |
950 | 950 | ||
951 | if (strlen(addr) > UNIX_PATH_MAX) { | 951 | if (strlen(addr) >= UNIX_PATH_MAX) { |
952 | P9_EPRINTK(KERN_ERR, "p9_trans_unix: address too long: %s\n", | 952 | P9_EPRINTK(KERN_ERR, "p9_trans_unix: address too long: %s\n", |
953 | addr); | 953 | addr); |
954 | return -ENAMETOOLONG; | 954 | return -ENAMETOOLONG; |