net/9p: Implement attrwalk 9p call
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Mon, 31 May 2010 07:52:45 +0000 (13:22 +0530)
committerEric Van Hensbergen <ericvh@gmail.com>
Mon, 2 Aug 2010 19:28:33 +0000 (14:28 -0500)
TXATTRWALK: Descend a ATTR namespace

 size[4] TXATTRWALK tag[2] fid[4] newfid[4] name[s]
 size[4] RXATTRWALK tag[2] size[8]

txattrwalk gets a fid pointing to xattr. This fid can later be
used to read the xattr value. If name is NULL the fid returned
can be used to get the list of extended attribute associated to
the file system object.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
include/net/9p/9p.h
include/net/9p/client.h
net/9p/client.c

index cf580a40e299e1880a0d50e76cc1e21eb98152ae..6fabb5e559baf97ee3659ab175fb2e7f680b2dcd 100644 (file)
@@ -153,6 +153,8 @@ enum p9_msg_t {
        P9_RGETATTR,
        P9_TSETATTR = 26,
        P9_RSETATTR,
+       P9_TXATTRWALK = 30,
+       P9_RXATTRWALK,
        P9_TREADDIR = 40,
        P9_RREADDIR,
        P9_TLINK = 70,
index d755c0ed67502fcf9c0cccc8e07f127417ef3a9d..60398b1a3f75b6bfa3d255fef2f3ed6b988a90be 100644 (file)
@@ -260,5 +260,6 @@ void p9stat_free(struct p9_wstat *);
 
 int p9_is_proto_dotu(struct p9_client *clnt);
 int p9_is_proto_dotl(struct p9_client *clnt);
+struct p9_fid *p9_client_xattrwalk(struct p9_fid *, const char *, u64 *);
 
 #endif /* NET_9P_CLIENT_H */
index c458e042d38436484645186f60511f27bc449796..ec80ee71d45346a012c25c70db90bb03eb982c43 100644 (file)
@@ -1622,6 +1622,56 @@ error:
 }
 EXPORT_SYMBOL(p9_client_rename);
 
+/*
+ * An xattrwalk without @attr_name gives the fid for the lisxattr namespace
+ */
+struct p9_fid *p9_client_xattrwalk(struct p9_fid *file_fid,
+                               const char *attr_name, u64 *attr_size)
+{
+       int err;
+       struct p9_req_t *req;
+       struct p9_client *clnt;
+       struct p9_fid *attr_fid;
+
+       err = 0;
+       clnt = file_fid->clnt;
+       attr_fid = p9_fid_create(clnt);
+       if (IS_ERR(attr_fid)) {
+               err = PTR_ERR(attr_fid);
+               attr_fid = NULL;
+               goto error;
+       }
+       P9_DPRINTK(P9_DEBUG_9P,
+               ">>> TXATTRWALK file_fid %d, attr_fid %d name %s\n",
+               file_fid->fid, attr_fid->fid, attr_name);
+
+       req = p9_client_rpc(clnt, P9_TXATTRWALK, "dds",
+                       file_fid->fid, attr_fid->fid, attr_name);
+       if (IS_ERR(req)) {
+               err = PTR_ERR(req);
+               goto error;
+       }
+       err = p9pdu_readf(req->rc, clnt->proto_version, "q", attr_size);
+       if (err) {
+               p9pdu_dump(1, req->rc);
+               p9_free_req(clnt, req);
+               goto clunk_fid;
+       }
+       p9_free_req(clnt, req);
+       P9_DPRINTK(P9_DEBUG_9P, "<<<  RXATTRWALK fid %d size %llu\n",
+               attr_fid->fid, *attr_size);
+       return attr_fid;
+clunk_fid:
+       p9_client_clunk(attr_fid);
+       attr_fid = NULL;
+error:
+       if (attr_fid && (attr_fid != file_fid))
+               p9_fid_destroy(attr_fid);
+
+       return ERR_PTR(err);
+}
+EXPORT_SYMBOL_GPL(p9_client_xattrwalk);
+
 int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset)
 {
        int err, rsize, total;