FreeCalypso > hg > freecalypso-sw
view rvinterf/etmsync/symlink.c @ 302:cd5068cf0551
fc-fsio: symlink command implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 02 Mar 2014 04:34:49 +0000 |
parents | |
children | 61c68a55f2a2 |
line wrap: on
line source
/* * 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]); }