| 1985 | } |
| 1986 | |
| 1987 | NTSTATUS |
| 1988 | Ext2RemoveEntry ( |
| 1989 | IN PEXT2_IRP_CONTEXT IrpContext, |
| 1990 | IN PEXT2_VCB Vcb, |
| 1991 | IN PEXT2_FCB Dcb, |
| 1992 | IN PEXT2_MCB Mcb |
| 1993 | ) |
| 1994 | { |
| 1995 | struct inode *dir = Dcb->Inode; |
| 1996 | struct buffer_head *bh = NULL; |
| 1997 | struct ext3_dir_entry_2 *de; |
| 1998 | struct inode *inode; |
| 1999 | int rc = -ENOENT; |
| 2000 | NTSTATUS Status = STATUS_UNSUCCESSFUL; |
| 2001 | BOOLEAN MainResourceAcquired = FALSE; |
| 2002 | |
| 2003 | if (!IsDirectory(Dcb)) { |
| 2004 | return STATUS_NOT_A_DIRECTORY; |
| 2005 | } |
| 2006 | |
| 2007 | ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE); |
| 2008 | MainResourceAcquired = TRUE; |
| 2009 | |
| 2010 | __try { |
| 2011 | |
| 2012 | Ext2ReferXcb(&Dcb->ReferenceCount); |
| 2013 | |
| 2014 | bh = ext3_find_entry(IrpContext, Mcb->de, &de); |
| 2015 | if (!bh) |
| 2016 | __leave; |
| 2017 | |
| 2018 | inode = &Mcb->Inode; |
| 2019 | if (le32_to_cpu(de->inode) != inode->i_ino) |
| 2020 | __leave; |
| 2021 | |
| 2022 | if (!inode->i_nlink) { |
| 2023 | ext3_warning (inode->i_sb, "ext3_unlink", |
| 2024 | "Deleting nonexistent file (%lu), %d", |
| 2025 | inode->i_ino, inode->i_nlink); |
| 2026 | inode->i_nlink = 1; |
| 2027 | } |
| 2028 | rc = ext3_delete_entry(IrpContext, dir, de, bh); |
| 2029 | if (rc) { |
| 2030 | Status = Ext2WinntError(rc); |
| 2031 | __leave; |
| 2032 | } |
| 2033 | /* |
| 2034 | if (!inode->i_nlink) |
| 2035 | ext3_orphan_add(handle, inode); |
| 2036 | */ |
| 2037 | inode->i_ctime = dir->i_ctime = dir->i_mtime = ext3_current_time(dir); |
| 2038 | ext3_dec_count(inode); |
| 2039 | ext3_mark_inode_dirty(IrpContext, inode); |
| 2040 | |
| 2041 | /* decrease dir inode's nlink for .. */ |
| 2042 | if (S_ISDIR(inode->i_mode)) { |
| 2043 | ext3_update_dx_flag(dir); |
| 2044 | ext3_dec_count(dir); |
no test coverage detected