FreeCalypso > hg > freecalypso-sw
comparison rvinterf/etmsync/fsbasics.c @ 282:517e8a428fde
fc-fsio: xlstat operation implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 25 Feb 2014 07:42:21 +0000 |
parents | 36ad667341fc |
children | 244f08f58e51 |
comparison
equal
deleted
inserted
replaced
281:082d12a1651e | 282:517e8a428fde |
---|---|
9 #include <strings.h> | 9 #include <strings.h> |
10 #include "etm.h" | 10 #include "etm.h" |
11 #include "ffs.h" | 11 #include "ffs.h" |
12 #include "tmffs2.h" | 12 #include "tmffs2.h" |
13 #include "limits.h" | 13 #include "limits.h" |
14 #include "localtypes.h" | |
15 #include "localstruct.h" | |
14 #include "exitcodes.h" | 16 #include "exitcodes.h" |
15 | 17 |
16 extern u_char rvi_msg[]; | 18 extern u_char rvi_msg[]; |
17 extern int rvi_msg_len; | 19 extern int rvi_msg_len; |
18 | 20 |
128 return(rc); | 130 return(rc); |
129 printf("%s\n", namebuf); | 131 printf("%s\n", namebuf); |
130 } | 132 } |
131 return(0); | 133 return(0); |
132 } | 134 } |
135 | |
136 do_xlstat(pathname, result) | |
137 char *pathname; | |
138 struct stat_info *result; | |
139 { | |
140 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; | |
141 int rc, slen; | |
142 | |
143 slen = strlen(pathname); | |
144 if (slen >= TMFFS_STRING_SIZE) { | |
145 printf("error: pathname arg exceeds string length limit\n"); | |
146 return(ERROR_USAGE); | |
147 } | |
148 dp = cmdpkt + 1; | |
149 *dp++ = ETM_FFS2; | |
150 *dp++ = TMFFS_XLSTAT; | |
151 *dp++ = slen + 1; | |
152 strcpy(dp, pathname); | |
153 dp += slen + 1; | |
154 rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); | |
155 if (rc) | |
156 return(rc); | |
157 if (rvi_msg[3]) { | |
158 printf("xlstat: FFS error %d\n", rvi_msg[3]); | |
159 return(ERROR_TARGET); | |
160 } | |
161 if (rvi_msg_len != 30 || rvi_msg[4] != 24) { | |
162 printf("error: xlstat response has wrong length\n"); | |
163 return(ERROR_TARGET); | |
164 } | |
165 result->type = rvi_msg[5]; | |
166 result->flags = rvi_msg[6]; | |
167 result->inode = rvi_msg[7] | rvi_msg[8] << 8; | |
168 result->size = rvi_msg[9] | rvi_msg[10] << 8 | rvi_msg[11] << 16 | | |
169 rvi_msg[12] << 24; | |
170 result->space = rvi_msg[13] | rvi_msg[14] << 8 | rvi_msg[15] << 16 | | |
171 rvi_msg[16] << 24; | |
172 result->location = rvi_msg[17] | rvi_msg[18] << 8 | rvi_msg[19] << 16 | | |
173 rvi_msg[20] << 24; | |
174 result->block = rvi_msg[22]; | |
175 result->sequence = rvi_msg[23] | rvi_msg[24] << 8; | |
176 result->updates = rvi_msg[25] | rvi_msg[26] << 8; | |
177 return(0); | |
178 } | |
179 | |
180 cmd_stat(argc, argv) | |
181 char **argv; | |
182 { | |
183 struct stat_info stat; | |
184 int rc; | |
185 char *type; | |
186 | |
187 rc = do_xlstat(argv[1], &stat); | |
188 if (rc) | |
189 return(rc); | |
190 switch (stat.type) { | |
191 case OT_FILE: | |
192 type = "file"; | |
193 break; | |
194 case OT_DIR: | |
195 type = "directory"; | |
196 break; | |
197 case OT_LINK: | |
198 type = "symlink"; | |
199 break; | |
200 default: | |
201 type = "???"; | |
202 } | |
203 printf("Type: %s%s\n", type, | |
204 stat.flags & OF_READONLY ? ", read-only" : ""); | |
205 printf("inode %x\n", stat.inode); | |
206 printf("size %u, space %u\n", stat.size, stat.space); | |
207 printf("location=%x, block %d\n", stat.location, stat.block); | |
208 return(0); | |
209 } |