# HG changeset patch # User Michael Spacefalcon # Date 1393563287 0 # Node ID 88eed3327682d0f97eb4f7b427f68f54e1f9caf7 # Parent 517e8a428fdebde4f340363ae5ff863b04a9bdf8 fc-fsio: ll command implemented diff -r 517e8a428fde -r 88eed3327682 rvinterf/etmsync/Makefile --- a/rvinterf/etmsync/Makefile Tue Feb 25 07:42:21 2014 +0000 +++ b/rvinterf/etmsync/Makefile Fri Feb 28 04:54:47 2014 +0000 @@ -3,8 +3,8 @@ PROGS= fc-fsio INSTBIN=/usr/local/bin -FSIO_OBJS= connect.o dispatch.o fsbasics.o fscmdtab.o fsiomain.o interf.o \ - launchrvif.o +FSIO_OBJS= connect.o dispatch.o fsbasics.o fscmdtab.o fsiomain.o fsread.o \ + interf.o launchrvif.o all: ${PROGS} diff -r 517e8a428fde -r 88eed3327682 rvinterf/etmsync/fscmdtab.c --- a/rvinterf/etmsync/fscmdtab.c Tue Feb 25 07:42:21 2014 +0000 +++ b/rvinterf/etmsync/fscmdtab.c Fri Feb 28 04:54:47 2014 +0000 @@ -7,6 +7,7 @@ extern int cmd_exec(); extern int cmd_exit(); extern int cmd_ffs2ver(); +extern int cmd_ll(); extern int cmd_ls(); extern int cmd_stat(); @@ -14,6 +15,7 @@ {"exec", 1, 1, cmd_exec}, {"exit", 0, 0, cmd_exit}, {"ffs2ver", 0, 0, cmd_ffs2ver}, + {"ll", 1, 1, cmd_ll}, {"ls", 1, 1, cmd_ls}, {"stat", 1, 1, cmd_stat}, {0, 0, 0, 0} diff -r 517e8a428fde -r 88eed3327682 rvinterf/etmsync/fsread.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/etmsync/fsread.c Fri Feb 28 04:54:47 2014 +0000 @@ -0,0 +1,92 @@ +/* + * Commands for reading the content of a GSM device's file system + */ + +#include +#include +#include +#include +#include +#include "etm.h" +#include "ffs.h" +#include "tmffs2.h" +#include "limits.h" +#include "localtypes.h" +#include "localstruct.h" +#include "exitcodes.h" + +void +ll_print_line(pathname, stat) + char *pathname; + struct stat_info *stat; +{ + char readonly; + + if (stat->flags & OF_READONLY) + readonly = 'r'; + else + readonly = ' '; + switch (stat->type) { + case OT_FILE: + printf("f%c %7u %s\n", readonly, stat->size, pathname); + return; + case OT_DIR: + printf("d%c %s\n", readonly, pathname); + return; + case OT_LINK: + printf("l%c %s\n", readonly, pathname); + return; + default: + printf("?%c %s\n", readonly, pathname); + } +} + +void +mk_ffs_child_path_from_readdir(dirpath, rdname, buf) + char *dirpath, *rdname, *buf; +{ + char *tailp; + + tailp = index(dirpath, '\0') - 1; + if (*tailp == '/') + sprintf(buf, "%s%s", dirpath, rdname); + else + sprintf(buf, "%s/%s", dirpath, rdname); +} + +cmd_ll(argc, argv) + char **argv; +{ + struct stat_info stat; + u_char rdstate[4]; + char rdbuf[TMFFS_STRING_SIZE], childpath[TMFFS_STRING_SIZE*2]; + int nument, i, rc; + + rc = do_xlstat(argv[1], &stat); + if (rc) + return(rc); + if (stat.type != OT_DIR) { + ll_print_line(argv[1], &stat); + return(0); + } + rc = do_opendir(argv[1], rdstate, &nument); + if (rc) + return(rc); + if (!nument) { + printf("\n"); + return(0); + } + for (i = 0; i < nument; i++) { + rc = do_readdir(rdstate, rdbuf); + if (rc) + return(rc); + mk_ffs_child_path_from_readdir(argv[1], rdbuf, childpath); + rc = do_xlstat(childpath, &stat); + if (rc) { + printf("xlstat failed on %s\n", childpath); + return(rc); + } + ll_print_line(childpath, &stat); + } + return(0); +}