FreeCalypso > hg > freecalypso-sw
diff 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 |
line wrap: on
line diff
--- a/rvinterf/etmsync/fsbasics.c Mon Feb 24 07:44:33 2014 +0000 +++ b/rvinterf/etmsync/fsbasics.c Tue Feb 25 07:42:21 2014 +0000 @@ -11,6 +11,8 @@ #include "ffs.h" #include "tmffs2.h" #include "limits.h" +#include "localtypes.h" +#include "localstruct.h" #include "exitcodes.h" extern u_char rvi_msg[]; @@ -130,3 +132,78 @@ } return(0); } + +do_xlstat(pathname, result) + char *pathname; + struct stat_info *result; +{ + u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; + int rc, slen; + + slen = strlen(pathname); + if (slen >= TMFFS_STRING_SIZE) { + printf("error: pathname arg exceeds string length limit\n"); + return(ERROR_USAGE); + } + dp = cmdpkt + 1; + *dp++ = ETM_FFS2; + *dp++ = TMFFS_XLSTAT; + *dp++ = slen + 1; + strcpy(dp, pathname); + dp += slen + 1; + rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); + if (rc) + return(rc); + if (rvi_msg[3]) { + printf("xlstat: FFS error %d\n", rvi_msg[3]); + return(ERROR_TARGET); + } + if (rvi_msg_len != 30 || rvi_msg[4] != 24) { + printf("error: xlstat response has wrong length\n"); + return(ERROR_TARGET); + } + result->type = rvi_msg[5]; + result->flags = rvi_msg[6]; + result->inode = rvi_msg[7] | rvi_msg[8] << 8; + result->size = rvi_msg[9] | rvi_msg[10] << 8 | rvi_msg[11] << 16 | + rvi_msg[12] << 24; + result->space = rvi_msg[13] | rvi_msg[14] << 8 | rvi_msg[15] << 16 | + rvi_msg[16] << 24; + result->location = rvi_msg[17] | rvi_msg[18] << 8 | rvi_msg[19] << 16 | + rvi_msg[20] << 24; + result->block = rvi_msg[22]; + result->sequence = rvi_msg[23] | rvi_msg[24] << 8; + result->updates = rvi_msg[25] | rvi_msg[26] << 8; + return(0); +} + +cmd_stat(argc, argv) + char **argv; +{ + struct stat_info stat; + int rc; + char *type; + + rc = do_xlstat(argv[1], &stat); + if (rc) + return(rc); + switch (stat.type) { + case OT_FILE: + type = "file"; + break; + case OT_DIR: + type = "directory"; + break; + case OT_LINK: + type = "symlink"; + break; + default: + type = "???"; + } + printf("Type: %s%s\n", type, + stat.flags & OF_READONLY ? ", read-only" : ""); + printf("inode %x\n", stat.inode); + printf("size %u, space %u\n", stat.size, stat.space); + printf("location=%x, block %d\n", stat.location, stat.block); + return(0); +}