FreeCalypso > hg > freecalypso-sw
annotate rvinterf/etmsync/symlink.c @ 441:b23743555ca8
OSL: os_sem_fl.c started
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 23 Jun 2014 00:23:49 +0000 |
parents | e0ca3ca46a06 |
children |
rev | line source |
---|---|
302
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Commands for experimenting with FFS symlinks |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdlib.h> |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <string.h> |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <strings.h> |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "etm.h" |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "ffs.h" |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "tmffs2.h" |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "limits.h" |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 #include "ffslimits.h" |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 #include "localtypes.h" |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 #include "localstruct.h" |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 #include "exitcodes.h" |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 extern u_char rvi_msg[]; |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 extern int rvi_msg_len; |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 do_symlink(target, realobj) |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 char *target, *realobj; |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 { |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 int rc, targlen, reallen; |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 reallen = strlen(realobj); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 if (reallen >= TMFFS_STRING_SIZE) { |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 printf("error: pathname arg exceeds string length limit\n"); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 return(ERROR_USAGE); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 } |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 targlen = strlen(target); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 if (3 + (reallen+2) + (targlen+2) + 1 > MAX_PKT_TO_TARGET) { |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 printf("error: symlink request fails to fit into packet\n"); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 return(ERROR_USAGE); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 } |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 dp = cmdpkt + 1; |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 *dp++ = ETM_FFS2; |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 *dp++ = TMFFS_SYMLINK; |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 *dp++ = reallen + 1; |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 strcpy(dp, realobj); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 dp += reallen + 1; |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 *dp++ = targlen + 1; |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 strcpy(dp, target); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 dp += targlen + 1; |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 if (rc) |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 return(rc); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 if (rvi_msg_len != 5) { |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 printf("error: TMFFS_SYMLINK response has wrong length\n"); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 return(ERROR_TARGET); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 } |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 if (rvi_msg[3]) { |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 report_ffs_err("symlink", rvi_msg[3]); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 return(ERROR_TARGET); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 } |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 return(0); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 } |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 cmd_symlink(argc, argv) |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 char **argv; |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 { |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 return do_symlink(argv[1], argv[2]); |
cd5068cf0551
fc-fsio: symlink command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 } |
303
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
66 |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
67 do_readlink(pathname, databuf, rdret) |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
68 char *pathname; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
69 u_char *databuf; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
70 int *rdret; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
71 { |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
72 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
73 int rc, slen, sz; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
74 |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
75 slen = strlen(pathname); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
76 if (slen >= TMFFS_STRING_SIZE) { |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
77 printf("error: pathname arg exceeds string length limit\n"); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
78 return(ERROR_USAGE); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
79 } |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
80 dp = cmdpkt + 1; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
81 *dp++ = ETM_FFS2; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
82 *dp++ = TMFFS_READLINK; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
83 *dp++ = slen + 1; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
84 strcpy(dp, pathname); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
85 dp += slen + 1; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
86 *dp++ = 0; /* dummy 2nd buffer */ |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
87 rc = etm_pkt_exch(cmdpkt, dp - cmdpkt - 1); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
88 if (rc) |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
89 return(rc); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
90 if (rvi_msg[3]) { |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
91 report_ffs_err("readlink", rvi_msg[3]); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
92 return(ERROR_TARGET); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
93 } |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
94 if (rvi_msg_len < 6) { |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
95 *rdret = 0; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
96 return(0); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
97 } |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
98 sz = rvi_msg[4]; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
99 if (rvi_msg_len != sz + 6) { |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
100 printf("error: readlink response has wrong length\n"); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
101 return(ERROR_TARGET); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
102 } |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
103 bcopy(rvi_msg + 5, databuf, sz); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
104 *rdret = sz; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
105 return(0); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
106 } |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
107 |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
108 cmd_readlink(argc, argv) |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
109 char **argv; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
110 { |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
111 u_char databuf[256]; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
112 int rc, sz, off, l; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
113 |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
114 rc = do_readlink(argv[1], databuf, &sz); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
115 if (rc) |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
116 return(rc); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
117 printf("%d bytes read\n", sz); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
118 for (off = 0; off < sz; off += 16) { |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
119 l = sz - off; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
120 if (l > 16) |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
121 l = 16; |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
122 hexdump_line(off, databuf + off, l); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
123 } |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
124 return(0); |
61c68a55f2a2
fc-fsio: readlink implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
302
diff
changeset
|
125 } |
304
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
126 |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
127 do_readlink_sancheck(pathname, databuf) |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
128 char *pathname; |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
129 u_char *databuf; |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
130 { |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
131 int rc, sz; |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
132 |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
133 rc = do_readlink(pathname, databuf, &sz); |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
134 if (rc) |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
135 return(rc); |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
136 if (sz < 2 || databuf[sz-1]) { |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
137 printf("error: readlink on %s returned garbage\n", pathname); |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
138 return(ERROR_TARGET); |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
139 } |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
140 return(0); |
e0ca3ca46a06
fc-fsio: ll reads and shows symlinks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
303
diff
changeset
|
141 } |