OSRLogo
OSRLogoOSRLogoOSRLogo x Seminar Ad
OSRLogo
x

Everything Windows Driver Development

x
x
x
GoToHomePage xLoginx
 
 

    Sun, 19 May 2013     98499 members

   Login
   Join


 
 
Contents
  About This Site
What's New?
OSR Dev Blog
The NT Insider
The Basics
File Systems
Downloads
ListServer / Forum
Driver Jobs
Store
  Express Links
  · WdfSend: Are There REALLY Three Useful Variants?
  · Turning a Breakpoint into a Busypoint
  · Investigating a NULL Pointer Dereference
  · Understanding WDFMEMORY Objects
  · Using WinDbg to hunt for strings

How Are Files Deleted In Windows


A file or directory is deleted when a deletion request is pending and the last user reference to the file is released (that is, the last IRP_MJ_CLEANUP is sent to the file system).

 

Deletion is requested on a file or directory in one of two ways:

 

  • When the file/directory is opened, FILE_DELETE_ON_CLOSE is set.  The exact semantics of this are complicated because the file systems explicitly check for this, explicitly add DELETE access to the access required (even if not requested originally) and must deal with issues regarding directories (a directory must be empty before it can be marked delete pending).
  • For an already opened file/directory, the IRP_MJ_SET_INFORMATION, specifying FileDispositionInformation and then providing the FILE_DISPOSITION_INFORMATION structure indicating TRUE for the DeleteFile field.

 

In these cases the file is now scheduled for deletion, but that can be changed by a subsequent call to modify the file disposition (indicating FALSE for the DeleteFile field.)

 

Note that the EXACT semantics are file system specific.  Do not be surprised if you see some differences in the seven general purpose file systems currently available from Microsoft.  For example, CDFS and UDFS currently do not allow you to delete files (note the term "currently" - were Microsoft to provide a read/write UDF file system, then we suspect these semantics would change.)  NFS semantics are very different than CIFS semantics for deletion.  Similarly, the semantics of the Netware File System are also unclear.

User Comments
Rate this article and give us feedback. Do you find anything missing? Share your opinion with the community!
Post Your Comment

"unix like delete"
Just in case you're porting unix application code (and I will wash my mouth out with soap right after this) that assumes the unix delete semantics, lets be explict about it. This means its not sufficient to delete a file, it may not be deleted immediately, and this may cause problems in deleting directories and/or creating a new file of the same name.

But you can closely simulate unix semantics by renaming the file to a temporary directory and scheduling it for deletion.

Rating:
18-Aug-03, Jack Heeley


Post Your Comments.
Print this article.
Email this article.

Windows Internals and SW Drivers
LAB

Santa Clara, CA
5-9 Aug 2013

Kernel Debugging & Crash Analysis
LAB

Santa Clara, CA
9-13 Sep 2013

Writing WDF Drivers
LAB

Boston/Waltham, MA
7-11 Oct 2013

Developing File Systems
Seattle, WA
5-8 Nov 2013

 
 

Windows Debugger
V6.12.2.633 -- 26 Feb 10

Checked Build Downloads
29-Apr-10

Debugging Symbols

 

WDK Doc Updates
Now updated bi-monthly!

Windows WDK
V7.1.0 -- 26 Feb 10

 
 
x
LetUsHelp
 

Need to develop a Windows file system solution?

We've got a kit for that.

Need Windows internals or kernel driver expertise?

Bring us your most challenging project - we can help!

System hangs/crashes?

We've got a special diagnostic team that's standing by.

Visit the OSR Corporate Web site for more information about how OSR can help!

 
bottom nav links