]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
net/9p: Implement TXATTRCREATE 9p call
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Mon, 31 May 2010 07:52:50 +0000 (13:22 +0530)
committerEric Van Hensbergen <ericvh@gmail.com>
Mon, 2 Aug 2010 19:28:34 +0000 (14:28 -0500)
TXATTRCREATE:  Prepare a fid for setting xattr value on a file system object.

 size[4] TXATTRCREATE tag[2] fid[4] name[s] attr_size[8] flags[4]
 size[4] RXATTRCREATE tag[2]

txattrcreate gets a fid pointing to xattr. This fid can later be
used to set the xattr value.

flag value is derived from set Linux setxattr. The manpage says
"The flags parameter can be used to refine the semantics of the operation.
XATTR_CREATE specifies a pure create, which fails if the named attribute
exists already. XATTR_REPLACE specifies a pure replace operation, which
fails if the named attribute does not already exist. By default (no flags),
the extended attribute will be created if need be, or will simply replace
the value if the attribute exists."

The actual setxattr operation happens when the fid is clunked. At that point
the written byte count and the attr_size specified in TXATTRCREATE should be
same otherwise an error will be returned.

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 6fabb5e559baf97ee3659ab175fb2e7f680b2dcd..a8de812ccbc8c68f15c0c434fdf5b70edcab707d 100644 (file)
@@ -155,6 +155,8 @@ enum p9_msg_t {
        P9_RSETATTR,
        P9_TXATTRWALK = 30,
        P9_RXATTRWALK,
+       P9_TXATTRCREATE = 32,
+       P9_RXATTRCREATE,
        P9_TREADDIR = 40,
        P9_RREADDIR,
        P9_TLINK = 70,
index 60398b1a3f75b6bfa3d255fef2f3ed6b988a90be..d1aa2cfb30f0f46b915e55118a29e7a8e91fe7e7 100644 (file)
@@ -261,5 +261,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 *);
+int p9_client_xattrcreate(struct p9_fid *, const char *, u64, int);
 
 #endif /* NET_9P_CLIENT_H */
index ec80ee71d45346a012c25c70db90bb03eb982c43..43396acd714a0b1b3f6ba256423577ec5a3eb167 100644 (file)
@@ -1672,6 +1672,31 @@ error:
 }
 EXPORT_SYMBOL_GPL(p9_client_xattrwalk);
 
+int p9_client_xattrcreate(struct p9_fid *fid, const char *name,
+                       u64 attr_size, int flags)
+{
+       int err;
+       struct p9_req_t *req;
+       struct p9_client *clnt;
+
+       P9_DPRINTK(P9_DEBUG_9P,
+               ">>> TXATTRCREATE fid %d name  %s size %lld flag %d\n",
+               fid->fid, name, (long long)attr_size, flags);
+       err = 0;
+       clnt = fid->clnt;
+       req = p9_client_rpc(clnt, P9_TXATTRCREATE, "dsqd",
+                       fid->fid, name, attr_size, flags);
+       if (IS_ERR(req)) {
+               err = PTR_ERR(req);
+               goto error;
+       }
+       P9_DPRINTK(P9_DEBUG_9P, "<<< RXATTRCREATE fid %d\n", fid->fid);
+       p9_free_req(clnt, req);
+error:
+       return err;
+}
+EXPORT_SYMBOL_GPL(p9_client_xattrcreate);
+
 int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset)
 {
        int err, rsize, total;