Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 1437 of file create.c.
Referenced by Ext2CommonCreate().
{ EXT2_INODE Inode, ParentInode; ULONG NewInodeNo = 0; BOOLEAN FCBAcquired = FALSE; ULONG LogicalBlockSize = 0; try { // 0. Verify if the creation is possible,,, if( Type != EXT2_FT_DIR && Type != EXT2_FT_REG_FILE ) { // // Can create only a directory or a regular file... // return 0; } // 1. Allocate an i-node... NewInodeNo = Ext2AllocInode( PtrIrpContext, PtrVCB, PtrParentFCB->INodeNo ); // NewInodeNo = 12; if( !NewInodeNo ) { return 0; } // 2. Acquire the Parent FCB Exclusively... if( !ExAcquireResourceExclusiveLite(&( PtrParentFCB->NTRequiredFCB.MainResource ), TRUE) ) { Ext2DeallocInode( PtrIrpContext, PtrVCB, NewInodeNo ); try_return( NewInodeNo = 0); } FCBAcquired = TRUE; // 3. Make an entry in the parent Directory... ASSERT( PtrParentFCB->DcbFcb.Dcb.PtrDirFileObject ); Ext2MakeNewDirectoryEntry( PtrIrpContext, PtrParentFCB, PtrParentFCB->DcbFcb.Dcb.PtrDirFileObject, PtrName, Type, NewInodeNo ); // 4. Initialize an inode entry and write it to disk... LogicalBlockSize = EXT2_MIN_BLOCK_SIZE << PtrVCB->LogBlockSize; { // To be deleted Ext2ReadInode( PtrVCB, NewInodeNo, &Inode ); } RtlZeroMemory( &Inode, sizeof( EXT2_INODE ) ); if( Type == EXT2_FT_DIR ) { Inode.i_mode = 0x41ff; // In addition to the usual link, // there will be an additional link in the directory itself - the '.' entry Inode.i_links_count = 2; // Incrementing the link count for the parent as well... Ext2ReadInode( PtrVCB, PtrParentFCB->INodeNo, &ParentInode ); ParentInode.i_links_count++; Ext2WriteInode( PtrIrpContext, PtrVCB, PtrParentFCB->INodeNo, &ParentInode ); } else { Inode.i_mode = 0x81ff; Inode.i_links_count = 1; } { // // Setting the time fields in the inode... // ULONG Time; Time = Ext2GetCurrentTime(); Inode.i_ctime = Time; Inode.i_atime = Time; Inode.i_mtime = Time; Inode.i_dtime = 0; // Deleted time; } Ext2WriteInode( PtrIrpContext, PtrVCB, NewInodeNo, &Inode ); try_exit: NOTHING; } finally { if( FCBAcquired ) { Ext2ReleaseResource( &(PtrParentFCB->NTRequiredFCB.MainResource) ); } } return NewInodeNo ; }