aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-01-31 12:34:58 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2013-02-26 02:46:05 -0500
commit38baba9ea02780c2df35c7a02552fddeb8576e16 (patch)
tree8e6cd8ecf1c6f1488dceab90015b76e349d4e2af /fs/9p
parent8add862fad426469a04c879bf5bb01f666a3c58e (diff)
9p: add fid-based variant of v9fs_xattr_set()
... making v9fs_xattr_set() a wrapper for it. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/9p')
-rw-r--r--fs/9p/xattr.c33
-rw-r--r--fs/9p/xattr.h2
2 files changed, 20 insertions, 15 deletions
diff --git a/fs/9p/xattr.c b/fs/9p/xattr.c
index 29653b70a9c3..c45e016b190f 100644
--- a/fs/9p/xattr.c
+++ b/fs/9p/xattr.c
@@ -111,19 +111,26 @@ ssize_t v9fs_xattr_get(struct dentry *dentry, const char *name,
111int v9fs_xattr_set(struct dentry *dentry, const char *name, 111int v9fs_xattr_set(struct dentry *dentry, const char *name,
112 const void *value, size_t value_len, int flags) 112 const void *value, size_t value_len, int flags)
113{ 113{
114 struct p9_fid *fid = v9fs_fid_lookup(dentry);
115 if (IS_ERR(fid))
116 return PTR_ERR(fid);
117 return v9fs_fid_xattr_set(fid, name, value, value_len, flags);
118}
119
120int v9fs_fid_xattr_set(struct p9_fid *fid, const char *name,
121 const void *value, size_t value_len, int flags)
122{
114 u64 offset = 0; 123 u64 offset = 0;
115 int retval, msize, write_count; 124 int retval, msize, write_count;
116 struct p9_fid *fid = NULL;
117 125
118 p9_debug(P9_DEBUG_VFS, "name = %s value_len = %zu flags = %d\n", 126 p9_debug(P9_DEBUG_VFS, "name = %s value_len = %zu flags = %d\n",
119 name, value_len, flags); 127 name, value_len, flags);
120 128
121 fid = v9fs_fid_clone(dentry); 129 /* Clone it */
122 if (IS_ERR(fid)) { 130 fid = p9_client_walk(fid, 0, NULL, 1);
123 retval = PTR_ERR(fid); 131 if (IS_ERR(fid))
124 fid = NULL; 132 return PTR_ERR(fid);
125 goto error; 133
126 }
127 /* 134 /*
128 * On success fid points to xattr 135 * On success fid points to xattr
129 */ 136 */
@@ -131,7 +138,8 @@ int v9fs_xattr_set(struct dentry *dentry, const char *name,
131 if (retval < 0) { 138 if (retval < 0) {
132 p9_debug(P9_DEBUG_VFS, "p9_client_xattrcreate failed %d\n", 139 p9_debug(P9_DEBUG_VFS, "p9_client_xattrcreate failed %d\n",
133 retval); 140 retval);
134 goto error; 141 p9_client_clunk(fid);
142 return retval;
135 } 143 }
136 msize = fid->clnt->msize; 144 msize = fid->clnt->msize;
137 while (value_len) { 145 while (value_len) {
@@ -144,17 +152,12 @@ int v9fs_xattr_set(struct dentry *dentry, const char *name,
144 if (write_count < 0) { 152 if (write_count < 0) {
145 /* error in xattr write */ 153 /* error in xattr write */
146 retval = write_count; 154 retval = write_count;
147 goto error; 155 break;
148 } 156 }
149 offset += write_count; 157 offset += write_count;
150 value_len -= write_count; 158 value_len -= write_count;
151 } 159 }
152 /* Total read xattr bytes */ 160 return p9_client_clunk(fid);
153 retval = offset;
154error:
155 if (fid)
156 retval = p9_client_clunk(fid);
157 return retval;
158} 161}
159 162
160ssize_t v9fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) 163ssize_t v9fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
diff --git a/fs/9p/xattr.h b/fs/9p/xattr.h
index eaa837c53bd5..eec348a3df71 100644
--- a/fs/9p/xattr.h
+++ b/fs/9p/xattr.h
@@ -27,6 +27,8 @@ extern ssize_t v9fs_fid_xattr_get(struct p9_fid *, const char *,
27 void *, size_t); 27 void *, size_t);
28extern ssize_t v9fs_xattr_get(struct dentry *, const char *, 28extern ssize_t v9fs_xattr_get(struct dentry *, const char *,
29 void *, size_t); 29 void *, size_t);
30extern int v9fs_fid_xattr_set(struct p9_fid *, const char *,
31 const void *, size_t, int);
30extern int v9fs_xattr_set(struct dentry *, const char *, 32extern int v9fs_xattr_set(struct dentry *, const char *,
31 const void *, size_t, int); 33 const void *, size_t, int);
32extern ssize_t v9fs_listxattr(struct dentry *, char *, size_t); 34extern ssize_t v9fs_listxattr(struct dentry *, char *, size_t);