summaryrefslogblamecommitdiff
path: root/src/kernel/vfs/node.h
blob: 2d16dabb91721c853ec2a94d53ea72579de2a4a4 (plain) (tree)








































                                                                                                
#ifndef DEF_VFS_NODE_H
#define DEF_VFS_NODE_H

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

#include <task/task.h>

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

	node(node* p, int t) : parent(p), type(t) {}
	
	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; }
};

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

// 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