我是C#的新手,目前正在使用COSMOS为我的操作系统类创建一个简单的FileSystem。目前,我试图实现一个“重新格式化”功能,当“控制台重新格式化”一词输入到控制台中时,操作系统(通过QEMU模拟)对磁盘进行分区。目前,这是我的代码:Cosmos自定义操作系统,addmapping?
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 < 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.
}
}
}
}
最重要的是该位:
else if (input == "reformat")
{
try
{
Partition part = null;
for (int j = 0; j < 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.
}
}
这类似于什么位置为:http://cosmos-tutorials.webs.com/atafat.html
然而,当我运行它,我得到这个错误:
我相信牛逼他是因为我缺少这条线:
Cosmos.System.Filesystem.FileSystem.AddMapping("C", FATFS);
FATFileList = FATFS.GetRoot();
位于上面的链接。有没有其他方法可以映射?或者我完全错过了什么? COSMOS的文档并没有多少意义,源代码对于像我这样的初学者来说,确实令人困惑,因为它对于函数的工作方式或者它们的功能没有任何评论。我使用的是旧版本的COSMOS(Milestone 4),因为它是唯一适用于Visual Studio C#2008的版本。较新的版本只能在Visual Studio C#2010中运行。
这是不对的。你说VMWare和你在QEMU中模拟它: - |。 –
你对对不起 – Erasmus