diff --git a/UBIXFS.PAS b/UBIXFS.PAS index bd4df0d..611cb93 100755 --- a/UBIXFS.PAS +++ b/UBIXFS.PAS @@ -238,7 +238,6 @@ inodeSize : uInt32; data : uPtr; {this was the etc field in bfs} blocks : TDataStream; - name : array[0..255] of char; smallData : TSmallDataNode; function addAttr(attribute:PChar; attrType:treeTypes; buffer:pointer; count:uInt32):PSmallDataNode; function delAttr(attribute:PChar):boolean; @@ -2789,7 +2788,6 @@ inode := allocInode(dirIAddr); // alloc a new inode (pass in the parent iaddr) assert(inode <> NIL); // make sure it isn't nil - move(fileNamePtr^, inode^.name, strlen(filenamePtr)); inode^.addAttr('name', BT_PCHAR, fileNamePtr, strlen(fileNamePtr)+1); if (inode = NIL) then exit; @@ -2955,7 +2953,7 @@ setIAddr(attributes, 0, 0, 0); inodeSize := sb^.inodeSize; - strcopy(name, 'Block Allocation Tree'); +// strcopy(name, 'Block Allocation Tree'); addAttr('name', BT_PCHAR, @BATName, strlen(@BATName)+1); end; // with sb^.BAT := inode^.inodeNum; @@ -3185,7 +3183,6 @@ inode^.mode := S_IFDIR; inode^.flags := INODE_LOGGED; superBlock^.rootDir := inode^.inodeNum; // assign the root dir - strcopy(inode^.name, '/'); // XXX Needs to be an attribute inode^.addAttr('name', BT_PCHAR, path, len+1); // len+1 should equal 2 assert(saveBlock(superBlock^.rootDir, inode)); // save the inode u.iAddr := inode^.inodeNum; // copy the inode addr to a uPtr @@ -3232,13 +3229,12 @@ if (inode = NIL) then exit; // set some appropiate error code (not sure what) inode^.mode := S_IFDIR; inode^.flags := INODE_LOGGED; - strcopy(inode^.name, dirNamePtr); inode^.addAttr('name', BT_PCHAR, dirNamePtr, strlen(dirNamePtr)+1); assert(saveBlock(inode^.inodeNum, inode)); u.iAddr := inode^.inodeNum; // open the parent dir new(dirTree, open(iAddrToStr(dirIAddr), new(PUbixBTreeVFS, init(@self)))); - writeln('dirTree^.Insert(@inode^.name, u) returned ', dirTree^.Insert(@inode^.name, u)); + writeln('dirTree^.Insert(dirNamePtr, u) returned ', dirTree^.Insert(dirNamePtr, u)); dispose(dirTree, done); // now open the subdir and insert '.' and '..' new(dirTree, init(iAddrToStr(inode^.inodeNum), 1024, BT_PCHAR, new(PUbixBTreeVFS, init(@self)))); @@ -3304,12 +3300,12 @@ inode:PUbixfsInode; u:uPtr; vnid:PVnid; + smallDataNode:PSmallDataNode; begin // XXX ToDo: // Set appropiate error codes. // If the "file" is actually a directory, bail on that // If bailing out, don't forget to reclaim allocated memory - // replace inode^.name with the actual attribute result := -1; if (fileName = NIL) or (superBlock = NIL) or (vnids = NIL) then exit; @@ -3346,7 +3342,11 @@ writeln('error loading inode in unlink()'); exit; // XXX cannot exit from here either end; - dirTree^.Delete(@inode^.name, u); + // the filename of the file always exists inside the + // small data area of the file. + smallDataNode := inode^.findAttr('name'); + assert(smallDataNode <> NIL); + dirTree^.Delete(smallDataNode^.dataPtr(), u); // We know the file exists.. but does anybody have it open? if vnids^.Find(@inode^.inodeNum, u) then begin @@ -3431,7 +3431,7 @@ dispose(attrTree, done); end; end; -end; // TUbixFS.readAttr +end; // TUbixFS.writeAttr function TUbixFS.writeDataStream; var diff --git a/graphics.pas b/graphics.pas index ec37b08..3a1d461 100755 --- a/graphics.pas +++ b/graphics.pas @@ -472,6 +472,7 @@ savebuf:^ogSurface; imageSaver:^ogImage; dirTree:PbTree; + smallDataNode:PSmallDataNode; begin if (dev = NIL) or (superBlock = NIL) then exit; map := NIL; @@ -535,7 +536,9 @@ shrinkFile(inode); u.iAddr := inode^.inodeNum; new(dirTree, open(IAddrToStr(inode^.parent), new(PUbixBTreeVFS, init(@self)))); - dirTree^.Delete(@inode^.name, u); + smallDataNode := inode^.findAttr('name'); + assert(smallDataNode <> NIL); + dirTree^.Delete(smallDataNode^.dataPtr(), u); dispose(dirTree, done); freeUsedBlocks(inode^.inodeNum); markAll();