hos/kernel/fs/vfs.h

60 lines
1.7 KiB
C

// vfs.h
// Author: Josh Holtrop
// Date: 03/11/04
// Modified: 03/16/04
#ifndef __HOS_VFS__
#define __HOS_VFS__ __HOS_VFS__
#include "hos_defines.h"
#define VFS_LABEL_LENGTH 8
typedef struct
{
void *diskDevice; //pointer to device-dependent structure
int length; //size of the volume in bytes
int deviceType; //one of VFS_DISK_TYPES
int fsType; //one of VFS_FS_TYPES
char label[VFS_LABEL_LENGTH]; //descriptive volume label
void *link; //link to next volume in linked list
} Volume;
typedef struct
{
dword location; //location used by disk driver
dword dataLocation; //location used by disk driver
dword position; //read/write position in file
dword attributes; //read/write
dword fileSize; //number of bytes the file takes
Volume *vol; //what volume this file is on
} FILE;
typedef struct
{
char *device;
char *mount;
void *mp;
} MountPoint;
#define FILE_READ 1
#define FILE_WRITE 2
#define FILE_READ_WRITE 3
enum VFS_DISK_TYPES {VFS_NODISK, VFS_RD, VFS_FD, VFS_HD, VFS_LOOP, VFS_NUM_DISK_TYPES};
enum VFS_FS_TYPES {VFS_NOFS, VFS_VFAT, VFS_EXT2, VFS_NUM_FS_TYPES};
void vfs_init();
Volume *vfs_newVolume();
Volume *vfs_getLastVolume();
int vfs_readSector(Volume *vol, dword sector, byte *buffer);
int vfs_writeSector(Volume *vol, dword sector, byte *buffer);
int vfs_readSectorn(Volume *vol, dword sector, byte *buffer, int n);
int vfs_writeSectorn(Volume *vol, dword sector, byte *buffer, int n);
int vfs_readFileBlock(Volume *vol, char *file, dword start, byte *buffer, dword blockSize);
int vfs_writeFileBlock(Volume *vol, char *file, dword start, byte *buffer, dword blockSize);
#endif