-
Notifications
You must be signed in to change notification settings - Fork 1
/
tsymlink.c
executable file
·54 lines (40 loc) · 1.25 KB
/
tsymlink.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h>
#include <comp421/yalnix.h>
#include <comp421/iolib.h>
int
main()
{
int status;
static char buffer[1024];
struct Stat sb;
int fd;
status = Create("/a");
printf("Create status %d\n", status);
status = SymLink("/a", "/b");
printf("SymLink status %d\n", status);
status = ReadLink("/b", buffer, sizeof(buffer));
printf("ReadLink status %d\n", status);
printf("link = '%s'\n", buffer);
status = Stat("/a", &sb);
printf("Stat status %d\n", status);
printf("/a: inum %d type %d size %d nlink %d\n",
sb.inum, sb.type, sb.size, sb.nlink);
status = Stat("/b", &sb);
printf("Stat status %d\n", status);
printf("/b: inum %d type %d size %d nlink %d\n",
sb.inum, sb.type, sb.size, sb.nlink);
status = SymLink("/00/11/22/33/44/55/66/77/88/99", "/xxx");
printf("SymLink status %d\n", status);
status = SymLink("00/11/22/33/44/55/66/77/88/99", "yyy");
printf("SymLink status %d\n", status);
fd = Open("/a");
printf("Open /a status %d\n", fd);
status = Write(fd, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 27);
printf("Write /a status %d\n", status);
fd = Open("b");
printf("Open b status %d\n", fd);
status = Read(fd, buffer, sizeof(buffer));
printf("Read b status %d\n", status);
printf("buffer = '%s'\n", buffer);
Shutdown();
}