I'm trying to make a virtual file system using the C# version of Dokan.
What I want to do right now is to set the max limit of a file for my filesystem, for example, the filesystem can't have a file with more than 2GB.
At the moment I'm doing this on Operation SetEndOfFile but I can only give DiskFull error and I want to return something like NTStatus.FileTooLarge, but when I do that the filesystem simply ignore that return.
Is there any options to do what I want?
You can check the offset of the WriteFile
function, if offset is bigger than 2GB - you return NtStatus.FileTooLarge
.
Also, you should check the buffer.Length
too, in case when you edit the file on the disk - it doesn't chop it into smaller buffered chunks, instead the entire file is put into a one buffer. In this scenario, you should find a way not to destroy the file, because the CleanUp
will be called immediately after returning NtStatus.FileTooLarge
from WriteFile
method with info.DeleteOnClose
set to true.