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

Function Ext2DeleteFile

Ext4Fsd/fileinfo.c:1905–2085  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1903}
1904
1905NTSTATUS
1906Ext2DeleteFile(
1907 PEXT2_IRP_CONTEXT IrpContext,
1908 PEXT2_VCB Vcb,
1909 PEXT2_FCB Fcb,
1910 PEXT2_MCB Mcb
1911)
1912{
1913 PEXT2_FCB Dcb = NULL;
1914
1915 NTSTATUS Status = STATUS_UNSUCCESSFUL;
1916
1917 BOOLEAN VcbResourceAcquired = FALSE;
1918 BOOLEAN FcbPagingIoAcquired = FALSE;
1919 BOOLEAN FcbResourceAcquired = FALSE;
1920 BOOLEAN DcbResourceAcquired = FALSE;
1921
1922 LARGE_INTEGER Size;
1923 LARGE_INTEGER SysTime;
1924
1925 BOOLEAN bFcbLockAcquired = FALSE;
1926
1927 DEBUG(DL_INF, ( "Ext2DeleteFile: File %wZ (%xh) will be deleted!\n",
1928 &Mcb->FullName, Mcb->Inode.i_ino));
1929
1930 if (IsFlagOn(Mcb->Flags, MCB_FILE_DELETED)) {
1931 return STATUS_SUCCESS;
1932 }
1933
1934 if (!IsMcbSymLink(Mcb) && IsMcbDirectory(Mcb)) {
1935 if (!Ext2IsDirectoryEmpty(IrpContext, Vcb, Mcb)) {
1936 return STATUS_DIRECTORY_NOT_EMPTY;
1937 }
1938 }
1939
1940 __try {
1941
1942 Ext2ReferMcb(Mcb);
1943
1944 ExAcquireResourceExclusiveLite(&Vcb->MainResource, TRUE);
1945 VcbResourceAcquired = TRUE;
1946
1947 ExAcquireResourceExclusiveLite(&Vcb->FcbLock, TRUE);
1948 bFcbLockAcquired = TRUE;
1949
1950 /* Mcb->Parent could be NULL when working with layered file systems */
1951 if (Mcb->Parent) {
1952 Dcb = Mcb->Parent->Fcb;
1953 if (!Dcb)
1954 Dcb = Ext2AllocateFcb(Vcb, Mcb->Parent);
1955 }
1956 if (Dcb)
1957 Ext2ReferXcb(&Dcb->ReferenceCount);
1958
1959 if (bFcbLockAcquired) {
1960 ExReleaseResourceLite(&Vcb->FcbLock);
1961 bFcbLockAcquired = FALSE;
1962 }

Callers 4

Ext2CleanupFunction · 0.85
Ext2SetRenameInfoFunction · 0.85
Ext2SetLinkInfoFunction · 0.85
Ext2CreateFileFunction · 0.85

Calls 11

Ext2IsDirectoryEmptyFunction · 0.85
Ext2AllocateFcbFunction · 0.85
Ext2RemoveEntryFunction · 0.85
Ext2RemoveMcbFunction · 0.85
Ext2TruncateFileFunction · 0.85
Ext2LinuxTimeFunction · 0.85
Ext2SaveInodeFunction · 0.85
Ext2FreeInodeFunction · 0.85
Ext2InodeTypeFunction · 0.85
Ext2ReleaseFcbFunction · 0.85
ext3_free_blocks_countFunction · 0.85

Tested by

no test coverage detected