char *Ext2_ReadDir(tVFS_Node *Node, int Pos);
tVFS_Node *Ext2_FindDir(tVFS_Node *Node, char *FileName);
int Ext2_MkNod(tVFS_Node *Node, char *Name, Uint Flags);
-tVFS_Node *Ext2_int_CreateNode(tExt2_Disk *Disk, Uint InodeId, char *Name);
+ int Ext2_Link(tVFS_Node *Parent, tVFS_Node *Node, char *Name);
+// --- Helpers ---
+tVFS_Node *Ext2_int_CreateNode(tExt2_Disk *Disk, Uint InodeId);
// === CODE ===
/**
namebuf[ dirent.name_len ] = '\0'; // Cap off string
// If it matches, create a node and return it
if(strcmp(namebuf, Filename) == 0)
- return Ext2_int_CreateNode( disk, dirent.inode, namebuf );
+ return Ext2_int_CreateNode( disk, dirent.inode );
// Increment pointers
ofs += dirent.rec_len;
size -= dirent.rec_len;
{
#if 0
tVFS_Node *child;
- child = Ext2_int_AllocateNode(Parent, Flags);
+ Uint64 inodeNum;
+ tExt2_Inode inode;
+ inodeNum = Ext2_int_AllocateInode(Parent->ImplPtr, Parent->Inode);
+
+ memset(&inode, 0, sizeof(tExt2_Inode));
+
+ // File type
+ inode.i_mode = 0664;
+ if( Flags & VFS_FFLAG_READONLY )
+ inode.i_mode &= ~0222;
+ if( Flags & VFS_FFLAG_SYMLINK )
+ inode.i_mode |= EXT2_S_IFLNK;
+ else if( Flags & VFS_FFLAG_DIRECTORY )
+ inode.i_mode |= EXT2_S_IFDIR | 0111;
+
+ inode.i_uid = Threads_GetUID();
+ inode.i_gid = Threads_GetGID();
+ inode.i_ctime =
+ inode.i_mtime =
+ inode.i_atime = now() / 1000;
+
+ child = Ext2_int_CreateNode(Parent->ImplPtr, inodeNum);
return Ext2_Link(Parent, child, Name);
#else
- return 0;
+ return 1;
#endif
}
// ---- INTERNAL FUNCTIONS ----
/**
- * \fn vfs_node *Ext2_int_CreateNode(tExt2_Disk *Disk, Uint InodeID, char *Name)
+ * \fn vfs_node *Ext2_int_CreateNode(tExt2_Disk *Disk, Uint InodeID)
* \brief Create a new VFS Node
*/
-tVFS_Node *Ext2_int_CreateNode(tExt2_Disk *Disk, Uint InodeID, char *Name)
+tVFS_Node *Ext2_int_CreateNode(tExt2_Disk *Disk, Uint InodeID)
{
tExt2_Inode inode;
tVFS_Node retNode;
retNode.FindDir = Ext2_FindDir;
retNode.MkNod = Ext2_MkNod;
//retNode.Relink = Ext2_Relink;
+ retNode.Link = Ext2_Link;
retNode.Flags = VFS_FFLAG_DIRECTORY;
break;
// Unknown, Write protect and hide it to be safe
break;
}
- // Check if the file should be hidden
- //if(Name[0] == '.') retNode.Flags |= VFS_FFLAG_HIDDEN;
-
// Set Timestamps
retNode.ATime = inode.i_atime * 1000;
retNode.MTime = inode.i_mtime * 1000;
if(ngrp <= 1) return;\r
VFS_WriteAt(Disk->FD, 1*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock);\r
\r
+ #define INT_MAX (((long long int)1<<(sizeof(int)*8))-1)\r
+ \r
// Powers of 3\r
- for( i = 3; i < ngrp; i *= 3 )\r
+ for( i = 3; i < ngrp && i < INT_MAX; i *= 3 )\r
VFS_WriteAt(Disk->FD, i*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock);\r
\r
// Powers of 5\r
- for( i = 5; i < ngrp; i *= 5 )\r
+ for( i = 5; i < ngrp && i < INT_MAX/5; i *= 5 )\r
VFS_WriteAt(Disk->FD, i*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock);\r
\r
// Powers of 7\r
- for( i = 7; i < ngrp; i *= 7 )\r
+ for( i = 7; i < ngrp && i < INT_MAX/7; i *= 7 )\r
VFS_WriteAt(Disk->FD, i*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock);\r
}\r