|
6 | 6 |
|
7 | 7 |
|
8 | 8 | int main() { |
9 | | - char* p1 = "link_source"; |
10 | | - char* p2 = "link_target"; |
11 | | - |
12 | | - int res = symlink(p2, p1); |
| 9 | + int res = symlink("link_target", "link_source"); |
13 | 10 | printf("link result: %d\n", res); |
14 | | - int src_fd = open(p1, O_CREAT | O_WRONLY, 0777); |
| 11 | + int src_fd = open("link_source", O_CREAT | O_WRONLY, 0777); |
15 | 12 | printf("source_fd: %d, errno: %d %s\n", src_fd, errno, strerror(errno)); |
16 | 13 | write(src_fd, "abc", 3); |
17 | 14 | close(src_fd); |
18 | 15 | { |
19 | | - int target_fd = open(p2, O_RDONLY); |
| 16 | + int target_fd = open("link_target", O_RDONLY); |
20 | 17 | printf("target_fd: %d, errno: %d %s\n", target_fd, errno, strerror(errno)); |
21 | 18 | char buf[10]; |
22 | 19 | read(target_fd, buf, 10); |
23 | 20 | printf("buf: '%s'\n", buf); |
24 | 21 | close(target_fd); |
25 | 22 | } |
26 | 23 | { |
27 | | - int target_fd = open(p1, O_RDONLY); |
| 24 | + int target_fd = open("link_source", O_RDONLY); |
28 | 25 | printf("target_fd: %d, errno: %d %s\n", target_fd, errno, strerror(errno)); |
29 | 26 | char buf[10]; |
30 | 27 | read(target_fd, buf, 10); |
|
0 commit comments