annotate rvinterf/tmsh/ffs2.c @ 888:0590cfd5803f

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