diff --git a/UBIXFS.PAS b/UBIXFS.PAS index 63cf616..d83b21f 100755 --- a/UBIXFS.PAS +++ b/UBIXFS.PAS @@ -242,6 +242,7 @@ smallData : TSmallDataNode; function addAttr(attribute:PChar; attrType:treeTypes; buffer:pointer; count:uInt32):PSmallDataNode; function delAttr(attribute:PChar):boolean; + function findAttr(attribute:PChar):PSmallDataNode; end; // TUbixfsInode PCacheNode = ^TCacheNode; @@ -467,7 +468,7 @@ move(buffer^, dataPtr^, count); end; // with result := smallDataNode; -end; // TUbixfsInode.addAttri +end; // TUbixfsInode.addAttr function TUbixfsInode.delAttr; var @@ -478,6 +479,25 @@ end; // TUbixfsInode.delAttr +function TUbixfsInode.findAttr; +var + smallDataNode:PSmallDataNode; + found:boolean; +begin + result := NIL; // failure by default + if (attribute = NIL) then exit; + smallDataNode := @smallData; + found := FALSE; + while not found and not smallDataNode^.isEmpty() do + with smallDataNode^ do + begin + if (strcomp(attribute, name) = 0) then + found := TRUE + else + smallDataNode := next(); + end; // while/with + if found then result := smallDataNode; +end; // TUbixfsInode.findAttr // TCacheNode methods constructor TCacheNode.init; begin @@ -2767,8 +2787,11 @@ writeln('creating new file: ', fileNamePtr); writeln('allocating new inode'); inode := allocInode(dirIAddr); // alloc a new inode (pass in the parent iaddr) - move(fileNamePtr^, inode^.name, strlen(filenamePtr)); 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; assert(saveBlock(inode^.inodeNum, inode)); // save the new inode u.iAddr := inode^.inodeNum; // copy the inode addr to a uPtr @@ -3161,6 +3184,7 @@ 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 @@ -3205,7 +3229,9 @@ assert(inode <> NIL); 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