+ return 1;
+}
+
+/**
+ * \brief Links an existing node to a new name
+ * \param Parent Parent (directory) node
+ * \param Node Node to link
+ * \param Name New name for the node
+ * \return Boolean Failure - See ::tVFS_Node.Link for info
+ */
+int Ext2_Link(tVFS_Node *Node, tVFS_Node *Child, const char *Name)
+{
+ #if 0
+ tExt2_Disk *disk = Node->ImplPtr;
+ tExt2_Inode inode;
+ tExt2_DirEnt dirent;
+ tExt2_DirEnt newEntry;
+ Uint64 Base; // Block's Base Address
+ int block = 0, ofs = 0;
+ Uint size;
+ void *blockData;
+ int bestMatch = -1, bestSize, bestBlock, bestOfs;
+ int nEntries;
+
+ blockData = malloc(disk->BlockSize);
+
+ // Read child inode (get's the file type)
+ Ext2_int_ReadInode(disk, Child->Inode, &inode);
+
+ // Create a stub entry
+ newEntry.inode = Child->Inode;
+ newEntry.name_len = strlen(Name);
+ newEntry.rec_len = (newEntry.name_len+3+8)&~3;
+ newEntry.type = inode.i_mode >> 12;
+ memcpy(newEntry.name, Name, newEntry.name_len);
+
+ // Read directory's inode
+ Ext2_int_ReadInode(disk, Node->Inode, &inode);
+ size = inode.i_size;
+
+ // Get a lock on the inode
+ Ext2_int_LockInode(disk, Node->Inode);
+
+ // Get First Block
+ // - Do this ourselves as it is a simple operation
+ base = inode.i_block[0] * disk->BlockSize;
+ VFS_ReadAt( disk->FD, base, disk->BlockSize, blockData );
+ block = 0;
+ // Find File
+ while(size > 0)
+ {
+ dirent = blockData + ofs;
+ // Sanity Check the entry
+ if(ofs + dirent->rec_len > disk->BlockSize) {
+ Log_Warning("EXT2",
+ "Directory entry %i of inode 0x%x extends over a block boundary",
+ nEntries, (Uint)Node->Inode);
+ }
+ else {
+
+ // Free entry
+ if(dirent->type == 0) {
+ if( dirent->rec_len >= newEntry.rec_len
+ && (bestMatch == -1 || bestSize > dirent->rec_len) )
+ {
+ bestMatch = nEntries;
+ bestSize = dirent->rec_len;
+ bestBlock = block;
+ bestOfs = ofs;
+ }
+ }
+ // Non free - check name to avoid duplicates
+ else {
+ if(strncmp(Name, dirent->name, dirent->name_len) == 0) {
+ Ext2_int_UnlockInode(disk, Node->Inode);
+ return 1; // ERR_???
+ }
+ }
+ }
+
+ // Increment the pointer
+ nEntries ++;
+ ofs += dirent->rec_len;
+ if( ofs >= disk->BlockSize ) {
+ // Read the next block if needed
+ BLOCK_DIR_OFS(Node->Data, block) = nEntries;
+ block ++;
+ ofs = 0;
+ base = Ext2_int_GetBlockAddr(disk, inode.i_block, block);
+ VFS_ReadAt( disk->FD, base, disk->BlockSize, blockData );
+ }
+ }
+
+ // Check if a free slot was found
+ if( bestMatch >= 0 ) {
+ // Read-Modify-Write
+ bestBlock = Ext2_int_GetBlockAddr(disk, inode.i_block, bestBlock);
+ if( block > 0 )
+ bestMatch = BLOCK_DIR_OFS(Node->Data, bestBlock);
+ VFS_ReadAt( disk->FD, base, disk->BlockSize, blockData );
+ dirent = blockData + bestOfs;
+ memcpy(dirent, newEntry, newEntry.rec_len);
+ VFS_WriteAt( disk->FD, base, disk->BlockSize, blockData );
+ }
+ else {
+ // Allocate block, Write
+ block = Ext2_int_AllocateBlock(Disk, block);
+ Log_Warning("EXT2", "");
+ }
+
+ Ext2_int_UnlockInode(disk, Node->Inode);