X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fdrv%2Fproc.c;h=521bb055a70b5887edaf453c34c8b867eeac058b;hb=e29b02ca55d580b2f7f10d1093c3d6ad1bc59458;hp=9aa0a34039f70e6092d522ac40fcd86fc1020418;hpb=243bdab4e7acc8516d9b1c138f45dc1195f97767;p=tpg%2Facess2.git diff --git a/Kernel/drv/proc.c b/Kernel/drv/proc.c index 9aa0a340..521bb055 100644 --- a/Kernel/drv/proc.c +++ b/Kernel/drv/proc.c @@ -3,7 +3,7 @@ * - Kernel Status Driver */ #define DEBUG 1 -#include +#include #include #include #include @@ -18,8 +18,8 @@ typedef struct sSysFS_Ent struct sSysFS_Ent *Next; struct sSysFS_Ent *ListNext; struct sSysFS_Ent *Parent; - char *Name; tVFS_Node Node; + char Name[]; } tSysFS_Ent; // === PROTOTYPES === @@ -42,7 +42,6 @@ MODULE_DEFINE(0, VERSION, SysFS, SysFS_Install, NULL, NULL); tSysFS_Ent gSysFS_Version_Kernel = { NULL, NULL, // Nexts &gSysFS_Version, // Parent - "Kernel", { .Inode = 1, // File #1 .ImplPtr = KERNEL_VERSION_STRING, @@ -51,12 +50,12 @@ tSysFS_Ent gSysFS_Version_Kernel = { .NumACLs = 1, .ACLs = &gVFS_ACL_EveryoneRO, .Read = SysFS_Comm_ReadFile - } + }, + "Kernel" }; tSysFS_Ent gSysFS_Version = { NULL, NULL, &gSysFS_Root, - "Version", { .Size = 1, .ImplPtr = &gSysFS_Version_Kernel, @@ -66,23 +65,19 @@ tSysFS_Ent gSysFS_Version = { .Flags = VFS_FFLAG_DIRECTORY, .ReadDir = SysFS_Comm_ReadDir, .FindDir = SysFS_Comm_FindDir - } + }, + "Version" }; -// Root of the SysFS tree (just used for clean code) +// Root of the SysFS tree (just used to keep the code clean) tSysFS_Ent gSysFS_Root = { NULL, NULL, NULL, - "/", { .Size = 1, .ImplPtr = &gSysFS_Version, .ImplInt = (Uint)&gSysFS_Root // Self-Link - // .NumACLs = 1, - // .ACLs = &gVFS_ACL_EveryoneRX, - // .Flags = VFS_FFLAG_DIRECTORY, - // .ReadDir = SysFS_Comm_ReadDir, - // .FindDir = SysFS_Comm_FindDir - } + }, + "/" }; tDevFS_Driver gSysFS_DriverInfo = { NULL, "system", @@ -108,7 +103,7 @@ tSysFS_Ent *gSysFS_FileList; int SysFS_Install(char **Options) { DevFS_AddDevice( &gSysFS_DriverInfo ); - return 0; + return MODULE_ERR_OK; } /** @@ -144,9 +139,8 @@ int SysFS_RegisterFile(char *Path, char *Data, int Length) // Need a new directory? if( !child ) { - child = calloc( 1, sizeof(tSysFS_Ent) ); + child = calloc( 1, sizeof(tSysFS_Ent)+tmp+1 ); child->Next = NULL; - child->Name = malloc(tmp+1); memcpy(child->Name, &Path[start], tmp); child->Name[tmp] = '\0'; child->Parent = ent; @@ -163,7 +157,7 @@ int SysFS_RegisterFile(char *Path, char *Data, int Length) ent->Node.ImplPtr = child; //else // gSysFS_DriverInfo.RootNode.ImplPtr = child; - // ^^^ Impossible (There is already /Version + // ^^^ Impossible (There is already /Version) } else prev->Next = child; @@ -171,7 +165,7 @@ int SysFS_RegisterFile(char *Path, char *Data, int Length) ent->Node.Size ++; else gSysFS_DriverInfo.RootNode.Size ++; - LOG("Added directory '%s'\n", child->Name); + Log_Log("SysFS", "Added directory '%s'", child->Name); } ent = child; @@ -194,14 +188,14 @@ int SysFS_RegisterFile(char *Path, char *Data, int Length) break; } if( child ) { - Warning("[SYSFS] '%s' is taken (in '%s')\n", &Path[start], Path); + Log_Warning("SysFS", "'%s' is taken (in '%s')\n", &Path[start], Path); return 0; } // Create new node - child = calloc( 1, sizeof(tSysFS_Ent) ); + child = calloc( 1, sizeof(tSysFS_Ent)+strlen(&Path[start])+1 ); child->Next = NULL; - child->Name = strdup(&Path[start]); + strcpy(child->Name, &Path[start]); child->Parent = ent; child->Node.Inode = giSysFS_NextFileID++; @@ -228,7 +222,7 @@ int SysFS_RegisterFile(char *Path, char *Data, int Length) child->ListNext = gSysFS_FileList; gSysFS_FileList = child; - Log("[SYSFS] Added '%s' (%p)", Path, Data); + Log_Log("SysFS", "Added '%s' (%p)", Path, Data); return child->Node.Inode; } @@ -297,7 +291,7 @@ int SysFS_RemoveFile(int ID) if( ent == file ) break; } if(!ent) { - Warning("[SYSFS] Bookkeeping Error: File in list, but not in directory"); + Log_Warning("SysFS", "Bookkeeping Error: File in list, but not in directory"); return 0; }