Jump-start your project by learning from devs who
write Windows drivers and file systems every day.
Take an OSR seminar!

OSR is Hiring! Click here to find out more.

Upcoming OSR Seminars:
Windows Internals & Software Drivers Lab, Santa Clara, CA 5-9 August, 2013
Kernel Debugging & Crash Analysis for Windows Lab, Santa Clara, CA 9-13 September, 2013
Writing WDF Drivers for Windows Lab, Boston, MA 7-11 October, 2013
Developing File Systems for Windows, Seattle, WA 5-8 November, 2013


Go Back   OSR Online Lists > ntfsd
Welcome, Guest
You must login to post to this list
  Message 1 of 6  
12 Mar 12 17:05
ntfsd member 132183
xxxxxx@gmail.com
Join Date:
Posts To This List: 5
Cleanup Routine

Im working on a file system for Windows and Im using IFS Test for make sure it is complying with Windows. Im working on this specific test, the DeleteOnLastCloseTest (more info here: http://msdn.microsoft.com/en-us/library/ff563405(v=vs.85).aspx) that tests the behavior for setting the flag DELETE_ON_CLOSE. For what I understand, the Cleanup should do this: * If a handle is marked for deletion, when it is closed, Cleanup should mark the file for deletion. * If a file is marked for deletion, on the last Cleanup call, it should be deleted Well, I implemented the behavior described above, but Im getting some awkward messages like this: Test : Group :IfsTestRtl Status :4000000C (IFSTEST_INFO_PROBLEM_IN_CLEANUP) LastNtStatus :C0000056 STATUS_DELETE_PENDING ExpectedNtStatus :00000000 STATUS_SUCCESS Description :{Msg# IfsRtl!del!12} The file called \delolc2.dat could not be deleted during the group cleanup routine. This file must be deleted manually. If it was created during the CreatePagingFileTest, you are required to reboot your machine before the file can be deleted. The status was C0000056. But the file delolc2.dat doesnt exist anymore when the test is finished. Any guesses? Arnett.
  Message 2 of 6  
12 Mar 12 22:27
Peter Scott
xxxxxx@kerneldrivers.com
Join Date: 17 Feb 2012
Posts To This List: 247
Re: Cleanup Routine

Are you correctly returning a status_file_deleted status if an attempt is made to open the file before the handle in which the delete_on_close was closed? There are intermediate operations which can be attempted on handles already opened which also must be handled correctly. Pete On 3/12/2012 3:04 PM, xxxxx@gmail.com wrote: > Im working on a file system for Windows and Im using IFS Test for make sure it is complying with Windows. Im working on this specific test, the DeleteOnLastCloseTest (more info here: http://msdn.microsoft.com/en-us/library/ff563405(v=vs.85).aspx) that tests the behavior for setting the flag DELETE_ON_CLOSE. For what I understand, the Cleanup should do this: > > * If a handle is marked for deletion, when it is closed, Cleanup should mark the file for deletion. > * If a file is marked for deletion, on the last Cleanup call, it should be deleted > > Well, I implemented the behavior described above, but Im getting some awkward messages like this: > > Test : > Group :IfsTestRtl > Status :4000000C (IFSTEST_INFO_PROBLEM_IN_CLEANUP) <...excess quoted lines suppressed...> -- Kernel Drivers Windows File System and Device Driver Consulting www.KernelDrivers.com 866.263.9295
  Message 3 of 6  
13 Mar 12 05:04
Malcolm Smith
xxxxxx@operamail.com
Join Date: 12 Sep 2007
Posts To This List: 98
Re: Cleanup Routine

On 03/12/2012 02:04 PM, xxxxx@gmail.com wrote: > Im working on a file system for Windows and Im using IFS Test for make sure it is complying with Windows. Im working on this specific test, the DeleteOnLastCloseTest (more info here: http://msdn.microsoft.com/en-us/library/ff563405(v=vs.85).aspx) that tests the behavior for setting the flag DELETE_ON_CLOSE. For what I understand, the Cleanup should do this: > > * If a handle is marked for deletion, when it is closed, Cleanup should mark the file for deletion. Prior to closing a DELETE_ON_CLOSE handle, other handles can be successfully created (operations should return STATUS_SUCCESS.) After closing this handle, behavior is the same as if a SetDisposition call occurred - operations to that stream or link should fail with STATUS_DELETE_PENDING. > * If a file is marked for deletion, on the last Cleanup call, it should be deleted After that, operations to the file or stream should fail with STATUS_FILE_DELETED. It shouldn't be possible to get this from usermode, since that requires an outstanding handle; only kernel mode callers operating on referenced FileObjects can see this state. > > Well, I implemented the behavior described above, but Im getting some awkward messages like this: > > Test : > Group :IfsTestRtl > Status :4000000C (IFSTEST_INFO_PROBLEM_IN_CLEANUP) > LastNtStatus :C0000056 STATUS_DELETE_PENDING > ExpectedNtStatus :00000000 STATUS_SUCCESS This sounds like IfsTest opened a DELETE_ON_CLOSE handle and attempted to open a second handle, which failed when it should have succeeded. > Description :{Msg# IfsRtl!del!12} The file called \delolc2.dat > could not be deleted during the group cleanup routine. > This file must be deleted manually. If it was created > during the CreatePagingFileTest, you are required to > reboot your machine before the file can be deleted. > The status was C0000056. > > But the file delolc2.dat doesnt exist anymore when the test is finished. IfsTest is a little overactive with this message. It's really saying, "my cleanup didn't do what I expect and I don't know what state the system is in, manual intervention may be required." But since you're deleting the file on last handle close, it will go away safely anyway. - M
  Message 4 of 6  
14 Mar 12 15:31
ntfsd member 132183
xxxxxx@gmail.com
Join Date:
Posts To This List: 5
RE: Cleanup Routine

Hi, thank you for your answers. @Peter Scott: Are you sure I should fail with STATUS_FILE_DELETED when an attempt is made to open the file before the handle in which the DELETE_ON_CLOSE was closed? I looked out for this status and found out this: STATUS_FILE_DELETED: An I/O request other than close was performed on a file after it was deleted, which can only happen to a request that did not complete before the last handle was closed via NtClose. Source: http://msdn.microsoft.com/en-us/library/cc704588(v=prot.10).aspx @Malcolm Smith: The behavior which you described is the one I implemented. But, about the cleanup, I'm not sure if it is doing what it should do. Do you know where I can find a sample right implementation of it? @All: I ran DeleteOnLastCloseTest on a NTFS partition with Process Monitor to see what exactly was happening. After doing that, I ran DeleteOnLast on the file system that I'm working on, and realized that the last close for the file (the one that should delete the file) is not being called on the right time, it is actually the last call the IFSTest does before it ends its execution. So, the file is only being deleted on the end of the execution of the IFSTest. Does anything similar ever happened to any of you? Thanks, Arnett.
  Message 5 of 6  
15 Mar 12 08:53
Peter Scott
xxxxxx@kerneldrivers.com
Join Date: 17 Feb 2012
Posts To This List: 247
Re: Cleanup Routine

Yes, if the delete flag is set on some file object then any attempted access to that file via another open request must be failed using STATUS_FILE_DELETED. You can see this code path in the FastFat source code, for example. Pete On 3/14/2012 1:31 PM, xxxxx@gmail.com wrote: > Hi, thank you for your answers. > > @Peter Scott: Are you sure I should fail with STATUS_FILE_DELETED when an attempt > is made to open the file before the handle in which the DELETE_ON_CLOSE was closed? I looked out for this status and found out this: > > STATUS_FILE_DELETED: An I/O request other than close was performed on a file after it was deleted, which can only happen to a request that did not complete before the last handle was closed via NtClose. > > Source: http://msdn.microsoft.com/en-us/library/cc704588(v=prot.10).aspx > > @Malcolm Smith: <...excess quoted lines suppressed...> -- Kernel Drivers Windows File System and Device Driver Consulting www.KernelDrivers.com 866.263.9295
  Message 6 of 6  
15 Mar 12 09:53
Malcolm Smith
xxxxxx@operamail.com
Join Date: 12 Sep 2007
Posts To This List: 98
Re: Cleanup Routine

On 03/15/2012 05:52 AM, Peter Scott wrote: > > Yes, if the delete flag is set on some file object then any attempted > access to that file via another open request must be failed using > STATUS_FILE_DELETED. You can see this code path in the FastFat source > code, for example. Please see my earlier post in this thread. STATUS_SUCCESS - Opening a handle once another handle exists which is DELETE_ON_CLOSE. It is totally valid to open at this point. STATUS_DELETE_PENDING - Opening a handle once another handle has set delete disposition via FileDispositionInformation, or the aforementioned DELETE_ON_CLOSE handle has been closed but another handle is keeping the object alive. Closing a DELETE_ON_CLOSE handle is the same thing as FileDispositionInformation with Delete == TRUE. STATUS_FILE_DELETED - The final handle has been closed and the object is actually gone. This can only happen from a referenced file object (ie., kernel mode) since no handle exists at this point. - M
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntfsd list to be able to post.

All times are GMT -5. The time now is 06:29.


Copyright ©2012, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license