Added "Free Me" Flag to VFS_ReadDir
authorJohn Hodge <[email protected]>
Sat, 26 Sep 2009 01:54:54 +0000 (09:54 +0800)
committerJohn Hodge <[email protected]>
Sat, 26 Sep 2009 01:54:54 +0000 (09:54 +0800)
Kernel/include/vfs.h
Kernel/vfs/dir.c
Kernel/vfs/fs/fat.c
Usermode/Applications/CLIShell_src/main.c

index 99250e1..cbec140 100644 (file)
@@ -88,6 +88,7 @@ typedef struct sVFS_Driver {
 #define        VFS_MAXSKIP     ((void*)1024)
 #define        VFS_SKIP        ((void*)1)
 #define        VFS_SKIPN(n)    ((void*)(n))
+#define VFS_FREEPLZ(ptr)       ((void*)(((Uint)ptr)|1))
 extern tVFS_Node       NULLNode;
 extern tVFS_ACL        gVFS_ACL_EveryoneRWX;
 extern tVFS_ACL        gVFS_ACL_EveryoneRW;
index ba2311e..b7133c5 100644 (file)
@@ -169,7 +169,8 @@ int VFS_ReadDir(int FD, char *Dest)
        
        strcpy(Dest, tmp);
        
-       if(IsHeap(tmp)) free(tmp);
+       if((Uint)tmp & 1)
+               free((void*)( (Uint)tmp & ~1 ));
        
        LEAVE('i', 1);
        return 1;
index 8cfeca4..d42a1b0 100644 (file)
@@ -701,7 +701,7 @@ char *FAT_ReadDir(tVFS_Node *dirNode, int dirpos)
                // Get the current length\r
                len = strlen(lfn);\r
                \r
-               // Sanity Check (FAT implementations do not allow >255 bytes)\r
+               // Sanity Check (FAT implementations should not allow >255 bytes)\r
                if(len + 13 > 255)      return VFS_SKIP;\r
                // Rebase all bytes\r
                for(a=len+1;a--;)       lfn[a+13] = lfn[a];\r
@@ -745,7 +745,7 @@ char *FAT_ReadDir(tVFS_Node *dirNode, int dirpos)
        #endif\r
        \r
        LEAVE('s', ret);\r
-       return ret;\r
+       return VFS_FREEPLZ(ret);\r
 }\r
 \r
 /**\r
index e806a53..aa1d9ab 100644 (file)
@@ -412,8 +412,12 @@ void Command_Dir(int argc, char **argv)
                // Get File Stats\r
                finfo(fp, &info, 0);\r
                \r
-               //Print Mode\r
-               //#if 0\r
+               if(info.flags & FILEFLAG_DIRECTORY)\r
+                       write(_stdout, 1, "d");\r
+               else\r
+                       write(_stdout, 1, "-");\r
+               \r
+               // Print Mode\r
                acl.group = 0;  acl.id = info.uid;\r
                _SysGetACL(fp, &acl);\r
                if(acl.perms & 1)       modeStr[0] = 'r';       else    modeStr[0] = '-';\r
@@ -430,16 +434,16 @@ void Command_Dir(int argc, char **argv)
                if(acl.perms & 1)       modeStr[7] = 'w';       else    modeStr[7] = '-';\r
                if(acl.perms & 1)       modeStr[8] = 'x';       else    modeStr[8] = '-';\r
                write(_stdout, 10, modeStr);\r
-               //#endif\r
                close(fp);\r
                \r
                // Colour Code\r
                if(info.flags & FILEFLAG_DIRECTORY)     // Directory: Green\r
                        write(_stdout, 6, "\x1B[32m");\r
-               else\r
-                       write(_stdout, 6, "\x1B[37m");  // Default: White\r
+               // Default: White\r
+               \r
                // Print Name\r
                write(_stdout, strlen(fileName), fileName);\r
+               \r
                // Print slash if applicable\r
                if(info.flags & FILEFLAG_DIRECTORY)\r
                        write(_stdout, 1, "/");\r
@@ -447,10 +451,8 @@ void Command_Dir(int argc, char **argv)
                // Revert Colour\r
                write(_stdout, 6, "\x1B[37m");\r
                \r
-               // Put Size\r
-               printf("\n", info.size);\r
-               \r
-               //write(_stdout, 1, "\n");\r
+               // Newline!\r
+               write(_stdout, 1, "\n");\r
        }\r
        // Close Directory\r
        close(dp);\r

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