CosmosOS / Cosmos

Cosmos is an operating system "construction kit". Build your own OS using managed languages such as C#, VB.NET, and more!
https://www.goCosmos.org
BSD 3-Clause "New" or "Revised" License
2.91k stars 549 forks source link

FileSystem is not working on Creating File or Directory #2664

Closed COR-ET closed 9 months ago

COR-ET commented 1 year ago

Area of Cosmos - What area of Cosmos are we dealing with?

FileSystem (and working with System.IO for File and Directory)

Expected Behaviour - What do you think that should happen?

Creating a Directory when using Directory.CreateDirectory(...) , or File.Create , !! ( for now , only showing Directories works fine , and the cd command too for SetCurrentDirectory and GetCurrentDirectory) !!

Actual Behaviour - What unexpectedly happens?

on first time , it wasn't even responding , System is not responding , even tho I have Exception Handler , now it shows (Directory created) , but there is no new directory . !! ( i tried on VHD on VBox , and on real HDD (USB disk FAT32 type added into VBox) , and even on Cosmos FileSystem VMDK ) ) !!

Reproduction - How did you get this error to appear?

as I said , its not an exception , there is no reason given for the error

Version - Were you using the User Kit or Dev Kit? And what User Kit version or Dev Kit commit (Cosmos, IL2CPU, X#)?

ofc Devkit , userkit is outdated i think , IL2CPU must be latest , as same for X#

for more details or info requests , resume contact with me in this thread !

Sorry for my Enjlish ._.

quajak commented 1 year ago

Can you please provide more precise reproduction steps? For example, a example kernel + vmdk file.

The tests in https://github.com/CosmosOS/Cosmos/blob/master/Tests/Kernels/Cosmos.Kernel.Tests.Fat/System.IO/DirectoryTest.cs#L82 work, so there must be some important differences.

COR-ET commented 1 year ago

here is my mkdir code :

 case "mkdir":
                            if (arguments.Length == 1)
                            {
                                var directory = arguments[0];
                                Console.WriteLine("Creating directory {0}", @directory);
                                var xDirectory = Directory.CreateDirectory(@"0:\test2"); 

                                Console.WriteLine("Created !");
                                break;
                            }
                            else
                            {
                                Console.WriteLine("Usage: mkdir <directory>");
                            }
                            break;

and here is my Pre-Load of FileSystem ( some messed stuff :> ) :

try { VFSManager.RegisterVFS(fs); } catch (Exception ex) { ReturnExp(ex); /*Console.WriteLine(" Failed in VFS Register"); */}
                try { FatFileSystemFactory fat = new FatFileSystemFactory(); Sys.FileSystem.VFS.FileSystemManager.Register(fat);  } catch (Exception ex) { ReturnExp(ex); /*Console.WriteLine("Failed in FAT Register"); */}
                try { fs.GetDisks().ForEach(disk => { if (disk.Type == BlockDeviceType.HardDrive) { disk.Mount(); /*disk.MountPartition(0);*/ } }); } catch (Exception ex) { ReturnExp(ex); Console.WriteLine("fs Mount Failed !"); }
                try {
                    foreach (var drive in DriveInfo.GetDrives()) {

                        DriveFormat = drive.DriveFormat;
                        Console.WriteLine("Drive {0} ({1})", drive.Name, drive.VolumeLabel);
                        Console.WriteLine("  File system: {0}", drive.DriveFormat);
                        Console.WriteLine("  Total size : {0} bytes", drive.TotalSize);
                        Console.WriteLine("  Free space : {0} bytes", drive.AvailableFreeSpace);
                        if (DriveFormat.Contains("FAT")) { SupportedDisk = true; } else { SupportedDisk = false; }

                    }
                }
                catch (Exception ex ) { ReturnExp(ex);  }

but here is the OS result :

image

and the file in real is empty , checked in explorer :

image

@quajak

terminal-cs commented 1 year ago

Why are you trying to use the FS factory? That's only meant to make new FS drivers

terminal-cs commented 1 year ago

Your code is way over complicated. You are suposed to register fs, not a new file systme factory. Please actually read documentation before assuming whatever you do will work

COR-ET commented 1 year ago

Check this :

image