FreeCalypso > hg > freecalypso-sw
changeset 302:cd5068cf0551
fc-fsio: symlink command implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 02 Mar 2014 04:34:49 +0000 |
parents | 8dd522a8d60e |
children | 61c68a55f2a2 |
files | rvinterf/etmsync/Makefile rvinterf/etmsync/fscmdtab.c rvinterf/etmsync/symlink.c |
diffstat | 3 files changed, 68 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/etmsync/Makefile Sun Mar 02 02:04:51 2014 +0000 +++ b/rvinterf/etmsync/Makefile Sun Mar 02 04:34:49 2014 +0000 @@ -5,7 +5,7 @@ FSIO_OBJS= connect.o dispatch.o fdcmd.o fileio.o fsbasics.o fscmdtab.o \ fserr.o fsiomain.o fsmisc.o fspath.o fsread.o fsupload.o \ - fswrite.o interf.o launchrvif.o + fswrite.o interf.o launchrvif.o symlink.o all: ${PROGS}
--- a/rvinterf/etmsync/fscmdtab.c Sun Mar 02 02:04:51 2014 +0000 +++ b/rvinterf/etmsync/fscmdtab.c Sun Mar 02 04:34:49 2014 +0000 @@ -21,6 +21,7 @@ extern int cmd_set_imeisv(); extern int cmd_set_pcm_string(); extern int cmd_stat(); +extern int cmd_symlink(); extern int cmd_uploadfs(); extern int cmd_upload_file(); extern int cmd_upload_subtree(); @@ -43,6 +44,7 @@ {"set-imeisv", 2, 2, cmd_set_imeisv}, {"set-pcm-string", 2, 2, cmd_set_pcm_string}, {"stat", 1, 1, cmd_stat}, + {"symlink", 2, 2, cmd_symlink}, {"upload-file", 2, 2, cmd_upload_file}, {"upload-fs", 1, 1, cmd_uploadfs}, {"upload-subtree", 2, 2, cmd_upload_subtree},
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/etmsync/symlink.c Sun Mar 02 04:34:49 2014 +0000 @@ -0,0 +1,65 @@ +/* + * Commands for experimenting with FFS symlinks + */ + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include "etm.h" +#include "ffs.h" +#include "tmffs2.h" +#include "limits.h" +#include "ffslimits.h" +#include "localtypes.h" +#include "localstruct.h" +#include "exitcodes.h" + +extern u_char rvi_msg[]; +extern int rvi_msg_len; + +do_symlink(target, realobj) + char *target, *realobj; +{ + u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; + int rc, targlen, reallen; + + reallen = strlen(realobj); + if (reallen >= TMFFS_STRING_SIZE) { + printf("error: pathname arg exceeds string length limit\n"); + return(ERROR_USAGE); + } + targlen = strlen(target); + if (3 + (reallen+2) + (targlen+2) + 1 > MAX_PKT_TO_TARGET) { + printf("error: symlink request fails to fit into packet\n"); + return(ERROR_USAGE); + } + dp = cmdpkt + 1; + *dp++ = ETM_FFS2; + *dp++ = TMFFS_SYMLINK; + *dp++ = reallen + 1; + strcpy(dp, realobj); + dp += reallen + 1; + *dp++ = targlen + 1; + strcpy(dp, target); + dp += targlen + 1; + rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); + if (rc) + return(rc); + if (rvi_msg_len != 5) { + printf("error: TMFFS_SYMLINK response has wrong length\n"); + return(ERROR_TARGET); + } + if (rvi_msg[3]) { + report_ffs_err("symlink", rvi_msg[3]); + return(ERROR_TARGET); + } + return(0); +} + +cmd_symlink(argc, argv) + char **argv; +{ + return do_symlink(argv[1], argv[2]); +}