Nucleus
Barry Files namespace f0dcd54 (3 years, 3 months ago)
diff --git a/include/nucleus/vfs.h b/include/nucleus/vfs.h
index ebd5396..59162c0 100644
--- a/include/nucleus/vfs.h
+++ b/include/nucleus/vfs.h
@@ -6,10 +6,13 @@
#include <nucleus/object.h>
#include <nucleus/memory.h>
+#define NFILES 32
#define NAME_MAX 255
+#define PATH_MAX 1024
typedef struct FSType FSType;
typedef struct FileSystem FileSystem;
+typedef struct Files Files;
typedef struct SuperBlock SuperBlock;
typedef struct SuperOps SuperOps;
typedef struct Inode Inode;
@@ -48,12 +51,16 @@ struct Inode {
InodeOps *ops;
FileOps *fileOps;
SuperBlock *super;
- union {
- ObjectList *dirEntries;
- ObjectList *pages;
- };
+ ObjectList *dirEntries;
+ ObjectList *pages;
};
struct InodeOps {
+ int (*create)(Inode *, DirEntry *, mode_t);
+ Inode *(*lookup)(Inode *, const char *);
+ int (*mkdir)(Inode *, DirEntry *, mode_t);
+ int (*rmdir)(Inode *, DirEntry *);
+ int (*mknod)(Inode *, DirEntry *, mode_t, dev_t);
+ int (*rename)(Inode *, DirEntry *, Inode *, DirEntry *);
};
/* Structure for a Directory Entry */
@@ -75,10 +82,15 @@ struct File {
ObjectList *path;
};
struct FileOps {
+ size_t (*read)(File *, char *, size_t, off_t);
+ size_t (*write)(File *, char *, size_t, off_t);
+ int (*open)(File *);
};
extern ObjectType fstypeType;
extern ObjectType fsType;
+extern ObjectType filesType;
+extern ObjectType superBlockType;
extern ObjectType inodeType;
extern ObjectType dirEntryType;
extern ObjectType fileType;
@@ -87,6 +99,23 @@ 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);
+
+/* Super Block functions */
+Inode *super_alloc_inode(SuperBlock *sb);
+Inode *super_find_inode(SuperBlock *sb, ino_t ino);
+/* Inode functions */
+int permission(Inode *inode, int mask);
+int inode_create(Inode *inode, DirEntry *entry, mode_t mode);
+DirEntry *inode_lookup(Inode *inode, const char *name);
+/* Directory Entry functions */
DirEntry *find_direntry(ObjectList *list, const char *name);
+/* File functions */
+int file_open(File *file);
+size_t file_read(File *file, char *buf, size_t count);
+size_t file_write(File *file, char *buf, size_t count);
+/* Files namespace functions */
+File *get_file_by_fd(int fd);
+int allocate_fd(void);
+void install_fd(int fd, File *file);
#endif