-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile.h
73 lines (59 loc) · 1.61 KB
/
file.h
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
#ifndef _FILE_H
#define _FILE_H
/**
* 支持的文件数量
*/
#define MAX_FILES 256
#define MAX_OPEN_FILE 32
#define FILE_NAME_LEN 256
/* file mode */
#define FM_READ 0X01
#define FM_WRITE 0X02
#define FM_RDWR (FM_READ | FM_WRITE)
/* file flags */
#define FF_READ 0X01
#define FF_WRITE 0X02
#define FF_RDWR (FF_READ | FF_WRITE)
#define FF_CRATE 0X10
#define FP_SET 1
#define FP_CUR 2
#define FP_END 3
struct file {
unsigned long hash; /* name hash */
long data_table;
unsigned long file_size;
int ref;
int mode; /* r,w,rw */
int num; /* 文件编号 */
struct super_block *sb;
};
struct file_name {
char buf[FILE_NAME_LEN];
};
struct file_stat {
unsigned long file_size;
int mode; /* r,w,rw */
int num; /* 文件编号 */
};
/* open file */
struct ofile {
struct file *f;
struct super_block *sb;
int oflags; /* open flags */
long off;
};
void dump_all_file(struct super_block *sb);
int delete_file(struct super_block *sb, char *path);
int open_file(struct super_block *sb, char *path, int flags);
int close_file(int file);
long write_file(int file, void *buf, long len);
long read_file(int file, void *buf, long len);
int seek_file(int file, int off, int pos);
long tell_file(int file);
long walk_file_name(struct super_block *sb, long file_num, void *buf, long len);
void list_files(struct super_block *sb);
int rename_file(struct super_block *sb, char *src_name, char *dest_name);
int stat_file(struct super_block *sb, char *path, struct file_stat *stat);
long alloc_file_num(struct super_block *sb);
int free_file_num(struct super_block *sb, long file_num);
#endif