EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Disk full Detection

Posted: 04/15/2008 09:31:31
by Franck Bonin (Standard support level)
Joined: 09/21/2007
Posts: 27

Despite the fact I report consistent information using GetVolumeSize() callback, when I start copying/create a file that will not fit my left virtual space, system still fill my virtual disk (using SetEndOffile, WriteFile, and SetAllocationSize callbacks) until it encounter a write failure.
In my case, write failure never (rarely occurs) since there is always enough rooms on my local temporary space. Error occurs very very lately, when my temporary space is saved remotely (and of course no room can be found)

As I would like a "smart and early" disk full detection, I try to used SetEndOffile callback
To detect file creation that would not fit my virtual space.

But, throwing ECBFSError from SetEndOffile() callback didn't stop system to create and fill too big files for my virtual space.

I also tried SetAllocationSize callback, without more success.

Of course I could test in every WriteFile Callback that data written will fit my virtual space. But this would not solve the "early detection" part of my problem and it seems not to be very efficient.

Is their any simple, obvious solution to my problem?

I use a cbfs.sys 32bit driver V and C++ API, both on Windows XP pro SP2.

Franck Bonin
Posted: 04/15/2008 13:38:49
by Volodymyr Zinin (Team)


Franck Bonin wrote:
I also tried SetAllocationSize callback, without more success.

Yes. You must use for your purpose SetAllocationSize callback. When there is not enough space then it should return an error (like ERROR_DISK_FULL).
What does it mean "without more success"? Does a file copying continue after SetAllocationSize returns an error?
Posted: 04/15/2008 13:49:23
by Volodymyr Zinin (Team)

BTW: GetVolumeSize() callback is used only when someone requests information about a volume size. For example Explorer does it when shows properties of a volume.
Posted: 04/16/2008 02:59:22
by Franck Bonin (Standard support level)
Joined: 09/21/2007
Posts: 27

"without more success" means I have tried to throw error from OnSetAllocationSize. But error I use to throw from here seemed to not stop file copy

Anyway I should have made a mistake since today, when I throw ERROR_DISK_FULL error from OnSetAllocationSize callback, it works perfectly! (Explorer complain with a disk full error popup).

Thanks !

Just a last question about OnSetAllocationSize :
CbFsFileInfo* FileInfo,
PVOID FileHandleContext,
__int64 AllocationSize)

What AllocationSize parameter exactly means:

"Total space the system may need to create/append concerned file?"


"Supplementary space system may need to create/append concerned file?"

(I think this make no differences when creating a new file but it is surly not the case when modifying an existing one)

Franck Bonin

Posted: 04/16/2008 03:31:04
by Volodymyr Zinin (Team)

There are two file sizes exist. One of them is 'end of file' (i.e. EOF) that means real size of data in a file. The other is 'allocation size' - it's size of space that a file has on a disk.
Before writing to a file (if space on a storage has not been allocated yet) and sometimes at a file creation time (see the ZwCreateFile's parameter AllocationSize in MSDN) the callback OnSetAllocationSize is called and if it returns success then CallbackFS (other file systems work in the same way) is assured that enough space on a disk has been allocated for data that will be written to the file. And when a file is closed and its 'allocation size' is more then 'end of file' then the file system frees excess space (by calling OnSetAllocationSize again).
Posted: 04/17/2011 08:55:32
by Oleg Savelos (Standard support level)
Joined: 08/25/2008
Posts: 21

So do we actually need to check if required space exist on other callbacks (OnWrite,OnSetFileSize) or dose the OnSetAllocationSize is enough?
Posted: 04/18/2011 00:07:21
by Volodymyr Zinin (Team)

OnSetAllocationSize is enough.
Posted: 04/18/2011 03:28:37
by Oleg Savelos (Standard support level)
Joined: 08/25/2008
Posts: 21




Topic viewed 5055 times

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


Back to top

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

Got it!