FreeCalypso > hg > freecalypso-tools
changeset 592:a0754c98fc2b
fc-fsio: rm -f mode implemented (ignore EFFS_NOTFOUND),
actual ffs_remove operation factored out into do_ffs_remove()
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 04 Feb 2020 03:36:08 +0000 |
parents | adcb617e6a92 |
children | f315cdb1555f |
files | rvinterf/etmsync/fileio.c rvinterf/etmsync/fscmdtab.c rvinterf/etmsync/fswrite.c |
diffstat | 3 files changed, 46 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/etmsync/fileio.c Tue Feb 04 03:09:11 2020 +0000 +++ b/rvinterf/etmsync/fileio.c Tue Feb 04 03:36:08 2020 +0000 @@ -399,3 +399,35 @@ return(ERROR_TARGET); } } + +do_ffs_remove(pathname, minusf_mode) + char *pathname; +{ + 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_REMOVE; + *dp++ = slen + 1; + strcpy(dp, pathname); + dp += slen + 1; + rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); + if (rc) + return(rc); + if (rvi_msg_len != 5) { + printf("error: TMFFS_REMOVE response has wrong length\n"); + return(ERROR_TARGET); + } + if (!rvi_msg[3]) /* success */ + return(0); + if (minusf_mode && rvi_msg[3] == TMFFS_ERR_NOTFOUND) + return(0); /* treat as OK */ + report_ffs_err("ffs_remove", rvi_msg[3]); + return(ERROR_TARGET); +}
--- a/rvinterf/etmsync/fscmdtab.c Tue Feb 04 03:09:11 2020 +0000 +++ b/rvinterf/etmsync/fscmdtab.c Tue Feb 04 03:36:08 2020 +0000 @@ -63,7 +63,7 @@ {"pirelli-magnetite-init", 0, 0, pirelli_magnetite_init}, {"preformat", 0, 0, cmd_preformat}, {"readlink", 1, 1, cmd_readlink}, - {"rm", 1, 1, cmd_delete}, + {"rm", 1, 2, cmd_delete}, {"set-imeisv", 2, 2, cmd_set_imeisv}, {"set-pcm-string", 2, 2, cmd_set_pcm_string}, {"set-rfcap", 1, 1, cmd_set_rfcap},
--- a/rvinterf/etmsync/fswrite.c Tue Feb 04 03:09:11 2020 +0000 +++ b/rvinterf/etmsync/fswrite.c Tue Feb 04 03:36:08 2020 +0000 @@ -29,32 +29,21 @@ cmd_delete(argc, argv) char **argv; { - u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; - int rc, slen; + char *pathname; + int minusf_mode; - slen = strlen(argv[1]); - if (slen >= TMFFS_STRING_SIZE) { - printf("error: pathname arg exceeds string length limit\n"); - return(ERROR_USAGE); + if (argc == 2) { + pathname = argv[1]; + minusf_mode = 0; + } else { + if (strcmp(argv[1], "-f")) { + fprintf(stderr, "usage: rm [-f] ffs_pathname\n"); + return(ERROR_USAGE); + } + pathname = argv[2]; + minusf_mode = 1; } - dp = cmdpkt + 1; - *dp++ = ETM_FFS2; - *dp++ = TMFFS_REMOVE; - *dp++ = slen + 1; - strcpy(dp, argv[1]); - dp += slen + 1; - rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); - if (rc) - return(rc); - if (rvi_msg_len != 5) { - printf("error: TMFFS_REMOVE response has wrong length\n"); - return(ERROR_TARGET); - } - if (rvi_msg[3]) { - report_ffs_err("ffs_remove", rvi_msg[3]); - return(ERROR_TARGET); - } - return(0); + return do_ffs_remove(pathname, minusf_mode); } hexdigit(c)