Skip to contentSkip to conversation

v9fs: fix handling of malformed 9P messages

PATCH New Eric Van Hensbergen 1 participant 1 message Aug 28, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 v9fs: fix handling of malformed 9P messages

[PATCH] v9fs: fix handling of malformed 9P messages

This patch attempts to do a better job of cleaning up after detecting errors on the transport. This should also improve error reporting on broken connections to servers.

---
commit 97bc19b509356dda0145cd19fb9768ac3c88ecda
tree f12a9e827c949f386cca42b718bac63405e9192d
parent 2b2ebf0cea451ad876ab29159162571b5291f8b7
author Eric Van Hensbergen <[email protected]> Sun, 28 Aug 2005 13:11:33 -0500
committer Eric Van Hensbergen <[email protected]> Sun, 28 Aug 2005 13:11:33 -0500

 fs/9p/error.h      |    1 +
 fs/9p/mux.c        |   53
+++++++++++++++++++++++++++++++++-------------------
 fs/9p/mux.h        |    1 +
 fs/9p/trans_sock.c |   12 ++++++++++--
 4 files changed, 46 insertions(+), 21 deletions(-)
fs/9p/error.h +1 -0
@@ -47,6 +47,7 @@ static struct errormap errmap[] = {
 	{"Operation not permitted", EPERM},
 	{"wstat prohibited", EPERM},
 	{"No such file or directory", ENOENT},
+	{"directory entry not found", ENOENT},
 	{"file not found", ENOENT},
 	{"Interrupted system call", EINTR},
 	{"Input/output error", EIO},
fs/9p/mux.c +34 -19

95 lines not on this page · raw message

fs/9p/mux.h +1 -0
@@ -28,6 +28,7 @@
 struct v9fs_rpcreq {
 	struct v9fs_fcall *tcall;
 	struct v9fs_fcall *rcall;
+	int err;	/* error code if response failed */
 
 	/* XXX - could we put scatter/gather buffers here? */
 
fs/9p/trans_sock.c +10 -2
@@ -246,7 +246,12 @@ v9fs_unix_init(struct v9fs_session_info 
 
 static void v9fs_sock_close(struct v9fs_transport *trans)
 {
-	struct v9fs_trans_sock *ts = trans ? trans->priv : NULL;
+	struct v9fs_trans_sock *ts;
+
+	if (!trans)
+		return;
+
+	ts = trans->priv;
 
 	if ((ts) && (ts->s)) {
 		dprintk(DEBUG_TRANS, "closing the socket %p\n", ts->s);
@@ -256,7 +261,10 @@ static void v9fs_sock_close(struct v9fs_
 		dprintk(DEBUG_TRANS, "socket closed\n");
 	}
 
-	kfree(ts);
+	if (ts)
+		kfree(ts);
+
+	trans->priv = NULL;
 }
 
 struct v9fs_transport v9fs_trans_tcp = {