EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Problem display size of the disk.

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
#33115
Posted: 04/23/2015 03:48:20
by Mike Bogdan (Priority Standard support level)
Joined: 04/23/2015
Posts: 3

Problem display size of the disk.

In the event callbacks OnGetVolumeSize I set the value for TotalAllocationUnits.

Here is the log with values:

2015-04-23 10:13:29,027 [CbFs] [36] INFO - [explorer: 3760:36]: GetVolumeSize: - TotalUnits: 8589934592, AvailableUnits: 8589934592

Actually, file managers (eg FAR) display similar data as follows:

TotalAllocationUnits: 268,435,456
CallerAvailableAllocationUnits: 268,435,456
ActualAvailableAllocationUnits: 268,435,456
SectorsPerAllocationUnit: 32
BytesPerSector: 512


Why?
#33116
Posted: 04/23/2015 03:55:29
by Eugene Mayevski (EldoS Corp.)

I am sorry but it's not clear what the actual problem is. Does the reported size differ from what you set? If yes, can you please tell us what values you return in OnGetVolumeSize?


Sincerely yours
Eugene Mayevski
#33117
Posted: 04/23/2015 04:04:01
by Andrew Pratt (Standard support level)
Joined: 03/01/2013
Posts: 4

Mike, the size shown is the value you supplied div by SectorsPerAllocationUnit
#33118
Posted: 04/23/2015 04:10:13
by Mike Bogdan (Priority Standard support level)
Joined: 04/23/2015
Posts: 3

sample code:
//Initialize my drive
private void Initialize(CbFsStorageType storageType, IVirtualDriveOptions driveOptions, bool useFileSecurity)
{
m_Cbfs = new CallbackFileSystem();

...

m_Cbfs.OnGetVolumeSize = new CbFsGetVolumeSizeEvent(OnCbfsGetVolumeSize);

...

// For Callback File System it doesn't matter what size of cluster is, but some applications request
// cluster size to calculate the buffer size used to transfer data in the read and write operations.
// So setting the cluster size to some larger value can increase speed of data transfer by decreasing
// the number of OnReadFile and OnWriteFile callbacks called.
m_Cbfs.ClusterSize = m_Cbfs.SectorSize * 32;

...

}

protected uint ClusterSize
{
get { return m_Cbfs.ClusterSize; }
}


private void OnCbfsGetVolumeSize(CallbackFileSystem sender, ref long totalAllocationUnits, ref long availableAllocationUnits)
{
try
{
totalAllocationUnits = 128L *1024*1024*1024*1024 /ClusterSize; // 128 Tb
availableAllocationUnits = 128L * 1024 * 1024 * 1024 * 1024 / ClusterSize;

WriteDebugLog(string.Format("GetVolumeSize: - TotalUnits: {0}, AvailableUnits: {1}", totalAllocationUnits, availableAllocationUnits));

}

...
}
#33119
Posted: 04/23/2015 04:40:57
by Volodymyr Zinin (EldoS Corp.)

Quote
MikeBo wrote:
private void OnCbfsGetVolumeSize(CallbackFileSystem sender, ref long totalAllocationUnits, ref long availableAllocationUnits) { try { totalAllocationUnits = 128L *1024*1024*1024*1024 /ClusterSize; // 128 Tb availableAllocationUnits = 128L * 1024 * 1024 * 1024 * 1024 / ClusterSize;

WriteDebugLog(string.Format("GetVolumeSize: - TotalUnits: {0}, AvailableUnits: {1}", totalAllocationUnits, availableAllocationUnits));

}


totalAllocationUnits and availableAllocationUnits must contain total size in bytes divided on SectorsPerAllocationUnit and BytesPerSector.
#33123
Posted: 04/23/2015 11:43:14
by Mike Bogdan (Priority Standard support level)
Joined: 04/23/2015
Posts: 3

Realized the error.

Confusion between ClusterSize and SectorSize

Thank you.
#33124
Posted: 04/23/2015 18:38:37
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 66

According to documentation:
Code
[C#]
    public void CbFsGetVolumeSizeEvent( CallbackFileSystem Sender, ref Int64 TotalAllocationUnits, ref Int64 AvailableAllocationUnits );

TotalAllocationUnits - the event handler must place the total number of the allocation units (clusters) on device to this parameter

In order to get number of clusters I should return the number of bytes divided by the cluster size: SizeOfDisk/ClusterSize

But in fact it seems that I'm required to return number of sectors: SizeOfDisk/SectorSize . And that is what the Mapper sample does.

In latter case Windows seems to show proper values.

I suppose that fixing this in API is a breaking change, so could the documentation be updated as follows?
Code
[C#]
    public void CbFsGetVolumeSizeEvent( CallbackFileSystem Sender, ref Int64 TotalSectors, ref Int64 AvailableSectors );


Sincerely,
IP
#33125
Posted: 04/24/2015 02:20:00
by Eugene Mayevski (EldoS Corp.)

Thank you for the detailed description, I've adjusted the help file to mention sectors, not clusters.


Sincerely yours
Eugene Mayevski
Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.

Reply

Statistics

Topic viewed 4716 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!