Progress
This commit is contained in:
@ -48,6 +48,7 @@ type
|
||||
PPDetectHook = procedure(disk : PStorage_Device);
|
||||
PPCreateDirHook = procedure(volume : PStorage_volume; directory : pchar; dirname : pchar; attributes : uint32; status : puint32);
|
||||
PPReadDirHook = function(volume : PStorage_volume; directory : pchar; status : puint32) : PLinkedListBase; //returns: 0 = success, 1 = dir not exsist, 2 = not directory, 3 = error //returns: 0 = success, 1 = dir not exsist, 2 = not directory, 3 = error
|
||||
PPFormatVolumeHook = procedure(disk : PStorage_device; sectorCount : uint32; start : uint32; config : puint32);
|
||||
|
||||
PPHIOHook_ = procedure;
|
||||
|
||||
@ -60,6 +61,7 @@ type
|
||||
detectCallback : PPDetectHook;
|
||||
createDirCallback : PPCreateDirHook;
|
||||
readDirCallback : PPReadDirHook;
|
||||
formatVolumeCallback : PPFormatVolumeHook;
|
||||
end;
|
||||
|
||||
TStorage_Volume = record
|
||||
@ -96,6 +98,58 @@ var
|
||||
|
||||
implementation
|
||||
|
||||
procedure format_volume_command(params : PParamList);
|
||||
var
|
||||
volume : PStorage_Volume;
|
||||
filesystem : PFilesystem;
|
||||
config : puint32;
|
||||
begin
|
||||
push_trace('VolumeManager.format_volume_command');
|
||||
|
||||
if paramCount(params) < 3 then begin
|
||||
console.writestringlnWND('Invalid arguments', getTerminalHWND());
|
||||
end;
|
||||
push_trace('VolumeManager.format_volume_command.1');
|
||||
|
||||
volume := PStorage_volume(LL_get(storageVolumes, stringToInt(getParam(1, params))));
|
||||
filesystem := PFilesystem(LL_get(filesystems, stringToInt(getParam(2, params))));
|
||||
push_trace('VolumeManager.format_volume_command.2');
|
||||
|
||||
config := PuInt32(kalloc(sizeof(uInt32)));
|
||||
config^ := 4;
|
||||
push_trace('VolumeManager.format_volume_command.3');
|
||||
|
||||
//TODO check things exsist
|
||||
|
||||
console.writestringlnWND('Staring volume formatting...', getTerminalHWND());
|
||||
filesystem^.formatVolumeCallback(volume^.device, volume^.sectorSize, volume^.sectorStart, config);
|
||||
console.writestringlnWND('Volume format finished.', getTerminalHWND());
|
||||
end;
|
||||
|
||||
procedure list_filesystems_command();
|
||||
var
|
||||
i : uint32;
|
||||
filesystem : PFilesystem;
|
||||
begin
|
||||
push_trace('VolumeManager.list_filesystems_command');
|
||||
|
||||
if LL_Size(filesystems) < 1 then begin
|
||||
console.writestringlnWnd('ERROR: no filesystems found!', getTerminalHWND());
|
||||
exit;
|
||||
end;
|
||||
|
||||
console.writestringlnWnd('Filesystems: ', getTerminalHWND());
|
||||
|
||||
for i:=0 to LL_Size(filesystems) - 1 do begin
|
||||
filesystem := PFilesystem(LL_Get(filesystems, i));
|
||||
|
||||
console.writestringWnd(' ', getTerminalHWND());
|
||||
console.writestringWnd(filesystem^.sName, getTerminalHWND());
|
||||
console.writestringWnd(' - ', getTerminalHWND());
|
||||
console.writehexlnWND(filesystem^.system_id, getTerminalHWND());
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure list_volume_command();
|
||||
var
|
||||
i : uint32;
|
||||
@ -116,9 +170,15 @@ begin
|
||||
console.writestringWnd(' ', getTerminalHWND());
|
||||
console.writeintWnd(i, getTerminalHWND());
|
||||
console.writestringWnd(' - Capacity: ', getTerminalHWND());
|
||||
console.writeintWnd(uint32(volume^.sectorSize * volume^.sectorCount DIV 1024 DIV 1024), getTerminalHWND());
|
||||
console.writestringWnd('MB System: ', getTerminalHWND());
|
||||
console.writestringlnWnd(volume^.filesystem^.sName, getTerminalHWND());
|
||||
console.writeintWnd(uint32((volume^.sectorSize * volume^.sectorCount) DIV 1024 DIV 1024), getTerminalHWND());
|
||||
console.writestringWnd('MB, Filesystem: ', getTerminalHWND());
|
||||
|
||||
if volume^.filesystem <> nil then begin
|
||||
console.writestringlnWnd(volume^.filesystem^.sName, getTerminalHWND());
|
||||
end else begin
|
||||
console.writestringlnWnd('None', getTerminalHWND());
|
||||
end;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -143,6 +203,16 @@ begin
|
||||
list_volume_command();
|
||||
exit;
|
||||
end;
|
||||
|
||||
if( stringEquals(subcmd, 'lsfs') ) then begin
|
||||
list_filesystems_command();
|
||||
exit;
|
||||
end;
|
||||
|
||||
if( stringEquals(subcmd, 'format') ) then begin
|
||||
format_volume_command(params);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Initialise volume manager }
|
||||
@ -189,8 +259,9 @@ begin
|
||||
storageVolume.device := drive;
|
||||
storageVolume.sectorStart := bootrecord^.partition_0.LBA_start;
|
||||
storageVolume.sectorCount := bootrecord^.partition_0.sector_count;
|
||||
storageVolume.sectorSize := drive^.sectorSize;
|
||||
storageVolume.freeSectors := 0; //TODO impliment
|
||||
push_trace('VolumeManager.init2');
|
||||
storageVolume.filesystem := nil;
|
||||
|
||||
if LL_Size(filesystems) < 1 then begin
|
||||
console.writestringln('Failed to initalise storage system, no filesystems found, stopping!');
|
||||
@ -218,4 +289,48 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
procedure create_volume(disk : PStorage_device; filesystem : PChar; sectorStart : uint32; sectorCount : uint32);
|
||||
var
|
||||
volume : PStorage_Volume;
|
||||
elm : void;
|
||||
begin
|
||||
|
||||
volume := PStorage_Volume(kalloc(SizeOf(TStorage_Volume)));
|
||||
volume^.device := disk;
|
||||
volume^.sectorStart := sectorStart;
|
||||
volume^.sectorCount := sectorCount;
|
||||
volume^.sectorSize := disk^.sectorSize;
|
||||
volume^.freeSectors := 0; //TODO impliment
|
||||
|
||||
//find filesystem
|
||||
for i:=0 to LL_Size(filesystems) - 1 do begin
|
||||
if stringEquals(filesystem, PFilesystem(LL_Get(filesystems, i))^.sName) then begin
|
||||
volume^.filesystem := PFilesystem(LL_Get(filesystems, i));
|
||||
end;
|
||||
end;
|
||||
|
||||
//format volume
|
||||
volume^.filesystem^.formatVolumeCallback(disk, sectorStart, sectorCount, 0);
|
||||
|
||||
//add volume to list
|
||||
elm := LL_Add(storageVolumes);
|
||||
memcpy(uint32(volume), uint32(elm), SizeOf(TStorage_Volume));
|
||||
|
||||
//add volume to device
|
||||
elm := LL_Add(disk^.volumes);
|
||||
memcpy(uint32(volume), uint32(elm), SizeOf(TStorage_Volume));
|
||||
|
||||
end;
|
||||
|
||||
procedure register_volume(device : PStorage_Device; volume : PStorage_Volume);
|
||||
var
|
||||
elm : void;
|
||||
begin
|
||||
push_trace('storagemanagement.register_volume');
|
||||
elm := LL_Add(device^.volumes);
|
||||
PStorage_volume(elm)^:= volume^;
|
||||
|
||||
if rootVolume = PStorage_Volume(0) then rootVolume:= volume;
|
||||
end;
|
||||
|
||||
end.
|
Reference in New Issue
Block a user