2014-08-01 21:15:06 +00:00
|
|
|
|
|
|
|
#ifndef __SYS_VFS_H__
|
|
|
|
#define __SYS_VFS_H__
|
|
|
|
|
2014-09-06 01:06:03 +00:00
|
|
|
#include <sys/kmem.h>
|
2014-12-05 08:25:20 +00:00
|
|
|
#include <sys/stat.h>
|
2014-09-06 01:06:03 +00:00
|
|
|
|
2014-08-01 21:15:06 +00:00
|
|
|
typedef struct VFSOp VFSOp;
|
|
|
|
typedef struct VNode VNode;
|
|
|
|
|
|
|
|
typedef struct VFS {
|
|
|
|
VFSOp *op;
|
|
|
|
Disk *disk;
|
|
|
|
Spinlock lock;
|
|
|
|
uint64_t refCount;
|
|
|
|
// FS Fields
|
|
|
|
void *fsptr;
|
|
|
|
uint64_t fsval;
|
2023-11-22 02:37:17 +00:00
|
|
|
uint64_t blksize;
|
2014-08-01 21:15:06 +00:00
|
|
|
VNode *root;
|
2023-11-22 02:37:17 +00:00
|
|
|
void *bitmap[16];
|
2014-08-01 21:15:06 +00:00
|
|
|
} VFS;
|
|
|
|
|
|
|
|
typedef struct VNode {
|
|
|
|
VFSOp *op;
|
|
|
|
Disk *disk;
|
|
|
|
Spinlock lock;
|
|
|
|
uint64_t refCount;
|
|
|
|
// FS Fields
|
|
|
|
void *fsptr;
|
|
|
|
uint64_t fsval;
|
2014-08-01 22:50:04 +00:00
|
|
|
VFS *vfs;
|
2014-08-01 21:15:06 +00:00
|
|
|
} VNode;
|
|
|
|
|
2014-09-06 01:06:03 +00:00
|
|
|
DECLARE_SLAB(VFS);
|
|
|
|
DECLARE_SLAB(VNode);
|
|
|
|
|
2014-08-01 21:15:06 +00:00
|
|
|
typedef struct VFSOp {
|
|
|
|
// VFS Operations
|
|
|
|
int (*unmount)(VFS *fs);
|
|
|
|
int (*getroot)(VFS *fs, VNode **dn);
|
|
|
|
// VNode Operations
|
|
|
|
int (*lookup)(VNode *dn, VNode **fn, const char *name);
|
|
|
|
int (*open)(VNode *fn);
|
|
|
|
int (*close)(VNode *fn);
|
2014-12-05 08:25:20 +00:00
|
|
|
int (*stat)(VNode *fn, struct stat *sb);
|
2014-08-01 21:15:06 +00:00
|
|
|
int (*read)(VNode *fn, void *buf, uint64_t off, uint64_t len);
|
2014-12-05 08:25:20 +00:00
|
|
|
int (*write)(VNode *fn, void *buf, uint64_t off, uint64_t len);
|
|
|
|
int (*readdir)(VNode *fn, void *buf, uint64_t len, uint64_t *off);
|
2014-08-01 21:15:06 +00:00
|
|
|
} VFSOp;
|
|
|
|
|
|
|
|
int VFS_MountRoot(Disk *root);
|
|
|
|
VNode *VFS_Lookup(const char *path);
|
2014-12-05 08:25:20 +00:00
|
|
|
// XXX: Release/Retain
|
|
|
|
int VFS_Stat(const char *path, struct stat *sb);
|
2014-08-01 21:15:06 +00:00
|
|
|
int VFS_Open(VNode *fn);
|
|
|
|
int VFS_Close(VNode *fn);
|
|
|
|
int VFS_Read(VNode *fn, void *buf, uint64_t off, uint64_t len);
|
2023-11-22 02:37:17 +00:00
|
|
|
int VFS_Write(VNode *fn, void *buf, uint64_t off, uint64_t len);
|
2014-12-05 08:25:20 +00:00
|
|
|
int VFS_ReadDir(VNode *fn, void *buf, uint64_t len, uint64_t *off);
|
2014-09-06 01:06:03 +00:00
|
|
|
|
2014-08-01 21:15:06 +00:00
|
|
|
#endif /* __SYS_VFS_H__ */
|
|
|
|
|