[GOOD] BUILD 0.1.0.590 DATE 9/05/2011 AT 2:40 PM

====================================================
Mainly changed: FS.Initrd
+ (kind of) refractored VFS, bugfixed
+ Rewrote 'initrd' file system, fixed many problems
+ Working 'cat' and 'dir' console commands
+ Wrote 'initrd' image write application (for windows), however it may
be bugged
This commit is contained in:
2021-09-14 18:52:47 +03:00
parent caa7718af9
commit 852cf1bb17
71 changed files with 1979 additions and 659 deletions

View File

@ -258,41 +258,45 @@ void CommandRead(string argv[], int32 argc)
}
extern MountPoint* mpArray;
extern uint32 mpCount;
void CommandDir (string argv[], int32 argc)
{
if (argc < 2)
{
// No parameters? Display root content
if (argc < 2) {
ConsoleWrite ("Content of root: \n\n");
uint32 i = 0;
MountPoint* mp = VfsGetMountPoint(0);
for (i = 0; i < mpCount; i++)
ConsoleWrite ("\t\t[DEV] %s\n", mpArray[i].Name);
for (i = 1; mp != NULL; i++)
{
ConsoleWrite ("\t[DEV] %s\n", mp->Name);
mp = VfsGetMountPoint(i);
}
return;
}
// Make sure directory exists
DirectoryEntry* temp = VfsTest(argv[1]);
if (temp == NULL)
{
ConsoleWrite("%#! Invalid path!\n", ColorLightRed);
return;
if (temp == NULL) {
ConsoleWrite("%#! Invalid path!\n", ColorLightRed); return;
}
// Write contents
ConsoleWrite ("Content of directory %#%s:\n\n", ColorWhite, argv[1]);
FILE dir; VfsOpen(&dir, argv[1]);
uint32 i;
temp = VfsReadDirectory(&dir,0);
for (i = 1; temp != NULL; i++, temp = VfsReadDirectory(&dir, 0))
for (i = 1; temp != NULL; i++)
{
ConsoleWrite ("\t\t[%s] ", (temp->Flags & 0x1) ? "FIL" : "DIR" );
ConsoleWrite ("\t[%s] ", (temp->Flags & 0x1) ? "FIL" : "DIR" );
ConsoleWrite ("%s", temp->Name);
Point p = {60, -1}; ConsoleCursorGoto(p);
ConsoleWrite ("%u bytes\n", temp->Size);
temp = VfsReadDirectory(&dir, i);
}
VfsClose(&dir);
@ -305,18 +309,25 @@ void CommandCat (string argv[], int32 argc)
return;
}
ConsoleWrite("Contents of file %s:\n--------------------------\n");
FILE f;
VfsOpen(&f, argv[1]);
uint8* buffer = kmalloc(0x1000);
uint32 sz, i;
while ((sz = VfsRead(&f, 1, 0x1000, buffer)))
{
for (i = 0; i < sz; i++) ConsoleWrite("%c", buffer[i]);
// Try to open
if (!VfsOpen(&f, argv[1])) {
ConsoleWrite ("%#! Invalid file: %s\n.", ColorLightRed, argv[1]);
return;
}
ConsoleWrite("\n--------------------------\n");
uint8* buffer = kmalloc(0x100);
uint32 sz, i;
ConsoleWrite("----[%s]------\n", argv[1]);
while ((sz = VfsRead(&f, 1, 0x100, buffer)))
{
for (i = 0; i < sz; i++) ConsoleWrite("%#%c", ColorLightGray, buffer[i]);
}
ConsoleWrite("\n------------[EOF]------------\n");
kfree(buffer);
VfsClose(&f);
}