FreeCalypso > hg > freecalypso-sw
annotate rvinterf/etmsync/fsread.c @ 288:e33d71e9033f
fc-fsio: cpout directory recursion implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 28 Feb 2014 08:46:14 +0000 |
parents | 211b35db427c |
children | 3dd74b16df82 |
rev | line source |
---|---|
283
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Commands for reading the content of a GSM device's file system |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
288
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
6 #include <sys/param.h> |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
7 #include <sys/stat.h> |
283
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <stdio.h> |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <stdlib.h> |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include <string.h> |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include <strings.h> |
288
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
12 #include <unistd.h> |
283
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "etm.h" |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 #include "ffs.h" |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 #include "tmffs2.h" |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 #include "limits.h" |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 #include "localtypes.h" |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 #include "localstruct.h" |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 #include "exitcodes.h" |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 void |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 ll_print_line(pathname, stat) |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 char *pathname; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 struct stat_info *stat; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 { |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 char readonly; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 if (stat->flags & OF_READONLY) |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 readonly = 'r'; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 else |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 readonly = ' '; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 switch (stat->type) { |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 case OT_FILE: |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 printf("f%c %7u %s\n", readonly, stat->size, pathname); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 return; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 case OT_DIR: |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 printf("d%c %s\n", readonly, pathname); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 return; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 case OT_LINK: |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 printf("l%c %s\n", readonly, pathname); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 return; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 default: |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 printf("?%c %s\n", readonly, pathname); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 } |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 } |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 void |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 mk_ffs_child_path_from_readdir(dirpath, rdname, buf) |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 char *dirpath, *rdname, *buf; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 { |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 char *tailp; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 tailp = index(dirpath, '\0') - 1; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 if (*tailp == '/') |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 sprintf(buf, "%s%s", dirpath, rdname); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 else |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 sprintf(buf, "%s/%s", dirpath, rdname); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 } |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 cmd_ll(argc, argv) |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 char **argv; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 { |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 struct stat_info stat; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 u_char rdstate[4]; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 char rdbuf[TMFFS_STRING_SIZE], childpath[TMFFS_STRING_SIZE*2]; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 int nument, i, rc; |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 rc = do_xlstat(argv[1], &stat); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 if (rc) |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 return(rc); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 if (stat.type != OT_DIR) { |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 ll_print_line(argv[1], &stat); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 return(0); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 } |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 rc = do_opendir(argv[1], rdstate, &nument); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 if (rc) |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 return(rc); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 if (!nument) { |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 printf("<empty dir>\n"); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 return(0); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 } |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 for (i = 0; i < nument; i++) { |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 rc = do_readdir(rdstate, rdbuf); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 if (rc) |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 return(rc); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 mk_ffs_child_path_from_readdir(argv[1], rdbuf, childpath); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 rc = do_xlstat(childpath, &stat); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 if (rc) { |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 printf("xlstat failed on %s\n", childpath); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 return(rc); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 } |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 ll_print_line(childpath, &stat); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 } |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 return(0); |
88eed3327682
fc-fsio: ll command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 } |
284
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
283
diff
changeset
|
96 |
285
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
97 void |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
98 hexdump_line(offset, buf, len) |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
99 u_char *buf; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
100 { |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
101 int i, c; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
102 |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
103 printf("%02X: ", offset); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
104 for (i = 0; i < 16; i++) { |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
105 if (i < len) |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
106 printf("%02X ", buf[i]); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
107 else |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
108 fputs(" ", stdout); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
109 if (i == 7 || i == 15) |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
110 putchar(' '); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
111 } |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
112 for (i = 0; i < len; i++) { |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
113 c = buf[i]; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
114 if (c < ' ' || c > '~') |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
115 c = '.'; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
116 putchar(c); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
117 } |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
118 putchar('\n'); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
119 } |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
120 |
284
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
283
diff
changeset
|
121 cmd_hd(argc, argv) |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
283
diff
changeset
|
122 char **argv; |
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
283
diff
changeset
|
123 { |
285
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
124 u_char databuf[MAX_READ_DATA]; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
125 int rc, sz, off, l; |
284
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
283
diff
changeset
|
126 |
285
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
127 rc = do_file_read(argv[1], databuf, MAX_READ_DATA, &sz); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
128 if (rc) |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
129 return(rc); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
130 printf("%d bytes read\n", sz); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
131 for (off = 0; off < sz; off += 16) { |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
132 l = sz - off; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
133 if (l > 16) |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
134 l = 16; |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
135 hexdump_line(off, databuf + off, l); |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
136 } |
bb28ba9e82c5
fc-fsio: file read primitive and hd command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
284
diff
changeset
|
137 return(0); |
284
7b4d4e3e610a
fc-fsio: functions written for file descriptor open/read/close
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
283
diff
changeset
|
138 } |
287
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
139 |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
140 cpout_object(ffspath, hostpath) |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
141 char *ffspath, *hostpath; |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
142 { |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
143 struct stat_info stat; |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
144 int rc; |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
145 |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
146 rc = do_xlstat(ffspath, &stat); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
147 if (rc) |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
148 return(rc); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
149 switch (stat.type) { |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
150 case OT_FILE: |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
151 return cpout_file(ffspath, &stat, hostpath); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
152 case OT_DIR: |
288
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
153 return cpout_dir(ffspath, hostpath); |
287
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
154 case OT_LINK: |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
155 printf("skipping FFS symlink %s\n", ffspath); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
156 return(0); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
157 default: |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
158 printf("error: stat returned bad objtype for %s\n", ffspath); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
159 return(ERROR_TARGET); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
160 } |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
161 } |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
162 |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
163 cpout_file(ffspath, stat, hostpath) |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
164 char *ffspath, *hostpath; |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
165 struct stat_info *stat; |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
166 { |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
167 int tfd; |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
168 FILE *of; |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
169 u_char buf[MAX_READ_DATA]; |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
170 int rc, sz; |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
171 |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
172 printf("copying %s\n", ffspath); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
173 rc = fd_open(ffspath, FFS_O_RDONLY, &tfd); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
174 if (rc) |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
175 return(rc); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
176 of = fopen(hostpath, "w"); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
177 if (!of) { |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
178 perror(hostpath); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
179 fd_close(tfd); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
180 return(ERROR_UNIX); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
181 } |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
182 for (;;) { |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
183 rc = fd_read(tfd, buf, MAX_READ_DATA, &sz); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
184 if (rc) { |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
185 fd_close(tfd); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
186 fclose(of); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
187 return(rc); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
188 } |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
189 if (!sz) |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
190 break; |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
191 fwrite(buf, 1, sz, of); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
192 } |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
193 fclose(of); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
194 return fd_close(tfd); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
195 } |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
196 |
288
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
197 host_mkdir(pathname) |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
198 char *pathname; |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
199 { |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
200 int rc; |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
201 struct stat st; |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
202 |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
203 rc = stat(pathname, &st); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
204 if (rc < 0) { |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
205 rc = mkdir(pathname, 0777); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
206 if (rc < 0) { |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
207 perror(pathname); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
208 return(ERROR_UNIX); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
209 } |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
210 return(0); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
211 } else { |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
212 if (S_ISDIR(st.st_mode)) |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
213 return(0); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
214 else { |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
215 fprintf(stderr, |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
216 "error: %s already exists and is not a directory\n", |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
217 pathname); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
218 return(ERROR_UNIX); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
219 } |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
220 } |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
221 } |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
222 |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
223 cpout_dir(ffspath_dir, hostpath_dir) |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
224 char *ffspath_dir, *hostpath_dir; |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
225 { |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
226 u_char rdstate[4]; |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
227 char rdbuf[TMFFS_STRING_SIZE], ffspath_child[TMFFS_STRING_SIZE*2]; |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
228 char hostpath_child[MAXPATHLEN]; |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
229 int nument, i, rc; |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
230 |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
231 printf("dir %s\n", ffspath_dir); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
232 rc = host_mkdir(hostpath_dir); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
233 if (rc) |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
234 return(rc); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
235 rc = do_opendir(ffspath_dir, rdstate, &nument); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
236 if (rc) |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
237 return(rc); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
238 for (i = 0; i < nument; i++) { |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
239 rc = do_readdir(rdstate, rdbuf); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
240 if (rc) |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
241 return(rc); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
242 mk_ffs_child_path_from_readdir(ffspath_dir, rdbuf, |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
243 ffspath_child); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
244 if (rdbuf[0] == '.') { |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
245 printf("skipping %s\n", ffspath_child); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
246 return(0); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
247 } |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
248 if (strlen(hostpath_dir) + strlen(rdbuf) + 2 > |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
249 sizeof hostpath_child) { |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
250 fprintf(stderr, |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
251 "error: host side pathname buffer overflow\n"); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
252 return(ERROR_UNIX); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
253 } |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
254 sprintf(hostpath_child, "%s/%s", hostpath_dir, rdbuf); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
255 rc = cpout_object(ffspath_child, hostpath_child); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
256 if (rc) |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
257 return(rc); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
258 } |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
259 return(0); |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
260 } |
e33d71e9033f
fc-fsio: cpout directory recursion implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
287
diff
changeset
|
261 |
287
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
262 cmd_cpout(argc, argv) |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
263 char **argv; |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
264 { |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
265 return cpout_object(argv[1], argv[2]); |
211b35db427c
fc-fsio: cpout of single files implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
285
diff
changeset
|
266 } |