-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
141 lines (120 loc) · 3.98 KB
/
main.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include "stdio.h"
#include "filesys.h"
struct hinode hinode[NHINO];
struct dir dir;
struct file sys_ofile[SYSOPENFILE];
struct filsys filsys;
struct pwd pwd[PWDNUM];
struct user user[USERNUM];
FILE *fd;
struct inode *cur_path_inode;
int user_id;
int iHave_formated;
int iCur_free_block_index;
int main()
{
unsigned short ab_fd1, ab_fd2, ab_fd3, ab_fd4, ab_fd5;
char *buf;
char file_content_buf[BLOCKSIZ];
char c;
/*printf("begin:\n");
printf("\nDo you want to format the disk?\n");
if (getchar() == 'y')
printf("\nFormat will erase context on the disk \n Are you sure?\n");
getchar();
if ((c = getchar()) == 'y')
{
printf("format starts\n");
format();
iHave_formated = 1;
printf("format ended\n");
}
else
printf("received char :%c from stdin\n", c);
printf("step 1 ended\n");//
install();*/
format();
iHave_formated = 1;
install();
printf("user 2118 login\n");
login(2118, "abcd");
user_id = 0;
waitCommand(2118);
// logout(2118);
// halt();
// _dir();
// mkdir("a2118");//创建目录
// _dir();//ls
// chdir("a2118");//改变目录
// _dir();
// printf("step 2 ended\n");
// _dir();
// printf("step 3 ended\n");
// user_id = 0;
// printf("step 4 ended\n");
// mkdir("a2118");//创建目录
// _dir();//ls
// printf("step 5-1 ended\n");
// chdir("a2118");//改变目录
// _dir();
// printf("step 5-2 ended\n");
// ab_fd1 = creat(2118, "ab_file0.c", 01777);//创建文件
// _dir();//ls
// printf("step 6 ended\n");
// buf = (char *)malloc(BLOCKSIZ * 6 + 5);
// printf("step 7 ended\n");
// write(2118, ab_fd1, buf, BLOCKSIZ * 6 + 5);//写文件
// printf("step 8 ended\n");
// close(2118, ab_fd1);//关闭文件
// printf("step 9 ended\n");
// free(buf);
// mkdir("subdir");
// printf("step 10-1 ended\n");
// chdir("subdir");
// printf("step 10-2 ended\n");
// ab_fd2 = creat(2118, "file1.c", 01777);
// printf("step 11 ended\n");
// buf = (char *)malloc(BLOCKSIZ * 4 + 20);
// printf("step 12 ended\n");
// write(2118, ab_fd2, buf, BLOCKSIZ * 4 + 20);
// printf("step 13 ended\n");
// close(2118, ab_fd2);
// free(buf);
// printf("step 14 ended\n");
// chdir("..");
// printf("step 15 ended\n");
// ab_fd3 = creat(2118, "ab_file2.c", 01777);
// buf = (char *)malloc(BLOCKSIZ * 10 + 255);
// write(2118, ab_fd3, buf, BLOCKSIZ * 3 + 255);
// close(2118, ab_fd3);
// free(buf);
// delete ("ab_file0.c");
// printf("step 16 ended\n");
// ab_fd4 = creat(2118, "ab_file3.c", 01777);
// buf = (char *)malloc(BLOCKSIZ * 8 + 300);
// printf("step 17 ended\n");
// write(2118, ab_fd4, buf, BLOCKSIZ * 8 + 300);
// printf("step 18 ended\n");
// close(2118, ab_fd4);
// free(buf);
// printf("step 19 ended\n");
// ab_fd3 = open(2118, "ab_file2.c", FAPPEND);
// printf("step 20 ended\n");
// buf = (char *)malloc(BLOCKSIZ * 3 + 100);
// write(2118, ab_fd3, buf, BLOCKSIZ * 3 + 100);
// printf("step 21 ended,ab_fd3 = %d\n", ab_fd3);
// close(2118, ab_fd3);
// ab_fd5 = creat(2118, "文件5", 01777);
// write(2118, ab_fd5, "\nFly me to the moon\nAnd let me play among the stars\nLet me see what Spring is like\nOn Jupiter and Mars\n带我飞向月球,让我在群星中嬉戏,让我看看木星和火星上的春天\n", BLOCKSIZ);
// close(2118, ab_fd5);
// ab_fd5 = open(2118, "文件5", FREAD);
// read(2118, ab_fd5, file_content_buf, BLOCKSIZ);
// printf("读出文件5的内容: %s\n", file_content_buf);
// close(2118, ab_fd5);
// printf("step 22 ended\n");
// free(buf);
// _dir();
// chdir("..");
// printf("\nstep 23 ended\n");
return 0;
}