MCPcopy Create free account
hub / github.com/bobranten/Ext4Fsd / Ext2CreateInode

Function Ext2CreateInode

Ext4Fsd/create.c:2044–2136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2042}
2043
2044NTSTATUS
2045Ext2CreateInode(
2046 PEXT2_IRP_CONTEXT IrpContext,
2047 PEXT2_VCB Vcb,
2048 PEXT2_FCB Parent,
2049 ULONG Type,
2050 ULONG FileAttr,
2051 PUNICODE_STRING FileName)
2052{
2053 NTSTATUS Status;
2054 ULONG iGrp;
2055 ULONG iNo;
2056 struct inode Inode = { 0 };
2057 struct dentry *Dentry = NULL;
2058 struct ext3_super_block *es = EXT3_SB(&Vcb->sb)->s_es;
2059
2060 LARGE_INTEGER SysTime;
2061
2062 iGrp = (Parent->Inode->i_ino - 1) / BLOCKS_PER_GROUP;
2063
2064 DEBUG(DL_INF, ("Ext2CreateInode: %S in %S(Inode=%xh)\n",
2065 FileName->Buffer,
2066 Parent->Mcb->ShortName.Buffer,
2067 Parent->Inode->i_ino));
2068
2069 Status = Ext2NewInode(IrpContext, Vcb, iGrp, Type, &iNo);
2070 if (!NT_SUCCESS(Status)) {
2071 goto errorout;
2072 }
2073
2074 KeQuerySystemTime(&SysTime);
2075 Ext2ClearInode(IrpContext, Vcb, iNo);
2076 Inode.i_sb = &Vcb->sb;
2077 Inode.i_ino = iNo;
2078 Inode.i_ctime = Inode.i_mtime =
2079 Inode.i_atime = Ext2LinuxTime(SysTime);
2080 if (IsFlagOn(Vcb->Flags, VCB_USER_IDS)) {
2081 Inode.i_uid = Vcb->uid;
2082 Inode.i_gid = Vcb->gid;
2083 } else {
2084 Inode.i_uid = Parent->Mcb->Inode.i_uid;
2085 Inode.i_gid = Parent->Mcb->Inode.i_gid;
2086 }
2087 Inode.i_generation = Parent->Inode->i_generation;
2088 Inode.i_mode = S_IPERMISSION_MASK &
2089 Parent->Inode->i_mode;
2090 if (Type == EXT2_FT_DIR) {
2091 Inode.i_mode |= S_IFDIR;
2092 } else if (Type == EXT2_FT_REG_FILE) {
2093 Inode.i_mode &= S_IFATTR;
2094 Inode.i_mode |= S_IFREG;
2095 } else {
2096 DbgBreak();
2097 }
2098 if (le16_to_cpu(es->s_want_extra_isize))
2099 Inode.i_extra_isize = le16_to_cpu(es->s_want_extra_isize);
2100
2101 /* Force using extent */

Callers 1

Ext2CreateFileFunction · 0.85

Calls 8

Ext2NewInodeFunction · 0.85
Ext2ClearInodeFunction · 0.85
Ext2LinuxTimeFunction · 0.85
ext4_ext_tree_initFunction · 0.85
Ext2SaveInodeFunction · 0.85
Ext2AddEntryFunction · 0.85
Ext2FreeInodeFunction · 0.85
Ext2FreeEntryFunction · 0.85

Tested by

no test coverage detected