commiting before rebase
This commit is contained in:
parent
6476a774dc
commit
28caca3bcc
@ -79,8 +79,71 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
{ Disk subcommand for formatting drives }
|
||||
procedure format_command(params : PParamList);
|
||||
var
|
||||
driveIndex : uint16;
|
||||
drive : PStorage_Device;
|
||||
|
||||
filesystemString : pchar;
|
||||
spc : puint32;
|
||||
|
||||
sectorCount : uint32;
|
||||
volumeId : uint8;
|
||||
|
||||
mb : PMaster_Boot_Record;
|
||||
i : uint32 = 0;
|
||||
|
||||
begin
|
||||
|
||||
//format <DRIVE_ID> <FILESYSTEM> <size>
|
||||
|
||||
spc:= puint32(kalloc(4));
|
||||
spc^:= 1;
|
||||
|
||||
//get drive from index/id
|
||||
driveIndex:= stringToInt( getParam(1, params) );
|
||||
drive:= PStorage_Device(LL_Get(storageDevices, driveIndex));
|
||||
|
||||
filesystemString := getParam(2, params);
|
||||
sectorCount := stringToInt( getParam(4, params) );
|
||||
|
||||
// if sector count is 0, use full drive
|
||||
if sectorCount = 0 then begin
|
||||
sectorCount := drive^.maxSectorCount - 10;
|
||||
end;
|
||||
|
||||
//create MBR if none, and partition table
|
||||
mb := PMaster_Boot_Record(kalloc(sizeof(TMaster_Boot_Record)));
|
||||
drive^.readCallback(drive, 0, 1, PuInt32(mb));
|
||||
|
||||
//check if MBR exists
|
||||
if not mb^.boot_sector = $55AA then begin
|
||||
|
||||
//create MBR
|
||||
mb^.signature := $A570 + drive^.id;
|
||||
mb^.boot_sector := $55AA;
|
||||
|
||||
//create partition table
|
||||
mbr.setup_partition(@mb^.partition[0], 2, sectorCount);
|
||||
|
||||
//write MBR
|
||||
drive^.writeCallback(drive, 0, 1, puint32(mb));
|
||||
|
||||
end;
|
||||
|
||||
kfree(puint32(mb));
|
||||
|
||||
//setup volume
|
||||
volumemanager.create_volume(drive, filesystemString, 2, sectorCount);
|
||||
|
||||
writestringWnd('Drive ', getTerminalHWND);
|
||||
writeintWnd(driveIndex, getTerminalHWND);
|
||||
writestringlnWnd(' formatted.', getTerminalHWND);
|
||||
|
||||
end;
|
||||
|
||||
{ initalise a drive with a MBR - TODO needs to be expanded for partitioning }
|
||||
//this is now deprecated functionality moved to storagemanagment
|
||||
procedure init_drive_command(driveIndex : uint32);
|
||||
var
|
||||
bootrecord : PMaster_Boot_Record;
|
||||
@ -118,7 +181,7 @@ begin
|
||||
console.writestringlnWnd('Please provide valid arguments.', getTerminalHWND());
|
||||
console.writestringlnWnd(' ls - for listing all drives', getTerminalHWND());
|
||||
console.writestringlnWnd(' info [drive] - display formation for specified drive', getTerminalHWND());
|
||||
console.writestringlnWnd(' init [drive] - DEPRECATED destructive, formats a drive with a blank partition', getTerminalHWND());
|
||||
console.writestringlnWnd(' init [drive] - destructive, formats a drive with a blank partition', getTerminalHWND());
|
||||
exit;
|
||||
end;
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
{
|
||||
Driver->Storage->StorageManagment Storage Managment System
|
||||
|
||||
DEPRECATED unit
|
||||
|
||||
@author(Aaron Hance ah@aaronhance.me)
|
||||
}
|
||||
unit storagemanagement;
|
||||
@ -178,9 +180,6 @@ begin
|
||||
//setup volume
|
||||
volumemanager.create_volume(drive, filesystemString, 2, sectorCount);
|
||||
|
||||
//todo change b4 adding in aniother filesytem
|
||||
// PFilesystem(LL_Get(filesystems, 0))^.createCallback(drive, drive^.maxSectorCount-1, 1, spc);
|
||||
|
||||
writestringWnd('Drive ', getTerminalHWND);
|
||||
writeintWnd(driveIndex, getTerminalHWND);
|
||||
writestringlnWnd(' formatted.', getTerminalHWND);
|
||||
|
Loading…
x
Reference in New Issue
Block a user