summaryrefslogtreecommitdiff
path: root/doc/vfs.txt
blob: 255ddb0bc09bb1fc9997e696d2acbe7ae5949bb1 (plain) (blame)
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
The VFS in T/CE :

File are objects that implement an abstract file class in the kernel. Its methods are :
- int open(process *pr, int mode)
- void close(process *pr)
- int read(size_t offset, size_t len, char *buffer)
- int write(size_t offset, size_t len, char *buffer)
- int stat(struct file_info *info)
- file* get_child(char* name)
- int add_child(char* name, file *child)

The following syscall interface is given to the process (fd_t is a file descriptor, an int) :
- fd_t open(char* filename, int mode)
- fd_t open_relative(fd_t root, char* filename, int mode)
- int stat(char* filename, struct file_info *info)
- int statf(fd_t file, struct file_info *info)
- void close(fd_t file)
- int read(fd_t file, size_t offset, size_t len, char *buffer)
- int write(fd_t file, size_t offset, size_t len, char *buffer)
- int link(char *from, char *to, int mode)

struct file_info {
	int type
	int dev_type
	int mode
	int uid, gid
	int size
}

File open modes flags :
- FM_READ		open for reading
- FM_WRITE		open for writing
- FM_APPEND		append data
- FM_TRUNC		truncate existing file
- FM_CREATE		create file if it doesn't exist
note : if mode contains neither FM_READ nor FM_WRITE, then the file will be created/truncated according to the flags given,
	but will not be actually oppenned, so the return value of open will be 0.

Link modes :
- LM_SYMLINK
- LM_HARDLINK	(don't count on that really being implemented)
- LM_MOUNT
- LM_OUTPUT_TO	(keyboard outputs to virtual terminal, virtual terminal outputs to display, that kind of stuff.)

File type flags :
- FT_FILE
- FT_DIR			// block devices that contain a partition table will have this flag
- FT_SYMLINK
- FT_DEV			// any kind of device with special properties (keyboard, hdd, disk partition, ...)
- FT_TERMINAL		// virtual terminal

Device types :
- DT_BLOCK
- DT_KEYBOARD
- DT_DISPLAY