Cleaning up and Debugging (Exposed by AcessNative mostly)
[tpg/acess2.git] / Kernel / drv / proc.c
index 521bb05..0d1ae52 100644 (file)
@@ -26,12 +26,14 @@ typedef struct sSysFS_Ent
  int   SysFS_Install(char **Arguments);
  int   SysFS_IOCtl(tVFS_Node *Node, int Id, void *Data);
 
- int   SysFS_RegisterFile(char *Path, char *Data, int Length);
- int   SysFS_UpdateFile(int ID, char *Data, int Length);
+#if 0
+ int   SysFS_RegisterFile(const char *Path, const char *Data, int Length);
+ int   SysFS_UpdateFile(int ID, const char *Data, int Length);
  int   SysFS_RemoveFile(int ID);
+#endif
 
 char   *SysFS_Comm_ReadDir(tVFS_Node *Node, int Id);
-tVFS_Node      *SysFS_Comm_FindDir(tVFS_Node *Node, char *Filename);
+tVFS_Node      *SysFS_Comm_FindDir(tVFS_Node *Node, const char *Filename);
 Uint64 SysFS_Comm_ReadFile(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
 void   SysFS_Comm_CloseFile(tVFS_Node *Node);
 
@@ -44,7 +46,7 @@ tSysFS_Ent    gSysFS_Version_Kernel = {
        &gSysFS_Version,        // Parent
        {
                .Inode = 1,     // File #1
-               .ImplPtr = KERNEL_VERSION_STRING,
+               .ImplPtr = (void*)KERNEL_VERSION_STRING,
                .ImplInt = (Uint)&gSysFS_Version_Kernel,        // Self-Link
                .Size = sizeof(KERNEL_VERSION_STRING)-1,
                .NumACLs = 1,
@@ -114,7 +116,7 @@ int SysFS_Install(char **Options)
  * \param Length       Length of the data buffer
  * \return The file's identifier
  */
-int SysFS_RegisterFile(char *Path, char *Data, int Length)
+int SysFS_RegisterFile(const char *Path, const char *Data, int Length)
 {
         int    start = 0;
         int    tmp;
@@ -153,10 +155,10 @@ int SysFS_RegisterFile(char *Path, char *Data, int Length)
                        child->Node.ReadDir = SysFS_Comm_ReadDir;
                        child->Node.FindDir = SysFS_Comm_FindDir;
                        if( !prev ) {
-                               //if(ent)
+                               if(ent)
                                        ent->Node.ImplPtr = child;
-                               //else
-                               //      gSysFS_DriverInfo.RootNode.ImplPtr = child;
+                               else
+                                       gSysFS_DriverInfo.RootNode.ImplPtr = child;
                                // ^^^ Impossible (There is already /Version)
                        }
                        else
@@ -182,7 +184,7 @@ int SysFS_RegisterFile(char *Path, char *Data, int Length)
                child = ent->Node.ImplPtr;
        else
                child = gSysFS_DriverInfo.RootNode.ImplPtr;
-       for( child = ent->Node.ImplPtr; child; prev = child, child = child->Next )
+       for( ; child; child = child->Next )
        {
                if( strcmp( &Path[start], child->Name ) == 0 )
                        break;
@@ -199,7 +201,7 @@ int SysFS_RegisterFile(char *Path, char *Data, int Length)
        child->Parent = ent;
        
        child->Node.Inode = giSysFS_NextFileID++;
-       child->Node.ImplPtr = Data;
+       child->Node.ImplPtr = (void*)Data;
        child->Node.ImplInt = (Uint)child;      // Uplink
        child->Node.Size = Length;
        child->Node.NumACLs = 1;
@@ -235,7 +237,7 @@ int SysFS_RegisterFile(char *Path, char *Data, int Length)
  * \param Length       Length of the data buffer
  * \return Boolean Success
  */
-int SysFS_UpdateFile(int ID, char *Data, int Length)
+int SysFS_UpdateFile(int ID, const char *Data, int Length)
 {
        tSysFS_Ent      *ent;
        
@@ -245,7 +247,7 @@ int SysFS_UpdateFile(int ID, char *Data, int Length)
                if(ent->Node.Inode < ID)        return 0;
                if(ent->Node.Inode == ID)
                {
-                       ent->Node.ImplPtr = Data;
+                       ent->Node.ImplPtr = (void*)Data;
                        ent->Node.Size = Length;
                        return 1;
                }
@@ -281,7 +283,10 @@ int SysFS_RemoveFile(int ID)
        parent = file->Parent;
        
        // Remove from file list
-       prev->ListNext = file->ListNext;
+       if(prev)
+               prev->ListNext = file->ListNext;
+       else
+               gSysFS_FileList = file->ListNext;
        file->Node.Size = 0;
        file->Node.ImplPtr = NULL;
        
@@ -322,10 +327,10 @@ char *SysFS_Comm_ReadDir(tVFS_Node *Node, int Pos)
 }
 
 /**
- * \fn tVFS_Node *SysFS_Comm_FindDir(tVFS_Node *Node, char *Filename)
+ * \fn tVFS_Node *SysFS_Comm_FindDir(tVFS_Node *Node, const char *Filename)
  * \brief Find a file in a SysFS directory
  */
-tVFS_Node *SysFS_Comm_FindDir(tVFS_Node *Node, char *Filename)
+tVFS_Node *SysFS_Comm_FindDir(tVFS_Node *Node, const char *Filename)
 {
        tSysFS_Ent      *child = (tSysFS_Ent*)Node->ImplPtr;
        

UCC git Repository :: git.ucc.asn.au