summaryrefslogtreecommitdiff
path: root/src/kernel/vfs/node.h
blob: b0ade4148825616cb9f7f84a3aa44f3b3228b054 (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
#ifndef DEF_VFS_NODE_H
#define DEF_VFS_NODE_H

#include <tce/vfs.h>
#include <tce/syscalls.h>

#include <task/task.h>

class display;
class vt;

class node {
	public:
	node* parent;
	int type, dev_type;
	int mode, uid, gid;

	node(node* p, int t) : parent(p), type(t) {}
	virtual ~node() {}
	
	virtual int open(process *proc, int mode);
	virtual void close(process *proc) {}
	virtual int read(size_t offset, size_t len, char *buffer) { return E_NOT_IMPLEMENTED; }
	virtual int write(size_t offset, size_t len, char* buffer) { return E_NOT_IMPLEMENTED; }
	int stat(file_info *info);
	virtual node* get_child(char* name) { return 0; }
	virtual int add_child(char* name, node *child) { return E_NOT_IMPLEMENTED; }
	virtual size_t get_size() { return 0; }
	virtual int link(node* other, int mode) { return E_NOT_IMPLEMENTED; }

	// kind of like dynamic_cast'int these things
	virtual display *as_display() { return 0; }
	virtual vt *as_vt() { return 0; }
};

void vfs_setup();
node* vfs_find(node* root, char* filename);

extern node *root, *dot_dev, *dot_ui;

// syscall interface
FILE open(char* filename, int mode);
FILE open_relative(FILE root, char* filename, int mode);
int stat(char* filename, file_info *info);
int stat_relative(FILE root, char* filename, file_info *info);
int statf(FILE file, file_info *info);
void close(FILE file);
int read(FILE file, size_t offset, size_t len, char *buffer);
int write(FILE file, size_t offset, size_t len, char *buffer);
int link(char* from, char* to, int mode);

#endif