BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / blob / 73145c0e2b43a1cca5c2cd10a53a703d3ad013bf / include / nucleus / vfs.h

// Related

Nucleus

Barry File object 015db5a (3 years, 3 months ago)
#ifndef _NUCLEUS_VFS_H
#define _NUCLEUS_VFS_H

#include <stddef.h>
#include <sys/types.h>
#include <nucleus/object.h>
#include <nucleus/memory.h>

#define NAME_MAX 255

typedef struct FSType FSType;
typedef struct FileSystem FileSystem;
typedef struct SuperBlock SuperBlock;
typedef struct SuperOps SuperOps;
typedef struct Inode Inode;
typedef struct InodeOps InodeOps;
typedef struct DirEntry DirEntry;
typedef struct File File;
typedef struct FileOps FileOps;

typedef Inode *(*mount_callback_t)(FSType *, int, const char *, void *);

/* Structure for a Super Block */
struct SuperBlock {
	Object obj;
	FSType *type;
	SuperOps *ops;
	Inode *root;
	ObjectList *inodes; /* List of cached inodes */
	void *data;
};
struct SuperOps {
	Inode *(*alloc_inode)(SuperBlock *);
	int (*write_inode)(Inode *);
	void (*delete_inode)(Inode *);
};

/* Structure for an Inode */
struct Inode {
	Object obj;
	ino_t ino;
	uid_t uid;
	gid_t gid;
	mode_t mode;
	nlink_t nlink;
	size_t size;
	dev_t dev;
	InodeOps *ops;
	FileOps *fileOps;
	SuperBlock *super;
	union {
		ObjectList *dirEntries;
		ObjectList *pages;
	};
};
struct InodeOps {
};

/* Structure for a Directory Entry */
struct DirEntry {
	Object obj;
	Inode *inode, *mnt;
	uint32_t hash;
	char name[NAME_MAX];
	SuperBlock *super;
};

/* Structure for an open File */
struct File {
	Object obj;
	Inode *inode;
	int flags;
	off_t pos;
	FileOps *ops;
	ObjectList *path;
};
struct FileOps {
};

extern ObjectType fstypeType;
extern ObjectType fsType;
extern ObjectType inodeType;
extern ObjectType dirEntryType;
extern ObjectType fileType;

void init_vfs(void);
void register_fstype(const char *name,	mount_callback_t mount);
int mount(const char *src, const char *target, const char *type,
          unsigned long flags, void *data);
DirEntry *find_direntry(ObjectList *list, const char *name);

#endif