FreeCalypso > hg > freecalypso-sw
comparison 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 |
comparison
equal
deleted
inserted
replaced
301:8dd522a8d60e | 302:cd5068cf0551 |
---|---|
1 /* | |
2 * Commands for experimenting with FFS symlinks | |
3 */ | |
4 | |
5 #include <sys/types.h> | |
6 #include <stdio.h> | |
7 #include <stdlib.h> | |
8 #include <string.h> | |
9 #include <strings.h> | |
10 #include "etm.h" | |
11 #include "ffs.h" | |
12 #include "tmffs2.h" | |
13 #include "limits.h" | |
14 #include "ffslimits.h" | |
15 #include "localtypes.h" | |
16 #include "localstruct.h" | |
17 #include "exitcodes.h" | |
18 | |
19 extern u_char rvi_msg[]; | |
20 extern int rvi_msg_len; | |
21 | |
22 do_symlink(target, realobj) | |
23 char *target, *realobj; | |
24 { | |
25 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; | |
26 int rc, targlen, reallen; | |
27 | |
28 reallen = strlen(realobj); | |
29 if (reallen >= TMFFS_STRING_SIZE) { | |
30 printf("error: pathname arg exceeds string length limit\n"); | |
31 return(ERROR_USAGE); | |
32 } | |
33 targlen = strlen(target); | |
34 if (3 + (reallen+2) + (targlen+2) + 1 > MAX_PKT_TO_TARGET) { | |
35 printf("error: symlink request fails to fit into packet\n"); | |
36 return(ERROR_USAGE); | |
37 } | |
38 dp = cmdpkt + 1; | |
39 *dp++ = ETM_FFS2; | |
40 *dp++ = TMFFS_SYMLINK; | |
41 *dp++ = reallen + 1; | |
42 strcpy(dp, realobj); | |
43 dp += reallen + 1; | |
44 *dp++ = targlen + 1; | |
45 strcpy(dp, target); | |
46 dp += targlen + 1; | |
47 rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); | |
48 if (rc) | |
49 return(rc); | |
50 if (rvi_msg_len != 5) { | |
51 printf("error: TMFFS_SYMLINK response has wrong length\n"); | |
52 return(ERROR_TARGET); | |
53 } | |
54 if (rvi_msg[3]) { | |
55 report_ffs_err("symlink", rvi_msg[3]); | |
56 return(ERROR_TARGET); | |
57 } | |
58 return(0); | |
59 } | |
60 | |
61 cmd_symlink(argc, argv) | |
62 char **argv; | |
63 { | |
64 return do_symlink(argv[1], argv[2]); | |
65 } |