shithub: 9pro

Download patch

ref: 1a12079c7124c8ceb79a4644715d21bdf5328314
parent: b0e40047171b6e9274719cbf5ac1c1c39254ed17
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Dec 22 12:31:03 EST 2019

trace for regular file read

--- a/9pex.c
+++ b/9pex.c
@@ -489,6 +489,30 @@
 }
 
 static int
+s9do(C9error e, char **err)
+{
+	if (e == 0) {
+		*err = NULL;
+		return 0;
+	}
+
+	switch (e) {
+	case C9Einit: *err = "c9: initialization failed"; break;
+	case C9Ever: *err = "c9: protocol version doesn't match"; break;
+	case C9Epkt: *err = "c9: incoming packet error"; break;
+	case C9Etag: *err = "c9: no free tags or bad tag"; break;
+	case C9Ebuf: *err = Enomem; break;
+	case C9Epath: *err = "c9: path is too long or just invalid"; break;
+	case C9Eflush: *err = "c9: limit of outstanding flushes reached"; break;
+	case C9Esize: *err = "c9: can't fit data in one message"; break;
+	case C9Estr: *err = "c9: bad string"; break;
+	default: *err = "c9: unknown error"; break;
+	}
+
+	return -1;
+}
+
+static int
 readf(C9ctx *c, C9tag tag, Fid *f, uint64_t offset, uint32_t size, char **err)
 {
 	struct stat st;
@@ -511,7 +535,9 @@
 			*err = strerror(errno);
 			return -1;
 		}
-		s9read(c, tag, p, n);
+		if (s9do(s9read(c, tag, p, n), err) != 0)
+			return -1;
+		trace("<- Rread tag=%d count=%d ...\n", tag, n);
 		return 0;
 	}
 
@@ -557,30 +583,6 @@
 		seekdir(f->dir, dirpos[num]);
 
 	return 0;
-}
-
-static int
-s9do(C9error e, char **err)
-{
-	if (e == 0) {
-		*err = NULL;
-		return 0;
-	}
-
-	switch (e) {
-	case C9Einit: *err = "c9: initialization failed"; break;
-	case C9Ever: *err = "c9: protocol version doesn't match"; break;
-	case C9Epkt: *err = "c9: incoming packet error"; break;
-	case C9Etag: *err = "c9: no free tags or bad tag"; break;
-	case C9Ebuf: *err = Enomem; break;
-	case C9Epath: *err = "c9: path is too long or just invalid"; break;
-	case C9Eflush: *err = "c9: limit of outstanding flushes reached"; break;
-	case C9Esize: *err = "c9: can't fit data in one message"; break;
-	case C9Estr: *err = "c9: bad string"; break;
-	default: *err = "c9: unknown error"; break;
-	}
-
-	return -1;
 }
 
 static void