49 lines
852 B
C
49 lines
852 B
C
/*****
|
|
*
|
|
* Interface for OS with
|
|
* filesystem modules
|
|
* fd table: connect file
|
|
* descriptors with actual
|
|
* files (inodes)
|
|
*
|
|
*****/
|
|
|
|
#pragma once
|
|
|
|
#include<stdint.h>
|
|
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<string.h>
|
|
#include"err.h"
|
|
|
|
#define BLOCKSIZE 4096
|
|
#define VFS_GENID() 0
|
|
|
|
typedef uint32_t fstype_t;
|
|
|
|
// An inode represents an actual file
|
|
typedef struct inode
|
|
{
|
|
uint32_t atime;
|
|
uint8_t flags;
|
|
} inode;
|
|
|
|
// Filesystem header/super_block
|
|
typedef struct FsHdr
|
|
{
|
|
uint8_t*address;
|
|
size_t length;
|
|
uint32_t id;
|
|
fstype_t type;
|
|
}FsHdr;
|
|
|
|
extern FsHdr filesystem;
|
|
|
|
// Function type to read from filesystem
|
|
typedef void(*fs_read_t)(uint32_t offset,uint32_t size);
|
|
typedef void(*fs_read_inode_t)(inode*inode_buffer,uint32_t offset);
|
|
|
|
err_t fs_mount_root(FsHdr*fs);
|
|
err_t fs_stat(const char*const path);
|
|
void fs_print(const FsHdr*const fs);
|