git-svn-id: https://spexeah.com:8443/svn/Asuro@549 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
dc4a927a53
commit
d662659273
@ -8,6 +8,11 @@
|
|||||||
* Contributors:
|
* Contributors:
|
||||||
************************************************ }
|
************************************************ }
|
||||||
|
|
||||||
|
{
|
||||||
|
Todo in the future, optimise by prvoiding batch read/write commands
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
unit FAT32;
|
unit FAT32;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -270,25 +275,32 @@ begin
|
|||||||
pop_trace();
|
pop_trace();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function writeDirectory(volume : PStorage_volume; directory : pchar) : uint8;
|
function writeDirectory(volume : PStorage_volume; directory : pchar) : uint8; // need to handle parent table cluster overflow, need to take attributes
|
||||||
var
|
var
|
||||||
dirList : PLinkedListBase;
|
dirAddr : PLinkedListBase;
|
||||||
str : pchar;
|
dirList : PLinkedListBase;
|
||||||
str2 : pchar;
|
str : pchar;
|
||||||
i : uint32 = 0;
|
str2 : pchar;
|
||||||
ii : uint32;
|
i : uint32 = 0;
|
||||||
buffer : puint32;
|
ii : uint32;
|
||||||
foundCluster : boolean = false;
|
buffer : puint32;
|
||||||
emptyCluster : uint32;
|
foundCluster : boolean = false;
|
||||||
targetDirectory : TDirectory;
|
emptyCluster : uint32;
|
||||||
|
prevDirCluster : uint32;
|
||||||
|
targetDirectory : PDirectory;
|
||||||
|
bootRecord : TBootRecord;
|
||||||
|
device : PStorage_Device;
|
||||||
begin
|
begin
|
||||||
dirList:= stringToLL(directory, '/');
|
dirAddr := stringToLL(directory, '/');
|
||||||
buffer:= puint32(kalloc(sizeof(volume^.sectorSize)));
|
//dirList := LL_New(sizeof(TDirectory));
|
||||||
|
bootRecord := readBootRecord(volume);
|
||||||
|
device := volume^.device;
|
||||||
|
buffer := puint32(kalloc(sizeof(volume^.sectorSize)));
|
||||||
|
|
||||||
//find un allocated cluster
|
//find un allocated cluster
|
||||||
while not foundCluster do begin
|
while not foundCluster do begin
|
||||||
volume^.device^.readcallback(volume^.device, volume^.sectorStart + 2 + (i * 32 div volume^.sectorSize), 1, buffer);
|
volume^.device^.readcallback(volume^.device, volume^.sectorStart + 2 + (i * 32 div volume^.sectorSize), 1, buffer);
|
||||||
for ii:=0 to 15 do begin
|
for ii:=0 to 127 do begin
|
||||||
if puint32(buffer + ii)^ = 0 then begin //found unallocated cluster
|
if puint32(buffer + ii)^ = 0 then begin //found unallocated cluster
|
||||||
emptyCluster:= (i * 16) + ii;
|
emptyCluster:= (i * 16) + ii;
|
||||||
foundCluster:= true;
|
foundCluster:= true;
|
||||||
@ -302,15 +314,24 @@ begin
|
|||||||
writeFat(volume, emptyCluster, $FFFFFFF8);
|
writeFat(volume, emptyCluster, $FFFFFFF8);
|
||||||
|
|
||||||
//find directory table
|
//find directory table
|
||||||
for i:=0 to LL_size(dirList) - 2 do begin
|
for i:=0 to LL_size(dirAddr) - 2 do begin //construct address for parent directory
|
||||||
str2:= pchar( puint32(LL_Get(dirList, i))^ );
|
str2:= pchar( puint32(LL_Get(dirAddr, i))^ );
|
||||||
str:= stringConcat(str, str2);
|
str:= stringConcat(str, str2);
|
||||||
end;
|
end;
|
||||||
|
writeDirectory:= readDirectory(volume, str, dirList); //hope str is correct, maybe need /
|
||||||
|
targetDirectory:= PDirectory(LL_Get(dirList, 0));
|
||||||
|
prevDirCluster:= targetDirectory^.clusterLow or (targetDirectory^.clusterHigh shl 16);
|
||||||
|
|
||||||
writeDirectory:= readDirectory(volume, str, dirList);
|
buffer:= puint32(kalloc(volume^.sectorSize)); //nope, need write one sector, the right sector
|
||||||
targetDirectory:= PDirectory(LL_Get(dirList, 0))^;
|
//size of dirlist (byte size of cluster) / 32 = max no of directories per cluster
|
||||||
|
device^.readcallback(device, volume^.sectorStart + 1 + bootrecord.fatSize + (bootRecord.spc * prevDirCluster), 1, buffer); //only writes first cluster
|
||||||
|
// volume^.sectorStart + 1 + fatSectorSize + (bootRecord.spc * cc)
|
||||||
|
|
||||||
//insert table entree
|
//insert table entree
|
||||||
|
//construct buffer from dirAddr
|
||||||
|
//add new directory
|
||||||
|
//write to disk
|
||||||
|
|
||||||
//write new directory table at emptyCluster
|
//write new directory table at emptyCluster
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -458,7 +479,7 @@ begin
|
|||||||
storagemanagement.register_volume(disk, volume);
|
storagemanagement.register_volume(disk, volume);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
readDirectory(volume, 'hello/word', nil);
|
//readDirectory(volume, 'hello/word', nil);
|
||||||
pop_trace();
|
pop_trace();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ begin
|
|||||||
tracer.pop_trace;
|
tracer.pop_trace;
|
||||||
|
|
||||||
{ Filsystems }
|
{ Filsystems }
|
||||||
//fat32.init();
|
fat32.init();
|
||||||
|
|
||||||
{ Device Drivers }
|
{ Device Drivers }
|
||||||
tracer.push_trace('kmain.DEVDRV');
|
tracer.push_trace('kmain.DEVDRV');
|
||||||
@ -249,7 +249,7 @@ begin
|
|||||||
mouse.init();
|
mouse.init();
|
||||||
testdriver.init();
|
testdriver.init();
|
||||||
E1000.init();
|
E1000.init();
|
||||||
//IDE.init();
|
IDE.init();
|
||||||
console.outputln('KERNEL', 'DEVICE DRIVERS: INIT END.');
|
console.outputln('KERNEL', 'DEVICE DRIVERS: INIT END.');
|
||||||
tracer.pop_trace;
|
tracer.pop_trace;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user