aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p/vfs_inode.c
diff options
context:
space:
mode:
authorLatchesar Ionkov <lucho@ionkov.net>2006-03-25 06:07:26 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-25 11:22:54 -0500
commit16cce6d27ef52e00cc124196046bbae7150024c1 (patch)
treed4494a6a5146fa7314138f674c2928e31c26bcc0 /fs/9p/vfs_inode.c
parent5174fdab9f58181249debab6e959ae4fd4abd0ed (diff)
[PATCH] v9fs: add extension field to Tcreate
Implement a new way of creating special files. Instead of Tcreate+Twstat, add one more field to Tcreate that contains special file description. Signed-off-by: Latchesar Ionkov <lucho@ionkov.net> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/9p/vfs_inode.c')
-rw-r--r--fs/9p/vfs_inode.c47
1 files changed, 19 insertions, 28 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index e46bb5a82e1a..dc67f83d0dae 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -255,8 +255,8 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
255} 255}
256 256
257static int 257static int
258v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name, 258v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name, u32 perm,
259 u32 perm, u8 mode, u32 *fidp, struct v9fs_qid *qid, u32 *iounit) 259 u8 mode, char *extension, u32 *fidp, struct v9fs_qid *qid, u32 *iounit)
260{ 260{
261 u32 fid; 261 u32 fid;
262 int err; 262 int err;
@@ -271,14 +271,14 @@ v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name,
271 err = v9fs_t_walk(v9ses, pfid, fid, NULL, &fcall); 271 err = v9fs_t_walk(v9ses, pfid, fid, NULL, &fcall);
272 if (err < 0) { 272 if (err < 0) {
273 PRINT_FCALL_ERROR("clone error", fcall); 273 PRINT_FCALL_ERROR("clone error", fcall);
274 goto error; 274 goto put_fid;
275 } 275 }
276 kfree(fcall); 276 kfree(fcall);
277 277
278 err = v9fs_t_create(v9ses, fid, name, perm, mode, &fcall); 278 err = v9fs_t_create(v9ses, fid, name, perm, mode, extension, &fcall);
279 if (err < 0) { 279 if (err < 0) {
280 PRINT_FCALL_ERROR("create fails", fcall); 280 PRINT_FCALL_ERROR("create fails", fcall);
281 goto error; 281 goto clunk_fid;
282 } 282 }
283 283
284 if (iounit) 284 if (iounit)
@@ -293,7 +293,11 @@ v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name,
293 kfree(fcall); 293 kfree(fcall);
294 return 0; 294 return 0;
295 295
296error: 296clunk_fid:
297 v9fs_t_clunk(v9ses, fid);
298 fid = V9FS_NOFID;
299
300put_fid:
297 if (fid >= 0) 301 if (fid >= 0)
298 v9fs_put_idpool(fid, &v9ses->fidpool); 302 v9fs_put_idpool(fid, &v9ses->fidpool);
299 303
@@ -474,7 +478,7 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode,
474 flags = O_RDWR; 478 flags = O_RDWR;
475 479
476 err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name, 480 err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name,
477 perm, v9fs_uflags2omode(flags), &fid, &qid, &iounit); 481 perm, v9fs_uflags2omode(flags), NULL, &fid, &qid, &iounit);
478 482
479 if (err) 483 if (err)
480 goto error; 484 goto error;
@@ -550,7 +554,7 @@ static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
550 perm = unixmode2p9mode(v9ses, mode | S_IFDIR); 554 perm = unixmode2p9mode(v9ses, mode | S_IFDIR);
551 555
552 err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name, 556 err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name,
553 perm, V9FS_OREAD, &fid, NULL, NULL); 557 perm, V9FS_OREAD, NULL, &fid, NULL, NULL);
554 558
555 if (err) { 559 if (err) {
556 dprintk(DEBUG_ERROR, "create error %d\n", err); 560 dprintk(DEBUG_ERROR, "create error %d\n", err);
@@ -1008,11 +1012,13 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)
1008 1012
1009 /* copy extension buffer into buffer */ 1013 /* copy extension buffer into buffer */
1010 if (fcall->params.rstat.stat.extension.len < buflen) 1014 if (fcall->params.rstat.stat.extension.len < buflen)
1011 buflen = fcall->params.rstat.stat.extension.len; 1015 buflen = fcall->params.rstat.stat.extension.len + 1;
1012 1016
1013 memcpy(buffer, fcall->params.rstat.stat.extension.str, buflen - 1); 1017 memmove(buffer, fcall->params.rstat.stat.extension.str, buflen - 1);
1014 buffer[buflen-1] = 0; 1018 buffer[buflen-1] = 0;
1015 1019
1020 dprintk(DEBUG_ERROR, "%s -> %.*s (%s)\n", dentry->d_name.name, fcall->params.rstat.stat.extension.len,
1021 fcall->params.rstat.stat.extension.str, buffer);
1016 retval = buflen; 1022 retval = buflen;
1017 1023
1018 FreeFcall: 1024 FreeFcall:
@@ -1072,7 +1078,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
1072 if (!link) 1078 if (!link)
1073 link = ERR_PTR(-ENOMEM); 1079 link = ERR_PTR(-ENOMEM);
1074 else { 1080 else {
1075 len = v9fs_readlink(dentry, link, strlen(link)); 1081 len = v9fs_readlink(dentry, link, PATH_MAX);
1076 1082
1077 if (len < 0) { 1083 if (len < 0) {
1078 __putname(link); 1084 __putname(link);
@@ -1109,10 +1115,7 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1109 struct v9fs_session_info *v9ses; 1115 struct v9fs_session_info *v9ses;
1110 struct v9fs_fid *dfid, *vfid; 1116 struct v9fs_fid *dfid, *vfid;
1111 struct inode *inode; 1117 struct inode *inode;
1112 struct v9fs_fcall *fcall;
1113 struct v9fs_wstat wstat;
1114 1118
1115 fcall = NULL;
1116 inode = NULL; 1119 inode = NULL;
1117 vfid = NULL; 1120 vfid = NULL;
1118 v9ses = v9fs_inode2v9ses(dir); 1121 v9ses = v9fs_inode2v9ses(dir);
@@ -1125,7 +1128,7 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1125 } 1128 }
1126 1129
1127 err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name, 1130 err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name,
1128 perm, V9FS_OREAD, &fid, NULL, NULL); 1131 perm, V9FS_OREAD, (char *) extension, &fid, NULL, NULL);
1129 1132
1130 if (err) 1133 if (err)
1131 goto error; 1134 goto error;
@@ -1148,23 +1151,11 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1148 goto error; 1151 goto error;
1149 } 1152 }
1150 1153
1151 /* issue a Twstat */
1152 v9fs_blank_wstat(&wstat);
1153 wstat.muid = v9ses->name;
1154 wstat.extension = (char *) extension;
1155 err = v9fs_t_wstat(v9ses, vfid->fid, &wstat, &fcall);
1156 if (err < 0) {
1157 PRINT_FCALL_ERROR("wstat error", fcall);
1158 goto error;
1159 }
1160
1161 kfree(fcall);
1162 dentry->d_op = &v9fs_dentry_operations; 1154 dentry->d_op = &v9fs_dentry_operations;
1163 d_instantiate(dentry, inode); 1155 d_instantiate(dentry, inode);
1164 return 0; 1156 return 0;
1165 1157
1166error: 1158error:
1167 kfree(fcall);
1168 if (vfid) 1159 if (vfid)
1169 v9fs_fid_destroy(vfid); 1160 v9fs_fid_destroy(vfid);
1170 1161
@@ -1224,7 +1215,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
1224 } 1215 }
1225 1216
1226 name = __getname(); 1217 name = __getname();
1227 sprintf(name, "hardlink(%d)\n", oldfid->fid); 1218 sprintf(name, "%d\n", oldfid->fid);
1228 retval = v9fs_vfs_mkspecial(dir, dentry, V9FS_DMLINK, name); 1219 retval = v9fs_vfs_mkspecial(dir, dentry, V9FS_DMLINK, name);
1229 __putname(name); 1220 __putname(name);
1230 1221