-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtmp.c
59 lines (48 loc) · 1.39 KB
/
tmp.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
#include <stdio.h>
#include "fs.h"
int main() {
// 创建并初始化文件系统
printf("%d\n", sizeof(INode));
FileSystem fs;
UserOpenTable openTable;
tbl_init(&openTable); // 初始化打开文件表
// 格式化文件系统
format(&fs);
INode inode;
inode = readInode(&fs, 0);
printf("inodenum: %d\n", inode.inode_number);
printf("inodetype: %o\n", inode.type);
printf("size: %d\n", inode.size);
printf("File system formatted.\n");
printf("%d %d\n", fs.current_dir_inode, fs.current_dir_inode);
ls(&fs, "/dir1");
ls(&fs, "/");
printf("fucking ls\n");
mkdir(&fs, "./fuck1");
ls(&fs, "/");
mkdir(&fs, "fuck2");
ls(&fs, "/");
printf("cd !!!!!\n");
cd(&fs, "fuck1");
ls(&fs, NULL);
cd(&fs, "/fuck2");
ls(&fs, NULL);
create(&fs, "cjd");
create(&fs, "cjd2");
ls(&fs, NULL);
// 打开文件进行写操作
open(&fs, &openTable, "cjd");
char content[] = "Hello, World!askjefhgiouqwehfiuowqbfuykgavweuyifgiyuawe";
write(&fs, &openTable, "cjd", sizeof(content), content, 0);
printf("wirtted\n");
char buf[1024];
read(&fs, &openTable, "cjd", 50, buf);
buf[50] = '\0';
printf("Readded : %s\n", buf);
// 关闭文件
close(&fs, &openTable, "cjd");
// exitfs(&fs, "filesystem");
// // 清理打开文件表
// tbl_destroy(&openTable);
return 0;
}