X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fvfs%2Fmain.c;h=c0c37e1d5feeb4200f931085bd9d9e76a3f02add;hb=4d498b090274b87befa5652589e0aa54b2b6fe0a;hp=4722aae5ebfd3203f034df184e397271f2bd2de2;hpb=1e7db40300bc594cf708bb6082a6e05a268da946;p=tpg%2Facess2.git diff --git a/Kernel/vfs/main.c b/Kernel/vfs/main.c index 4722aae5..c0c37e1d 100644 --- a/Kernel/vfs/main.c +++ b/Kernel/vfs/main.c @@ -2,7 +2,7 @@ * Acess 2 * Virtual File System */ -#include +#include #include #include "vfs.h" #include "vfs_int.h" @@ -13,16 +13,21 @@ extern tVFS_Driver gRootFS_Info; extern tVFS_Driver gDevFS_Info; // === PROTOTYPES === - int VFS_Init(); -char *VFS_GetTruePath(char *Path); +#if 0 + int VFS_Init(void); +char *VFS_GetTruePath(const char *Path); void VFS_GetMemPath(char *Dest, void *Base, Uint Length); -tVFS_Driver *VFS_GetFSByName(char *Name); +tVFS_Driver *VFS_GetFSByName(const char *Name); int VFS_AddDriver(tVFS_Driver *Info); -void VFS_UpdateDriverFile(); +#endif +void VFS_UpdateDriverFile(void); + +// === EXPORTS === +EXPORT(VFS_AddDriver); // === GLOBALS === tVFS_Node NULLNode = {0}; -tSpinlock siDriverListLock = 0; +tShortSpinlock slDriverListLock; tVFS_Driver *gVFS_Drivers = NULL; char *gsVFS_DriverFile = NULL; int giVFS_DriverFileID = 0; @@ -32,10 +37,10 @@ char *gsVFS_MountFile = NULL; // === CODE === /** - * \fn int VFS_Init() + * \fn int VFS_Init(void) * \brief Initialises the VFS for use by the kernel and user */ -int VFS_Init() +int VFS_Init(void) { // Core Drivers gVFS_Drivers = &gRootFS_Info; @@ -46,7 +51,10 @@ int VFS_Init() giVFS_MountFileID = SysFS_RegisterFile("VFS/Mounts", NULL, 0); giVFS_DriverFileID = SysFS_RegisterFile("VFS/Drivers", NULL, 0); - VFS_Mount("root", "/", "rootfs", ""); + if( VFS_Mount("root", "/", "rootfs", "") != 0 ) { + Panic("Unable to mount root (Where the **** is rootfs?)"); + return -1; + } VFS_MkDir("/Devices"); VFS_MkDir("/Mount"); VFS_Mount("dev", "/Devices", "devfs", ""); @@ -56,18 +64,20 @@ int VFS_Init() } /** - * \fn char *VFS_GetTruePath(char *Path) + * \fn char *VFS_GetTruePath(const char *Path) * \brief Gets the true path (non-symlink) of a file */ -char *VFS_GetTruePath(char *Path) +char *VFS_GetTruePath(const char *Path) { tVFS_Node *node; char *ret, *tmp; tmp = VFS_GetAbsPath(Path); if(tmp == NULL) return NULL; + //Log(" VFS_GetTruePath: tmp = '%s'", tmp); node = VFS_ParsePath(tmp, &ret); free(tmp); + //Log(" VFS_GetTruePath: node=%p, ret='%s'", node, ret); if(!node) return NULL; if(node->Close) node->Close(node); @@ -81,25 +91,24 @@ char *VFS_GetTruePath(char *Path) */ 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' ); + itoa( &Dest[1], (tVAddr)Base, 16, BITS/4, '0' ); Dest[BITS/4+1] = ':'; itoa( &Dest[BITS/4+2], Length, 16, BITS/4, '0' ); - - Log("VFS_GetMemPath: Dest = \"%s\"", Dest); + Dest[BITS/2+2] = '\0'; } /** - * \fn tVFS_Driver *VFS_GetFSByName(char *Name) + * \fn tVFS_Driver *VFS_GetFSByName(const char *Name) * \brief Gets a filesystem structure given a name */ -tVFS_Driver *VFS_GetFSByName(char *Name) +tVFS_Driver *VFS_GetFSByName(const char *Name) { tVFS_Driver *drv = gVFS_Drivers; for(;drv;drv=drv->Next) { +// Log("strcmp('%s' (%p), '%s') == 0?", drv->Name, drv->Name, Name); if(strcmp(drv->Name, Name) == 0) return drv; } @@ -113,10 +122,10 @@ int VFS_AddDriver(tVFS_Driver *Info) { if(!Info) return -1; - LOCK( &siDriverListLock ); + SHORTLOCK( &slDriverListLock ); Info->Next = gVFS_Drivers; gVFS_Drivers = Info; - RELEASE( &siDriverListLock ); + SHORTREL( &slDriverListLock ); VFS_UpdateDriverFile(); @@ -124,10 +133,10 @@ int VFS_AddDriver(tVFS_Driver *Info) } /** - * \fn void VFS_UpdateDriverFile() + * \fn void VFS_UpdateDriverFile(void) * \brief Updates the driver list file */ -void VFS_UpdateDriverFile() +void VFS_UpdateDriverFile(void) { tVFS_Driver *drv; int len = 0;