FreeCalypso > hg > freecalypso-sw
annotate rvinterf/etmsync/fileio.c @ 865:f5affe83ba2d
lldbg hack (poor girl's substitute for JTAG) implemented
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Fri, 15 May 2015 00:02:03 +0000 |
parents | ffeea2f9d149 |
children | d1333db6385f |
rev | line source |
---|---|
284
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * FFS2 file descriptor I/O operations |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdlib.h> |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <string.h> |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <strings.h> |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "etm.h" |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "ffs.h" |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "tmffs2.h" |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "limits.h" |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 #include "localtypes.h" |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 #include "localstruct.h" |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 #include "exitcodes.h" |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 extern u_char rvi_msg[]; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 extern int rvi_msg_len; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 fd_open(pathname, flags, fdrtn) |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 char *pathname; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 int flags, *fdrtn; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 { |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 int rc, slen; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 slen = strlen(pathname); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 if (slen >= TMFFS_STRING_SIZE) { |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 printf("error: pathname arg exceeds string length limit\n"); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 return(ERROR_USAGE); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 } |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 dp = cmdpkt + 1; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 *dp++ = ETM_FFS2; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 *dp++ = TMFFS_OPEN; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 *dp++ = slen + 1; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 strcpy(dp, pathname); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 dp += slen + 1; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 *dp++ = flags; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 if (rc) |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 return(rc); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 if (rvi_msg[3]) { |
289
244f08f58e51
fc-fsio: error decoding implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
286
diff
changeset
|
44 report_ffs_err("open fd", rvi_msg[3]); |
284
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 return(ERROR_TARGET); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 } |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 if (rvi_msg_len != 6) { |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 printf("error: open fd response has wrong length\n"); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 return(ERROR_TARGET); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 } |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 *fdrtn = rvi_msg[4]; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 return(0); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 } |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 fd_read(fd, databuf, rdsize, rdret) |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 u_char *databuf; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 int fd, rdsize, *rdret; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 { |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 u_char cmdpkt[6]; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 int rc, sz; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 if (rdsize > MAX_READ_DATA) { |
286
146e7bf3fa4e
fc-fsio: fd debug commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
63 printf("error: # of bytes to read may not exceed %d\n", |
146e7bf3fa4e
fc-fsio: fd debug commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
64 MAX_READ_DATA); |
146e7bf3fa4e
fc-fsio: fd debug commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
65 return(ERROR_USAGE); |
284
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 } |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 cmdpkt[1] = ETM_FFS2; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 cmdpkt[2] = TMFFS_READ; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 cmdpkt[3] = fd; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 cmdpkt[4] = rdsize; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 rc = etm_pkt_exch(cmdpkt, 4); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 if (rc) |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 return(rc); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 if (rvi_msg[3]) { |
289
244f08f58e51
fc-fsio: error decoding implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
286
diff
changeset
|
75 report_ffs_err("read fd", rvi_msg[3]); |
284
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 return(ERROR_TARGET); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 } |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 if (rvi_msg_len < 6) { |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 *rdret = 0; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 return(0); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 } |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 sz = rvi_msg[4]; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 if (rvi_msg_len != sz + 6 || sz > rdsize) { |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 printf("error: read fd response has wrong length\n"); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 return(ERROR_TARGET); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 } |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 bcopy(rvi_msg + 5, databuf, sz); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 *rdret = sz; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 return(0); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 } |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 |
293
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
92 fd_write(fd, data, wrsize) |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
93 u_char *data; |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
94 { |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
95 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
96 int rc; |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
97 |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
98 if (wrsize > MAX_PKT_TO_TARGET - 6) { |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
99 printf("error: fd write data fails to fit in the packet\n"); |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
100 return(ERROR_USAGE); |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
101 } |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
102 dp = cmdpkt + 1; |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
103 *dp++ = ETM_FFS2; |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
104 *dp++ = TMFFS_WRITE; |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
105 *dp++ = fd; |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
106 *dp++ = wrsize; |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
107 bcopy(data, dp, wrsize); |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
108 dp += wrsize; |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
109 rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
110 if (rc) |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
111 return(rc); |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
112 if (rvi_msg[3]) { |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
113 report_ffs_err("fd write", rvi_msg[3]); |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
114 return(ERROR_TARGET); |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
115 } |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
116 if (rvi_msg_len != 6) { |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
117 printf("error: TMFFS_WRITE response has wrong length\n"); |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
118 return(ERROR_TARGET); |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
119 } |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
120 if (rvi_msg[4] != wrsize) { |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
121 printf("fd write error: # of bytes written != requested\n"); |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
122 return(ERROR_TARGET); |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
123 } |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
124 return(0); |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
125 } |
ffeea2f9d149
fc-fsio: fwrite from file implemented, but no 0 length file handling yet
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
291
diff
changeset
|
126 |
284
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 fd_close(fd) |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 { |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 u_char cmdpkt[5]; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 int rc; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 cmdpkt[1] = ETM_FFS2; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 cmdpkt[2] = TMFFS_CLOSE; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 cmdpkt[3] = fd; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 rc = etm_pkt_exch(cmdpkt, 3); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 if (rc) |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 return(rc); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 if (rvi_msg[3]) { |
289
244f08f58e51
fc-fsio: error decoding implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
286
diff
changeset
|
139 report_ffs_err("close fd", rvi_msg[3]); |
284
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 return(ERROR_TARGET); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 } |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 if (rvi_msg_len != 5) { |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 printf("error: close fd response has wrong length\n"); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 return(ERROR_TARGET); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 } |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 return(0); |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 } |
285
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
148 |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
149 do_file_read(pathname, databuf, rdsize, rdret) |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
150 char *pathname; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
151 u_char *databuf; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
152 int rdsize, *rdret; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
153 { |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
154 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
155 int rc, slen, sz; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
156 |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
157 slen = strlen(pathname); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
158 if (slen >= TMFFS_STRING_SIZE) { |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
159 printf("error: pathname arg exceeds string length limit\n"); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
160 return(ERROR_USAGE); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
161 } |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
162 if (rdsize > MAX_READ_DATA) { |
286
146e7bf3fa4e
fc-fsio: fd debug commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
163 printf("error: # of bytes to read may not exceed %d\n", |
146e7bf3fa4e
fc-fsio: fd debug commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
164 MAX_READ_DATA); |
146e7bf3fa4e
fc-fsio: fd debug commands implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
165 return(ERROR_USAGE); |
285
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
166 } |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
167 dp = cmdpkt + 1; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
168 *dp++ = ETM_FFS2; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
169 *dp++ = TMFFS_FILE_READ; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
170 *dp++ = slen + 1; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
171 strcpy(dp, pathname); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
172 dp += slen + 1; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
173 *dp++ = rdsize; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
174 rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
175 if (rc) |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
176 return(rc); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
177 if (rvi_msg[3]) { |
289
244f08f58e51
fc-fsio: error decoding implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
286
diff
changeset
|
178 report_ffs_err("read file", rvi_msg[3]); |
285
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
179 return(ERROR_TARGET); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
180 } |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
181 if (rvi_msg_len < 6) { |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
182 *rdret = 0; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
183 return(0); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
184 } |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
185 sz = rvi_msg[4]; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
186 if (rvi_msg_len != sz + 6 || sz > rdsize) { |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
187 printf("error: read file response has wrong length\n"); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
188 return(ERROR_TARGET); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
189 } |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
190 bcopy(rvi_msg + 5, databuf, sz); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
191 *rdret = sz; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
192 return(0); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
193 } |
291
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
194 |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
195 max_short_file_write(pathname) |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
196 char *pathname; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
197 { |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
198 return MAX_PKT_TO_TARGET - 3 - (strlen(pathname) + 2) - 3; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
199 } |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
200 |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
201 do_short_fwrite(pathname, data, datalen) |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
202 char *pathname; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
203 u_char *data; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
204 { |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
205 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
206 int rc, slen; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
207 |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
208 slen = strlen(pathname); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
209 if (slen >= TMFFS_STRING_SIZE) { |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
210 printf("error: pathname arg exceeds string length limit\n"); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
211 return(ERROR_USAGE); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
212 } |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
213 if (datalen > max_short_file_write(pathname)) { |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
214 printf("error: short write data fails to fit in the packet\n"); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
215 return(ERROR_USAGE); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
216 } |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
217 dp = cmdpkt + 1; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
218 *dp++ = ETM_FFS2; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
219 *dp++ = TMFFS_FILE_WRITE; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
220 *dp++ = slen + 1; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
221 strcpy(dp, pathname); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
222 dp += slen + 1; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
223 *dp++ = datalen; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
224 bcopy(data, dp, datalen); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
225 dp += datalen; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
226 *dp++ = FFS_O_CREATE | FFS_O_TRUNC; |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
227 rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
228 if (rc) |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
229 return(rc); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
230 if (rvi_msg_len != 5) { |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
231 printf("error: TMFFS_FILE_WRITE response has wrong length\n"); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
232 return(ERROR_TARGET); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
233 } |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
234 if (rvi_msg[3]) { |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
235 report_ffs_err("short file write", rvi_msg[3]); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
236 return(ERROR_TARGET); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
237 } |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
238 return(0); |
69e8ae2b5ba2
fc-fsio: fwrite implementation started
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
289
diff
changeset
|
239 } |