Commit Diff


commit - 36b30273d4a241ff11725191fd670029335ad188
commit + 5ed7f718a952eec4a57551943b63b00fe3c20643
blob - 88934113293d4cf07e877bff43df7d3def99885a
blob + b7ee8e39400eae7cd8b15ec73e2afaf33e0de179
--- kamirepl.c
+++ kamirepl.c
@@ -73,10 +73,12 @@ static void		 write_hdr(uint32_t, uint8_t, uint16_t);
 static void		 write_hdr_auto(uint32_t, uint8_t);
 static void		 write_str(uint16_t, const char *);
 static void		 write_fid(uint32_t);
+static void		 write_tag(uint16_t);
 
 static void		 excmd_version(const char **, int);
 static void		 excmd_attach(const char **, int);
 static void		 excmd_clunk(const char **, int);
+static void		 excmd_flush(const char **, int);
 static void		 excmd(const char **, int);
 
 static const char	*pp_qid_type(uint8_t);
@@ -389,6 +391,13 @@ write_fid(uint32_t fid)
 {
 	fid = htole32(fid);
 	bufferevent_write(bev, &fid, sizeof(fid));
+}
+
+static void
+write_tag(uint16_t tag)
+{
+	tag = htole16(tag);
+	bufferevent_write(bev, &tag, sizeof(tag));
 }
 
 /* version [version-str] */
@@ -475,6 +484,33 @@ excmd_clunk(const char **argv, int argc)
 
 usage:
 	log_warnx("usage: clunk fid");
+}
+
+/* flush oldtag */
+static void
+excmd_flush(const char **argv, int argc)
+{
+	uint32_t	 len;
+	uint16_t	 oldtag;
+	const char	*errstr;
+
+	if (argc != 2)
+		goto usage;
+
+	oldtag = strtonum(argv[1], 0, UINT16_MAX, &errstr);
+	if (errstr != NULL) {
+		log_warnx("oldtag is %s: %s", errstr, argv[1]);
+		return;
+	}
+
+	/* oldtag[2] */
+	len = sizeof(oldtag);
+	write_hdr_auto(len, Tflush);
+	write_tag(oldtag);
+	return;
+
+usage:
+	log_warnx("usage: flush oldtag");
 }
 
 static void
@@ -487,6 +523,7 @@ excmd(const char **argv, int argc)
 		{"version",	excmd_version},
 		{"attach",	excmd_attach},
 		{"clunk",	excmd_clunk},
+		{"flush",	excmd_flush},
 	};
 	size_t i;
 
@@ -597,6 +634,11 @@ pp_msg(uint32_t len, uint8_t type, uint16_t tag, const
 			printf("invalid Rclunk: %"PRIu32" extra bytes", len);
 		break;
 
+	case Rflush:
+		if (len != 0)
+			printf("invalid Rflush: %"PRIu32" extra bytes", len);
+		break;
+
 	case Rerror:
 		memcpy(&slen, d, sizeof(slen));
 		d += sizeof(slen);