Payman,
This is kind of a broad question. If I were you, I would consider purchasing the book “Microsoft Windows Internals” Fourth Edition by Mark E. Russinovich and David A. Solomon. It talks briefly about how to use reparse points for HSM-type solutions, plus is generally informative and useful for understanding how the kernel and filesytem work.
I’m not sure if there is any good documentation on reparse point usage in HSM solutions, but you can pick up hints from here or there. You’ll also want to read Microsoft’s “Filter Driver Development Guide” (Google it), which has some info on using reparse points. Be sure to search through these forums for info on reparse points, as well.
I’m guessing the basic idea of what you’ll want to do is something along these lines:
- Copy data to remote storage
- Tag file with reparse point
- Remove data from file & optionally mark as sparse
- Write a minifilter which looks for STATUS_REPARSE in the post-create function for MJ_CREATE operations which would then do something to restore the file and or redirect the open to remote storage and then re-issue the IRP
Don’t be fooled, though, it’s harder than it sounds.
Here’s some C++ code that might help you (or anyone else) set reparse points (—> USER-MODE ONLY <—):
// Returned size fron DeviceIoControl
DWORD dwReturnedSize = 0;
// Should make sure this file is on an NTFS volume, otherwise this will fail
if(! this->VolumeSupportsReparsePoints(this->mwsFileName) )
return false;
// Get a handle to the file to set the reparse point
HANDLE hFile = CreateFile( this->mwsFileReadWriteName.c_str(),
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_ALWAYS,
FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS,
NULL );
// Make sure we could create the new file
if (hFile == INVALID_HANDLE_VALUE)
{
CloseHandle(hFile);
return false;
}
// Actually tag the file with the reparse point
if ( ! DeviceIoControl( hFile,
FSCTL_SET_REPARSE_POINT,
this->mpReparseInfo,
this->mpReparseInfo->ReparseDataLength + this->mulHeaderSize,
NULL,
0,
&dwReturnedSize,
NULL ) )
{
// Signals a failure
CloseHandle(hFile);
return false;
}
// Everything seemed to work correctly!
CloseHandle(hFile);
return true;
====================
Hope that helps,
Bill