From: John Hodge Date: Sat, 26 Sep 2009 01:54:54 +0000 (+0800) Subject: Added "Free Me" Flag to VFS_ReadDir X-Git-Tag: rel0.06~498 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=f6b468cee21ebf1c9b98efec5315950aa043ead5;p=tpg%2Facess2.git Added "Free Me" Flag to VFS_ReadDir --- diff --git a/Kernel/include/vfs.h b/Kernel/include/vfs.h index 99250e12..cbec1406 100644 --- a/Kernel/include/vfs.h +++ b/Kernel/include/vfs.h @@ -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; diff --git a/Kernel/vfs/dir.c b/Kernel/vfs/dir.c index ba2311e0..b7133c50 100644 --- a/Kernel/vfs/dir.c +++ b/Kernel/vfs/dir.c @@ -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; diff --git a/Kernel/vfs/fs/fat.c b/Kernel/vfs/fs/fat.c index 8cfeca44..d42a1b00 100644 --- a/Kernel/vfs/fs/fat.c +++ b/Kernel/vfs/fs/fat.c @@ -701,7 +701,7 @@ char *FAT_ReadDir(tVFS_Node *dirNode, int dirpos) // Get the current length len = strlen(lfn); - // Sanity Check (FAT implementations do not allow >255 bytes) + // Sanity Check (FAT implementations should not allow >255 bytes) if(len + 13 > 255) return VFS_SKIP; // Rebase all bytes for(a=len+1;a--;) lfn[a+13] = lfn[a]; @@ -745,7 +745,7 @@ char *FAT_ReadDir(tVFS_Node *dirNode, int dirpos) #endif LEAVE('s', ret); - return ret; + return VFS_FREEPLZ(ret); } /** diff --git a/Usermode/Applications/CLIShell_src/main.c b/Usermode/Applications/CLIShell_src/main.c index e806a537..aa1d9abe 100644 --- a/Usermode/Applications/CLIShell_src/main.c +++ b/Usermode/Applications/CLIShell_src/main.c @@ -412,8 +412,12 @@ void Command_Dir(int argc, char **argv) // Get File Stats finfo(fp, &info, 0); - //Print Mode - //#if 0 + if(info.flags & FILEFLAG_DIRECTORY) + write(_stdout, 1, "d"); + else + write(_stdout, 1, "-"); + + // Print Mode acl.group = 0; acl.id = info.uid; _SysGetACL(fp, &acl); if(acl.perms & 1) modeStr[0] = 'r'; else modeStr[0] = '-'; @@ -430,16 +434,16 @@ void Command_Dir(int argc, char **argv) if(acl.perms & 1) modeStr[7] = 'w'; else modeStr[7] = '-'; if(acl.perms & 1) modeStr[8] = 'x'; else modeStr[8] = '-'; write(_stdout, 10, modeStr); - //#endif close(fp); // Colour Code if(info.flags & FILEFLAG_DIRECTORY) // Directory: Green write(_stdout, 6, "\x1B[32m"); - else - write(_stdout, 6, "\x1B[37m"); // Default: White + // Default: White + // Print Name write(_stdout, strlen(fileName), fileName); + // Print slash if applicable if(info.flags & FILEFLAG_DIRECTORY) write(_stdout, 1, "/"); @@ -447,10 +451,8 @@ void Command_Dir(int argc, char **argv) // Revert Colour write(_stdout, 6, "\x1B[37m"); - // Put Size - printf("\n", info.size); - - //write(_stdout, 1, "\n"); + // Newline! + write(_stdout, 1, "\n"); } // Close Directory close(dp);