-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib_test.c
executable file
·73 lines (52 loc) · 1.38 KB
/
lib_test.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <comp421/hardware.h>
#include <comp421/yalnix.h>
#include <comp421/iolib.h>
int main(int argc, char** argv){
int buflen = 100;
char buf[buflen];
char* buf2 = "contents to be written";
char* pathname1 = "/home/thien-nam/Documents";
char* pathname2 = "/usr/bin";
int fd;
struct Stat stat;
printf("\nopening file\n");
fd = Open(pathname1);
printf("\nclosing file\n");
Close(fd);
printf("\ncreating file\n");
fd = Create(pathname2);
printf("\nreading file\n");
Read(fd, buf, buflen);
printf("\nwriting file\n");
Write(fd, buf2, strlen(buf2));
printf("\nseeking file\n");
Seek(fd, 15, SEEK_END);
printf("\nlinking paths\n");
Link(pathname1, pathname2);
printf("\nunlinking path\n");
Unlink(pathname2);
printf("\nsymlinking paths\n");
SymLink(pathname1, pathname2);
printf("\nreading link\n");
ReadLink(pathname1, buf, buflen);
printf("\nmaking dir\n");
MkDir(pathname1);
printf("\nremoving dir\n");
RmDir(pathname1);
printf("\nchanging dir\n");
ChDir(pathname1);
printf("\nreading stat\n");
Stat(pathname1, &stat);
printf("\nsynching\n");
Sync();
printf("\nshutting down\n");
Shutdown();
while(1){
Pause();
printf("idling\n");
}
return 0;
}