diff rvinterf/tmsh/ffs2.c @ 261:7f14d7c789a7

fc-tmsh ffs2: most commands implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Wed, 05 Feb 2014 05:48:47 +0000
parents c146f38d2b5f
children b5b54feb111a
line wrap: on
line diff
--- a/rvinterf/tmsh/ffs2.c	Wed Feb 05 04:02:13 2014 +0000
+++ b/rvinterf/tmsh/ffs2.c	Wed Feb 05 05:48:47 2014 +0000
@@ -11,6 +11,7 @@
 #include "limits.h"
 #include "localtypes.h"
 #include "etm.h"
+#include "ffs.h"
 #include "tmffs2.h"
 
 void
@@ -34,7 +35,7 @@
 
 	slen = strlen(argv[1]);
 	if (slen >= TMFFS_STRING_SIZE) {
-		printf("error: argument exceeds string length limit\n");
+		printf("error: pathname arg exceeds string length limit\n");
 		return;
 	}
 	dp = cmdpkt + 1;
@@ -71,6 +72,27 @@
 }
 
 void
+cmd_ffs2_mkdir(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
+	int slen;
+
+	slen = strlen(argv[1]);
+	if (slen >= TMFFS_STRING_SIZE) {
+		printf("error: pathname arg exceeds string length limit\n");
+		return;
+	}
+	dp = cmdpkt + 1;
+	*dp++ = ETM_FFS2;
+	*dp++ = TMFFS_MKDIR;
+	*dp++ = slen + 1;
+	strcpy(dp, argv[1]);
+	dp += slen + 1;
+	send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
+}
+
+void
 cmd_ffs2_open(argc, argv)
 	char **argv;
 {
@@ -79,7 +101,7 @@
 
 	slen = strlen(argv[1]);
 	if (slen >= TMFFS_STRING_SIZE) {
-		printf("error: argument exceeds string length limit\n");
+		printf("error: pathname arg exceeds string length limit\n");
 		return;
 	}
 	dp = cmdpkt + 1;
@@ -93,6 +115,27 @@
 }
 
 void
+cmd_ffs2_opendir(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
+	int slen;
+
+	slen = strlen(argv[1]);
+	if (slen >= TMFFS_STRING_SIZE) {
+		printf("error: pathname arg exceeds string length limit\n");
+		return;
+	}
+	dp = cmdpkt + 1;
+	*dp++ = ETM_FFS2;
+	*dp++ = TMFFS_OPENDIR;
+	*dp++ = slen + 1;
+	strcpy(dp, argv[1]);
+	dp += slen + 1;
+	send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
+}
+
+void
 cmd_ffs2_preformat()
 {
 	u_char cmdpkt[6];
@@ -106,6 +149,74 @@
 }
 
 void
+cmd_ffs2_query(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[5];
+
+	cmdpkt[1] = ETM_FFS2;
+	cmdpkt[2] = TMFFS_QUERY;
+	cmdpkt[3] = strtoul(argv[1], 0, 0);
+	send_etm_cmd(cmdpkt, 3);
+}
+
+void
+cmd_ffs2_readfd(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[6];
+
+	cmdpkt[1] = ETM_FFS2;
+	cmdpkt[2] = TMFFS_READ;
+	cmdpkt[3] = strtoul(argv[1], 0, 0);
+	cmdpkt[4] = strtoul(argv[2], 0, 0);
+	send_etm_cmd(cmdpkt, 4);
+}
+
+void
+cmd_ffs2_readfile(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
+	int slen;
+
+	slen = strlen(argv[1]);
+	if (slen >= TMFFS_STRING_SIZE) {
+		printf("error: pathname arg exceeds string length limit\n");
+		return;
+	}
+	dp = cmdpkt + 1;
+	*dp++ = ETM_FFS2;
+	*dp++ = TMFFS_FILE_READ;
+	*dp++ = slen + 1;
+	strcpy(dp, argv[1]);
+	dp += slen + 1;
+	*dp++ = strtoul(argv[2], 0, 0);
+	send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
+}
+
+void
+cmd_ffs2_stat(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
+	int slen;
+
+	slen = strlen(argv[1]);
+	if (slen >= TMFFS_STRING_SIZE) {
+		printf("error: pathname arg exceeds string length limit\n");
+		return;
+	}
+	dp = cmdpkt + 1;
+	*dp++ = ETM_FFS2;
+	*dp++ = TMFFS_STAT;
+	*dp++ = slen + 1;
+	strcpy(dp, argv[1]);
+	dp += slen + 1;
+	send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
+}
+
+void
 cmd_ffs2_version()
 {
 	u_char cmdpkt[4];
@@ -115,6 +226,79 @@
 	send_etm_cmd(cmdpkt, 2);
 }
 
