Cosmos
Cosmos copied to clipboard
Filesystem not working in real hardware
Area of Cosmos - What area of Cosmos are we dealing with?
filesystem
Expected Behaviour - What do you think that should happen?
Should run like it does in vmware debugger
Actual Behaviour - What unexpectedly happens?
Reproduction - How did you get this error to appear?
make a filesystem in when Run in debugging vmware, and export as ISO, but then filesystem fails.
Version - Were you using the User Kit or Dev Kit? And what User Kit version or Dev Kit commit (Cosmos, IL2CPU, X#)?
User kit
(VMware without the debugging thing simulates real hardware)
Here is the code btw:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Sys = Cosmos.System;
namespace CosmosKernel5
{
public class Kernel : Sys.Kernel
{
protected override void BeforeRun()
{
// File system
var fs = new Sys.FileSystem.CosmosVFS();
Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs);
// Welcome message
Console.WriteLine("Welcome to Barrel OS v0.0.1 . This is the start of your future.");
}
protected override void Run()
{
Console.Write("> ");
var input = Console.ReadLine();
// Console.Write("sdfsdf: ");
// Console.WriteLine(input);
if (input == "HELP")
{
Console.WriteLine("REBOOT -- REBOOT THE SYSTEM");
Console.WriteLine("SHUTDOWN -- POWER OFF THE SYSTEM");
Console.WriteLine("CLS -- CLEAR THE SCREEN");
Console.WriteLine("CHCOLOR -- CHANGE THE COLOR OF THE SCREEN");
Console.WriteLine("LIST -- LIST ALL THE FILES AND DIRECTORIES IN THE CURRENT DIRECTORY");
Console.WriteLine("TEXT -- FS TESTING");
}
else if (input == "SHUTDOWN")
{
Cosmos.System.Power.Shutdown();
}
else if (input == "REBOOT")
{
Cosmos.System.Power.Reboot();
}
else if (input == "CLS")
{
Console.Clear();
}
else if (input == "CHCOLOR")
{
Console.WriteLine("CHCOLOR: USE: 'CHCOLOR [ARGS] [COLOR]'");
}
else if (input == "CHCOLOR -BG RED")
{
Console.BackgroundColor = ConsoleColor.Red;
}
else if (input == "CHCOLOR -FG RED")
{
Console.ForegroundColor = ConsoleColor.Red;
}
else if (input == "CHCOLOR -BG WHITE")
{
Console.BackgroundColor = ConsoleColor.White;
}
else if (input == "CHCOLOR -FG WHITE")
{
Console.ForegroundColor = ConsoleColor.White;
}
else if (input == "CHCOLOR -BG BLACK")
{
Console.BackgroundColor = ConsoleColor.Black;
}
else if (input == "CHCOLOR -FG BLACK")
{
Console.ForegroundColor = ConsoleColor.Black;
}
else if (input == "LIST")
{
Console.WriteLine("LIST: FILES/DIRS");
var directory_list = Sys.FileSystem.VFS.VFSManager.GetDirectoryListing("0:\\");
foreach (var directoryEntry in directory_list)
{
Console.WriteLine(directoryEntry.mName);
}
}
else if (input == "LIST -D")
{
// needed for main
var directory_list = Sys.FileSystem.VFS.VFSManager.GetDirectoryListing("0:\\");
Console.WriteLine("LIST: FILE CONTENT/SIZE");
// main
try
{
foreach (var directoryEntry in directory_list)
{
var file_stream = directoryEntry.GetFileStream();
var entry_type = directoryEntry.mEntryType;
if (entry_type == Sys.FileSystem.Listing.DirectoryEntryTypeEnum.File)
{
byte[] content = new byte[file_stream.Length];
file_stream.Read(content, 0, (int)file_stream.Length);
Console.WriteLine("File name: " + directoryEntry.mName);
Console.WriteLine("File size: " + directoryEntry.mSize);
Console.WriteLine("Content: ");
foreach (char ch in content)
{
Console.Write(ch.ToString());
}
Console.WriteLine();
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
else if (input == "LIST -H")
{
Console.WriteLine("LIST: USE: 'LIST [ARGS]'");
}
else if (input == "LIST -FS")
{
Console.WriteLine("FS TYPE: ");
string fs_type = Sys.FileSystem.VFS.VFSManager.GetFileSystemType("0:\\");
Console.WriteLine(fs_type);
}
else if (input == "LIST -F")
{
Console.WriteLine("LIST: FILE CONTENT IN DIR");
Console.Write("FILE_NAME> ");
var finput = Console.ReadLine();
try
{
var hello_file = Sys.FileSystem.VFS.VFSManager.GetFile(@"0:\" + finput);
var hello_file_stream = hello_file.GetFileStream();
if (hello_file_stream.CanRead)
{
byte[] text_to_read = new byte[hello_file_stream.Length];
hello_file_stream.Read(text_to_read, 0, (int)hello_file_stream.Length);
Console.WriteLine(Encoding.Default.GetString(text_to_read));
}
}
catch
{
Console.WriteLine("TASK FAILED. :(");
}
}
else if (input == "TEXT -H")
{
Console.WriteLine("TEXT: USE: 'TEXT [ARGS]'");
}
else if (input == "TEXT -EX")
{
try
{
Console.WriteLine("TEXT: WRITE TO AN EXISTING FILE.");
Console.Write("FILENAME> ");
var tinput = Console.ReadLine();
Console.Write("FILE_DATA: (WILL DELETE ORIGINAL CONTENT!) ");
var write = Console.ReadLine();
var hello_file = Sys.FileSystem.VFS.VFSManager.GetFile(@"0:\" + tinput);
var hello_file_stream = hello_file.GetFileStream();
if (hello_file_stream.CanWrite)
{
byte[] text_to_write = Encoding.ASCII.GetBytes(write);
hello_file_stream.Write(text_to_write, 0, text_to_write.Length);
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
else if (input == "TEXT -N")
{
Console.Write("ENTER THE FILENAME: ");
var ninput = Console.ReadLine();
try
{
Sys.FileSystem.VFS.VFSManager.CreateFile(@"0:\" + ninput);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
else if (input == "TEXT -DEL")
{
Console.Write("ENTER THE FILENAME: ");
var delinput = Console.ReadLine();
try
{
Sys.FileSystem.VFS.VFSManager.DeleteFile(@"0:\" + delinput);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
else if (input == "TEXT -NDIR")
{
Console.Write("ENTER THE DIRNAME: ");
var ndirinput = Console.ReadLine();
try
{
Sys.FileSystem.VFS.VFSManager.CreateDirectory(@"0:\" + ndirinput);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
else if (input == "TEXT")
{
Console.WriteLine("ALL ARGS:");
Console.WriteLine("-EX -- WRITE TO AN EXISTING FILE");
Console.WriteLine("-H -- HELP FOR THIS COMMAND");
Console.WriteLine("-N -- MAKE A NEW FILE");
Console.WriteLine("-DEL -- DELETE A FILE");
Console.WriteLine("-NDIR -- MAKE A NEW DIRECTORY");
}
else
{
Console.WriteLine("BAD COMMAND ENTERED!");
}
}
}
}
I got the same problem
The phisical machine needs to have a pre-formatted FAT32 disk with IDE and has to be less than 120GB (iirc), so yeah good luck searching for that combination