Note that there are some explanatory texts on larger screens.

plurals
  1. POCosmos custom OS, addmapping?
    text
    copied!<p>I am new to C# and is currently using COSMOS to make a simple FileSystem for my OS class. Currently I'm trying to implement a "reformat" function that, when the word "reformat" is typed into the console, the OS (emulated via QEMU), partitions the disk. Currently this is my code:</p> <pre><code> public static void console() { while (true) { Console.WriteLine("Console: "); String input = Console.ReadLine(); if (input == "exit") { Cosmos.Sys.Deboot.ShutDown(); } else if (input == "cpumem") { Console.WriteLine(Cosmos.Kernel.CPU.AmountOfMemory.ToString()); } else if (input == "restart") { Cosmos.Sys.Deboot.Reboot(); } else if (input == "devices") { var devices = Cosmos.Sys.FileSystem.Disk.Devices.ToArray(); } else if (input == "reformat") { try { Partition part = null; for (int j = 0; j &lt; Cosmos.Hardware.BlockDevice.Devices.Count; j++) { if (Cosmos.Hardware.BlockDevice.Devices[j] is Partition) { part = (Partition)Cosmos.Hardware.BlockDevice.Devices[j]; } } var fs = new Cosmos.Sys.FileSystem.FAT32.FAT32(part); uint cluster = 100; fs.Format("newCluster", cluster); } catch { //Do Something warn user. } } } } </code></pre> <p>Most important is this bit:</p> <pre><code> else if (input == "reformat") { try { Partition part = null; for (int j = 0; j &lt; Cosmos.Hardware.BlockDevice.Devices.Count; j++) { if (Cosmos.Hardware.BlockDevice.Devices[j] is Partition) { part = (Partition)Cosmos.Hardware.BlockDevice.Devices[j]; } } var fs = new Cosmos.Sys.FileSystem.FAT32.FAT32(part); uint cluster = 100; fs.Format("newCluster", cluster); } catch { //Do Something warn user. } } </code></pre> <p>Which is analogous to what is located here: <a href="http://cosmos-tutorials.webs.com/atafat.html" rel="nofollow noreferrer">http://cosmos-tutorials.webs.com/atafat.html</a></p> <p>However, when I run it, I get this error:</p> <p><img src="https://i.stack.imgur.com/afk5s.jpg" alt="enter image description here"></p> <p>I believe this is because I lack this line:</p> <pre><code>Cosmos.System.Filesystem.FileSystem.AddMapping("C", FATFS); FATFileList = FATFS.GetRoot(); </code></pre> <p>Located in the link above. Is there any other way to map? Or am I missing something completely? The COSMOS documentation doesn't really tell much, the source code is honestly confusing for a beginner like me as it has no comments whatsoever on how the functions work or what they do. I am using an older version of COSMOS (Milestone 4) as it's the only one that works for Visual Studio C# 2008. Newer versions run only in Visual Studio C# 2010.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload