annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
258
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * In this module we are going to implement TMFFS2 functionality.
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <string.h>
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <strings.h>
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <stdlib.h>
260
c146f38d2b5f rvinterf subdir structure made a little more sensible
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 259
diff changeset
10 #include "pktmux.h"
c146f38d2b5f rvinterf subdir structure made a little more sensible
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 259
diff changeset
11 #include "limits.h"
258
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "localtypes.h"
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "etm.h"
261
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
14 #include "ffs.h"
258
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 #include "tmffs2.h"
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 void
259
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
18 cmd_ffs2_close(argc, argv)
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
19 char **argv;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
20 {
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
21 u_char cmdpkt[5];
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
22
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
23 cmdpkt[1] = ETM_FFS2;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
24 cmdpkt[2] = TMFFS_CLOSE;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
25 cmdpkt[3] = strtoul(argv[1], 0, 0);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
26 send_etm_cmd(cmdpkt, 3);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
27 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
28
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
29 void
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
30 cmd_ffs2_delete(argc, argv)
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
31 char **argv;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
32 {
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
33 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
34 int slen;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
35
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
36 slen = strlen(argv[1]);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
37 if (slen >= TMFFS_STRING_SIZE) {
261
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
38 printf("error: pathname arg exceeds string length limit\n");
259
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
39 return;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
40 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
41 dp = cmdpkt + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
42 *dp++ = ETM_FFS2;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
43 *dp++ = TMFFS_REMOVE;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
44 *dp++ = slen + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
45 strcpy(dp, argv[1]);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
46 dp += slen + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
47 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
48 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
49
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
50 void
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
51 cmd_ffs2_format(argc, argv)
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
52 char **argv;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
53 {
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
54 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
55 int slen;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
56
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
57 slen = strlen(argv[1]);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
58 if (slen >= TMFFS_STRING_SIZE) {
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
59 printf("error: argument exceeds string length limit\n");
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
60 return;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
61 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
62 dp = cmdpkt + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
63 *dp++ = ETM_FFS2;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
64 *dp++ = TMFFS_FORMAT;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
65 *dp++ = slen + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
66 strcpy(dp, argv[1]);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
67 dp += slen + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
68 /* magic is 0x2BAD, 16-bit little-endian */
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
69 *dp++ = 0xAD;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
70 *dp++ = 0x2B;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
71 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
72 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
73
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
74 void
261
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
75 cmd_ffs2_mkdir(argc, argv)
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
76 char **argv;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
77 {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
78 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
79 int slen;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
80
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
81 slen = strlen(argv[1]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
82 if (slen >= TMFFS_STRING_SIZE) {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
83 printf("error: pathname arg exceeds string length limit\n");
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
84 return;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
85 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
86 dp = cmdpkt + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
87 *dp++ = ETM_FFS2;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
88 *dp++ = TMFFS_MKDIR;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
89 *dp++ = slen + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
90 strcpy(dp, argv[1]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
91 dp += slen + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
92 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
93 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
94
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
95 void
259
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
96 cmd_ffs2_open(argc, argv)
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
97 char **argv;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
98 {
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
99 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
100 int slen;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
101
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
102 slen = strlen(argv[1]);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
103 if (slen >= TMFFS_STRING_SIZE) {
261
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
104 printf("error: pathname arg exceeds string length limit\n");
259
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
105 return;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
106 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
107 dp = cmdpkt + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
108 *dp++ = ETM_FFS2;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
109 *dp++ = TMFFS_OPEN;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
110 *dp++ = slen + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
111 strcpy(dp, argv[1]);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
112 dp += slen + 1;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
113 *dp++ = strtoul(argv[2], 0, 16);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
114 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
115 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
116
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
117 void
261
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
118 cmd_ffs2_opendir(argc, argv)
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
119 char **argv;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
120 {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
121 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
122 int slen;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
123
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
124 slen = strlen(argv[1]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
125 if (slen >= TMFFS_STRING_SIZE) {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
126 printf("error: pathname arg exceeds string length limit\n");
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
127 return;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
128 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
129 dp = cmdpkt + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
130 *dp++ = ETM_FFS2;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
131 *dp++ = TMFFS_OPENDIR;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
132 *dp++ = slen + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
133 strcpy(dp, argv[1]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
134 dp += slen + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
135 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
136 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
137
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
138 void
259
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
139 cmd_ffs2_preformat()
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
140 {
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
141 u_char cmdpkt[6];
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
142
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
143 cmdpkt[1] = ETM_FFS2;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
144 cmdpkt[2] = TMFFS_PREFORMAT;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
145 /* magic is 0xDEAD, 16-bit little-endian */
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
146 cmdpkt[3] = 0xAD;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
147 cmdpkt[4] = 0xDE;
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
148 send_etm_cmd(cmdpkt, 4);
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
149 }
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
150
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
151 void
261
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
152 cmd_ffs2_query(argc, argv)
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
153 char **argv;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
154 {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
155 u_char cmdpkt[5];
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
156
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
157 cmdpkt[1] = ETM_FFS2;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
158 cmdpkt[2] = TMFFS_QUERY;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
159 cmdpkt[3] = strtoul(argv[1], 0, 0);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
160 send_etm_cmd(cmdpkt, 3);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
161 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
162
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
163 void
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
164 cmd_ffs2_readfd(argc, argv)
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
165 char **argv;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
166 {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
167 u_char cmdpkt[6];
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
168
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
169 cmdpkt[1] = ETM_FFS2;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
170 cmdpkt[2] = TMFFS_READ;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
171 cmdpkt[3] = strtoul(argv[1], 0, 0);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
172 cmdpkt[4] = strtoul(argv[2], 0, 0);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
173 send_etm_cmd(cmdpkt, 4);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
174 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
175
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
176 void
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
177 cmd_ffs2_readfile(argc, argv)
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
178 char **argv;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
179 {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
180 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
181 int slen;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
182
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
183 slen = strlen(argv[1]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
184 if (slen >= TMFFS_STRING_SIZE) {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
185 printf("error: pathname arg exceeds string length limit\n");
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
186 return;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
187 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
188 dp = cmdpkt + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
189 *dp++ = ETM_FFS2;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
190 *dp++ = TMFFS_FILE_READ;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
191 *dp++ = slen + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
192 strcpy(dp, argv[1]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
193 dp += slen + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
194 *dp++ = strtoul(argv[2], 0, 0);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
195 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
196 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
197
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
198 void
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
199 cmd_ffs2_stat(argc, argv)
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
200 char **argv;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
201 {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
202 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
203 int slen;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
204
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
205 slen = strlen(argv[1]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
206 if (slen >= TMFFS_STRING_SIZE) {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
207 printf("error: pathname arg exceeds string length limit\n");
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
208 return;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
209 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
210 dp = cmdpkt + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
211 *dp++ = ETM_FFS2;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
212 *dp++ = TMFFS_STAT;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
213 *dp++ = slen + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
214 strcpy(dp, argv[1]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
215 dp += slen + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
216 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
217 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
218
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
219 void
258
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
220 cmd_ffs2_version()
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
221 {
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
222 u_char cmdpkt[4];
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
223
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
224 cmdpkt[1] = ETM_FFS2;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
225 cmdpkt[2] = TMFFS_VERSION;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
226 send_etm_cmd(cmdpkt, 2);
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
227 }
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
228
261
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
229 void
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
230 cmd_ffs2_wrfile(argc, argv)
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
231 char **argv;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
232 {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
233 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
234 int slen, slen2;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
235
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
236 slen = strlen(argv[1]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
237 if (slen >= TMFFS_STRING_SIZE) {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
238 printf("error: pathname arg exceeds string length limit\n");
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
239 return;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
240 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
241 slen2 = strlen(argv[2]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
242 if (slen2 > 64) {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
243 printf("error: write test data argument is too long\n");
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
244 return;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
245 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
246 dp = cmdpkt + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
247 *dp++ = ETM_FFS2;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
248 *dp++ = TMFFS_FILE_WRITE;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
249 *dp++ = slen + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
250 strcpy(dp, argv[1]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
251 dp += slen + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
252 *dp++ = slen2; /* no NUL-termination on test data */
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
253 strcpy(dp, argv[2]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
254 dp += slen2;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
255 *dp++ = FFS_O_CREATE | FFS_O_TRUNC;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
256 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
257 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
258
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
259 void
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
260 cmd_ffs2_writefd(argc, argv)
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
261 char **argv;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
262 {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
263 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
264 int slen2;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
265
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
266 slen2 = strlen(argv[2]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
267 if (slen2 > 64) {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
268 printf("error: write test data argument is too long\n");
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
269 return;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
270 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
271 dp = cmdpkt + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
272 *dp++ = ETM_FFS2;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
273 *dp++ = TMFFS_WRITE;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
274 *dp++ = strtoul(argv[1], 0, 0);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
275 *dp++ = slen2; /* no NUL-termination on test data */
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
276 strcpy(dp, argv[2]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
277 dp += slen2;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
278 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
279 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
280
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
281 void
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
282 cmd_ffs2_xlstat(argc, argv)
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
283 char **argv;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
284 {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
285 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
286 int slen;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
287
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
288 slen = strlen(argv[1]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
289 if (slen >= TMFFS_STRING_SIZE) {
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
290 printf("error: pathname arg exceeds string length limit\n");
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
291 return;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
292 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
293 dp = cmdpkt + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
294 *dp++ = ETM_FFS2;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
295 *dp++ = TMFFS_XLSTAT;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
296 *dp++ = slen + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
297 strcpy(dp, argv[1]);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
298 dp += slen + 1;
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
299 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
300 }
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
301
258
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
302 static struct cmdtab {
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
303 char *cmd;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
304 int minargs;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
305 int maxargs;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
306 void (*func)();
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
307 } ffs2_cmds[] = {
259
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
308 {"close", 1, 1, cmd_ffs2_close},
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
309 {"delete", 1, 1, cmd_ffs2_delete},
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
310 {"format", 1, 1, cmd_ffs2_format},
261
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
311 {"mkdir", 1, 1, cmd_ffs2_mkdir},
259
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
312 {"open", 2, 2, cmd_ffs2_open},
261
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
313 {"opendir", 1, 1, cmd_ffs2_opendir},
259
35113b1964d3 fc-tmsh ffs2: a few request-sending commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 258
diff changeset
314 {"preformat", 0, 0, cmd_ffs2_preformat},
261
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
315 {"query", 1, 1, cmd_ffs2_query},
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
316 {"readfd", 2, 2, cmd_ffs2_readfd},
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
317 {"readfile", 2, 2, cmd_ffs2_readfile},
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
318 {"stat", 1, 1, cmd_ffs2_stat},
258
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
319 {"version", 0, 0, cmd_ffs2_version},
261
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
320 {"wrfile", 2, 2, cmd_ffs2_wrfile},
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
321 {"writefd", 2, 2, cmd_ffs2_writefd},
7f14d7c789a7 fc-tmsh ffs2: most commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 260
diff changeset
322 {"xlstat", 1, 1, cmd_ffs2_xlstat},
258
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
323 {0, 0, 0, 0}
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
324 };
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
325
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
326 void
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
327 cmd_ffs2(argc, argv)
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
328 char **argv;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
329 {
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
330 struct cmdtab *tp;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
331 int extargs;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
332
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
333 for (tp = ffs2_cmds; tp->cmd; tp++)
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
334 if (!strcmp(tp->cmd, argv[1]))
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
335 break;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
336 if (!tp->func) {
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
337 printf("error: no such ffs2 command\n");
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
338 return;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
339 }
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
340 extargs = argc - 2;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
341 if (extargs > tp->maxargs) {
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
342 printf("error: too many arguments\n");
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
343 return;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
344 }
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
345 if (extargs < tp->minargs) {
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
346 printf("error: too few arguments\n");
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
347 return;
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
348 }
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
349 tp->func(argc - 1, argv + 1);
ab66a2eea6a8 fc-tmsh: beginning of ffs2 command dispatch
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
350 }