Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I copy a locked file directly from the disk and make sure that the file is intact?

The application I am writing needs to be able to copy files that are locked. We attempted to use Volume Shadow Copy, and while it was successful in copying the file, the application that had the lock on the file crashed because it could not acquire a lock while we were copying the file.

I am left to believe that my only option is to bypass the OS and read directly from the disk. The problem is that if I read directly to the disk I cannot be sure of the integrity of the file, if it is in the middle of a write the file will be in a damaged state.

After hours of searching I was able to find one utility that copied the file directly from the disk and used a file system driver to cache writes while copying so that it could make sure that the file was in an intact state. However, that utility is extraordinarily expensive, 100k+ for the license I would likely need to use.

Does anyone have any ideas on how to accomplish what I am trying to?

We are planning on restricting the system to NTFS volumes only.

like image 984
Eric Milas Avatar asked Jun 06 '11 20:06

Eric Milas


1 Answers

I ended up using a C program called DirectCopy written by Napalm. It works rather well.

http://www.rohitab.com/discuss/topic/24252-ntfs-directcopy-method-from-napalm/

like image 69
Eric Milas Avatar answered Oct 01 '22 19:10

Eric Milas