EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Regarding OnCanFileBeDeleted() callback

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#20977
Posted: 08/02/2012 04:47:16
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 66

Hi there,

Does the OS call OnCanFileBeDeleted() callback only when all file handles are closed?
Or should I check myself that there are no open handles for the file?

I have read the documentation and searched through the forum but couldn't find a definitive answer.

Thanks,
IP

tags: CbfsCanFileBeDeleted OnCanFileBeDeleted CanFileBeDeleted
#20980
Posted: 08/02/2012 05:13:09
by Volodymyr Zinin (EldoS Corp.)

OnCanFileBeDeleted() can be called at any time.
Here is a pair of situations when it's called:
1. When Windows wants to place a file to recycle bin it opens the file, checks if it can be deleted (passes to the file system driver a request IRP_MJ_SET_INFORMATION with the FileDispositionInformation flag and CallbackFS calls the OnCanFileBeDeleted() calback), and then moves the file to the "recycle bin" folder. There is no real deletion of it.

2. Several processes open a file with the FILE_SHARE_DELETE share access and then one of them marks the file to be deleted (again as in the first case sends IRP_MJ_SET_INFORMATION with the FileDispositionInformation flag to the file system driver). In this case the OnCanFileBeDeleted() calback is being called when there are several handles for the file, but it can be really deleted only after the latest handle has been closed.
#20985
Posted: 08/02/2012 07:07:52
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 66

Vladimir, thanks a lot for your explanations.

I want to know whether I have to do any checks myself (like searching through opened handles) in CanFileBeDeleted().

Can just return 'true' if I don't have any additional requirements, and can be sure that OS will do call OnDelete() when all handles are closed (in case of SHARE_DELETE)?

Thanks,
IP
#20986
Posted: 08/02/2012 07:38:39
by Volodymyr Zinin (EldoS Corp.)

Quote
Ivan P wrote:
Can just return 'true' if I don't have any additional requirements, and can be sure that OS will do call OnDelete() when all handles are closed (in case of SHARE_DELETE)?

Yes

Reply

Statistics

Topic viewed 817 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!