示例#1
0
        /* Open
         * Initializes a disk with the existing disk-scheme and gathers
         * information about the on-board filesystems */
        public bool Open(CDisk Disk)
        {
            // Store disk
            m_pDisk = Disk;

            return(false);
        }
示例#2
0
        /* Create
         * Initializes a disk with the disk-scheme and formats the disk
         * for usage with <AddPartition>, this action wipes the disk */
        public bool Create(CDisk Disk, Boolean SinglePartition = true)
        {
            // Store variables
            m_bSinglePartition = SinglePartition;
            m_pDisk            = Disk;

            // Open disn
            m_pDisk.Open();

            // Prepare boot-sector if it's a multi-partition layout
            if (!m_bSinglePartition)
            {
                // no support
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#3
0
        /* DiskUtility Entry
         * Handles all command line switches and initializes the utility */
        static int Main(string[] args)
        {
            // Variables
            IDiskScheme Scheme;
            String      Target     = "live";
            String      SchemeType = "mbr";
            bool        Automatic  = false;

            // Debug print header
            Console.WriteLine("MFS Utility Software");
            Console.WriteLine("Software Capabilities include formatting, read, write to/from MFS.\n");

            // Parse arguments
            if (args != null && args.Length > 0)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    switch (args[i].ToLower())
                    {
                    case "-auto":
                    case "-a": {
                        Automatic = true;
                    } break;

                    case "-target": {
                        Target = args[i + 1];
                        i++;
                    } break;

                    case "-scheme": {
                        SchemeType = args[i + 1];
                        i++;
                    } break;
                    }
                }
            }

            // Retrieve a list of physical drives
            Hashtable Drives = new Hashtable();

            if (Target == "live")
            {
                Console.WriteLine("Available Drives:");
                WqlObjectQuery           q   = new WqlObjectQuery("SELECT * FROM Win32_DiskDrive");
                ManagementObjectSearcher res = new ManagementObjectSearcher(q);
                int Itr = 0;
                foreach (ManagementObject o in res.Get())
                {
                    // Never take main-drive into account
                    if (o["DeviceID"].ToString().Contains("PHYSICALDRIVE0"))
                    {
                        continue;
                    }

                    // Debug
                    Console.WriteLine(Itr.ToString() + ". " + o["Caption"] + " (DeviceID = " + o["DeviceID"] + ")");

                    var bps = o.GetPropertyValue("BytesPerSector");
                    var spt = o["SectorsPerTrack"];
                    var tpc = o["TracksPerCylinder"];
                    var ts  = o["TotalSectors"];

                    // Create and store the disk
                    Drives.Add(Itr, new CDisk((String)o["DeviceID"], (UInt32)o["BytesPerSector"],
                                              (UInt32)o["SectorsPerTrack"], (UInt32)o["TracksPerCylinder"], (UInt64)o["TotalSectors"]));
                    Itr++;
                }
            }

            // Should we automate the process?
            if (Automatic)
            {
                // Variables
                IFileSystem FileSystem;
                CDisk       Disk = null;

                // Which kind of target?
                if (Target.ToLower() == "live" && Drives.Count > 0)
                {
                    Disk = (CDisk)Drives[0];
                }
                else if (Target.ToLower() == "vmdk")
                {
                    Disk = new CDisk("VMDK", 512, 63, 255, 2097152);
                }
                else if (Target.ToLower() == "img")
                {
                    Disk = new CDisk("IMG", 512, 63, 255, 2097152);
                }
                else
                {
                    Console.WriteLine("Invalid option for -target");
                    return(-1);
                }

                // Which kind of disk-scheme?
                if (SchemeType.ToLower() == "mbr")
                {
                    Scheme = new SchemeMBR();
                }
                else if (SchemeType.ToLower() == "gpt")
                {
                    Scheme = null;
                }
                else
                {
                    Console.WriteLine("Invalid option for -scheme");
                    return(-1);
                }

                // Partition setup?
                FileSystem = new CMollenOSFileSystem("MollenOS");

                // Setup disk partition layout
                Scheme.Create(Disk);

                // Create the requested partition setup
                Scheme.AddPartition(FileSystem, Scheme.GetFreeSectorCount());

                // Install mollenos on the disk
                InstallMollenOS(FileSystem);

                // Finish
                Scheme.Finalize();
            }

            // Launch CLI if none-automatic
            if (!Automatic)
            {
                LaunchCLI(Drives);
            }

            // Return
            return(0);
        }
示例#4
0
 /* Constructor
  * Initializes local members */
 public SchemeMBR()
 {
     m_iSectorsAllocated = 0;
     m_pDisk             = null;
 }