X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fvfs%2Fmain.c;h=736b578557204493bcae1f22ef9dc8547150c114;hb=c3d486ba13c6cd12558d4c0cf01d3fd93e797d64;hp=3d1f8e58201aa715afaa38a3e655b58c0f13e4e9;hpb=466eda7c917791866a29c253c6c22197faf41bf7;p=tpg%2Facess2.git diff --git a/Kernel/vfs/main.c b/Kernel/vfs/main.c index 3d1f8e58..736b5785 100644 --- a/Kernel/vfs/main.c +++ b/Kernel/vfs/main.c @@ -2,7 +2,8 @@ * Acess 2 * Virtual File System */ -#include +#include +#include #include "vfs.h" #include "vfs_int.h" #include "vfs_ext.h" @@ -11,10 +12,26 @@ extern tVFS_Driver gRootFS_Info; extern tVFS_Driver gDevFS_Info; +// === PROTOTYPES === + int VFS_Init(); +char *VFS_GetTruePath(char *Path); +void VFS_GetMemPath(char *Dest, void *Base, Uint Length); +tVFS_Driver *VFS_GetFSByName(char *Name); + int VFS_AddDriver(tVFS_Driver *Info); +void VFS_UpdateDriverFile(); + +// === EXPORTS === +EXPORT(VFS_AddDriver); + // === GLOBALS === tVFS_Node NULLNode = {0}; -static int siDriverListLock = 0; +tSpinlock siDriverListLock = 0; tVFS_Driver *gVFS_Drivers = NULL; +char *gsVFS_DriverFile = NULL; + int giVFS_DriverFileID = 0; + +char *gsVFS_MountFile = NULL; + int giVFS_MountFileID = 0; // === CODE === /** @@ -26,6 +43,11 @@ int VFS_Init() // Core Drivers gVFS_Drivers = &gRootFS_Info; gVFS_Drivers->Next = &gDevFS_Info; + VFS_UpdateDriverFile(); + + // Register with SysFS + giVFS_MountFileID = SysFS_RegisterFile("VFS/Mounts", NULL, 0); + giVFS_DriverFileID = SysFS_RegisterFile("VFS/Drivers", NULL, 0); VFS_Mount("root", "/", "rootfs", ""); VFS_MkDir("/Devices"); @@ -57,16 +79,17 @@ char *VFS_GetTruePath(char *Path) } /** - * \fn void VFS_GetMemPath(void *Base, Uint Length, char *Dest) + * \fn void VFS_GetMemPath(char *Dest, void *Base, Uint Length) * \brief Create a VFS memory pointer path */ -void VFS_GetMemPath(void *Base, Uint Length, char *Dest) +void VFS_GetMemPath(char *Dest, void *Base, Uint Length) { Log("VFS_GetMemPath: (Base=%p, Length=0x%x, Dest=%p)", Base, Length, Dest); Dest[0] = '$'; itoa( &Dest[1], (Uint)Base, 16, BITS/4, '0' ); Dest[BITS/4+1] = ':'; itoa( &Dest[BITS/4+2], Length, 16, BITS/4, '0' ); + Dest[BITS/2+2] = '\0'; Log("VFS_GetMemPath: Dest = \"%s\"", Dest); } @@ -99,5 +122,38 @@ int VFS_AddDriver(tVFS_Driver *Info) gVFS_Drivers = Info; RELEASE( &siDriverListLock ); + VFS_UpdateDriverFile(); + return 0; } + +/** + * \fn void VFS_UpdateDriverFile() + * \brief Updates the driver list file + */ +void VFS_UpdateDriverFile() +{ + tVFS_Driver *drv; + int len = 0; + char *buf; + + // Format: + // \n + for( drv = gVFS_Drivers; drv; drv = drv->Next ) + { + len += 1 + strlen(drv->Name); + } + buf = malloc(len+1); + len = 0; + for( drv = gVFS_Drivers; drv; drv = drv->Next ) + { + strcpy( &buf[len], drv->Name ); + len += strlen(drv->Name); + buf[len++] = '\n'; + } + buf[len] = '\0'; + + SysFS_UpdateFile( giVFS_DriverFileID, buf, len ); + if(gsVFS_DriverFile) free(gsVFS_DriverFile); + gsVFS_DriverFile = buf; +}