+void
+cmd_ffs2_wrfile(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
+	int slen, slen2;
+
+	slen = strlen(argv[1]);
+	if (slen >= TMFFS_STRING_SIZE) {
+		printf("error: pathname arg exceeds string length limit\n");
+		return;
+	}
+	slen2 = strlen(argv[2]);
+	if (slen2 > 64) {
+		printf("error: write test data argument is too long\n");
+		return;
+	}
+	dp = cmdpkt + 1;
+	*dp++ = ETM_FFS2;
+	*dp++ = TMFFS_FILE_WRITE;
+	*dp++ = slen + 1;
+	strcpy(dp, argv[1]);
+	dp += slen + 1;
+	*dp++ = slen2;		/* no NUL-termination on test data */
+	strcpy(dp, argv[2]);
+	dp += slen2;
+	*dp++ = FFS_O_CREATE | FFS_O_TRUNC;
+	send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
+}
+
+void
+cmd_ffs2_writefd(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
+	int slen2;
+
+	slen2 = strlen(argv[2]);
+	if (slen2 > 64) {
+		printf("error: write test data argument is too long\n");
+		return;
+	}
+	dp = cmdpkt + 1;
+	*dp++ = ETM_FFS2;
+	*dp++ = TMFFS_WRITE;
+	*dp++ = strtoul(argv[1], 0, 0);
+	*dp++ = slen2;		/* no NUL-termination on test data */
+	strcpy(dp, argv[2]);
+	dp += slen2;
+	send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
+}
+
+void
+cmd_ffs2_xlstat(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
+	int slen;
+
+	slen = strlen(argv[1]);
+	if (slen >= TMFFS_STRING_SIZE) {
+		printf("error: pathname arg exceeds string length limit\n");
+		return;
+	}
+	dp = cmdpkt + 1;
+	*dp++ = ETM_FFS2;
+	*dp++ = TMFFS_XLSTAT;
+	*dp++ = slen + 1;
+	strcpy(dp, argv[1]);
+	dp += slen + 1;
+	send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
+}
+
 static struct cmdtab {
 	char *cmd;
 	int minargs;
@@ -124,9 +308,18 @@
 	{"close", 1, 1, cmd_ffs2_close},
 	{"delete", 1, 1, cmd_ffs2_delete},
 	{"format", 1, 1, cmd_ffs2_format},
+	{"mkdir", 1, 1, cmd_ffs2_mkdir},
 	{"open", 2, 2, cmd_ffs2_open},
+	{"opendir", 1, 1, cmd_ffs2_opendir},
 	{"preformat", 0, 0, cmd_ffs2_preformat},
+	{"query", 1, 1, cmd_ffs2_query},
+	{"readfd", 2, 2, cmd_ffs2_readfd},
+	{"readfile", 2, 2, cmd_ffs2_readfile},
+	{"stat", 1, 1, cmd_ffs2_stat},
 	{"version", 0, 0, cmd_ffs2_version},
+	{"wrfile", 2, 2, cmd_ffs2_wrfile},
+	{"writefd", 2, 2, cmd_ffs2_writefd},
+	{"xlstat", 1, 1, cmd_ffs2_xlstat},
 	{0, 0, 0, 0}
 };