summaryrefslogtreecommitdiff
path: root/src/kernel/vfs/node.h
blob: 7fbc205f5062d7f4e36bd1e6248ed7362a69c2de (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
56
57
#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;
	uint32_t type, dev_type;
	uint32_t mode, uid, gid;

	node(node* p, uint32_t 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; }
	virtual int dev_control(char *data) { return E_NOT_IMPLEMENTED; }

	// kind of like dynamic_cast'ing 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;

typedef int FILE;	// file descriptor type, DIFFERENT FROM FILE TYPE IN USERLAND !!!

// 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);
int dev_control(FILE file, char *data);

#endif