-
Notifications
You must be signed in to change notification settings - Fork 1
/
volume_info.c
66 lines (54 loc) · 1.9 KB
/
volume_info.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "volume_info.h"
#include "debug.h"
#include "general.h"
unsigned MxfsGetFreeSpace(MINIX_FS *FileSys)
{
unsigned UsedZones = MxfsCountBitsSet(&FileSys->ZoneMap);
unsigned TotalZones = FileSys->Super.s_zones;
unsigned FreeBlocks = (TotalZones - UsedZones) << FileSys->Super.s_log_zone_size;
return FreeBlocks * MINIX_BLOCK_SIZE;
}
int DOKAN_CALLBACK MxfsGetDiskFreeSpace(
PULONGLONG FreeBytesAvailable,
PULONGLONG TotalNumberOfBytes,
PULONGLONG TotalNumberOfFreeBytes,
PDOKAN_FILE_INFO FileInfo)
{
TRACE("");
MINIX_FS *FileSys = (MINIX_FS*)(ULONG_PTR)FileInfo->DokanOptions->GlobalContext;
ASSERT(FileSys);
unsigned FreeBytes = 0;
if(FreeBytesAvailable || TotalNumberOfFreeBytes)
FreeBytes = MxfsGetFreeSpace(FileSys);
if(FreeBytesAvailable)
*FreeBytesAvailable = FreeBytes;
if(TotalNumberOfBytes)
*TotalNumberOfBytes = FileSys->cbLen;
if(TotalNumberOfFreeBytes)
*TotalNumberOfFreeBytes = FreeBytes;
return 0;
}
// see Win32 API GetVolumeInformation
int DOKAN_CALLBACK MxfsGetVolumeInformation(
LPWSTR VolumeNameBuffer,
DWORD VolumeNameSize, // in num of chars
LPDWORD VolumeSerialNumber,
LPDWORD MaximumComponentLength, // in num of chars
LPDWORD FileSystemFlags,
LPWSTR FileSystemNameBuffer,
DWORD FileSystemNameSize, // in num of chars (this is not true?)
PDOKAN_FILE_INFO FileInfo)
{
TRACE("");
if(VolumeNameSize > 0 && VolumeNameBuffer)
wcscpy_s(VolumeNameBuffer, VolumeNameSize, L"");
if(VolumeSerialNumber)
*VolumeSerialNumber = MINIX_VOLUME_ID;
if(MaximumComponentLength)
*MaximumComponentLength = MAX_NAME_LEN;
if(FileSystemFlags)
*FileSystemFlags = FILE_CASE_SENSITIVE_SEARCH;
if(FileSystemNameSize > 0 && FileSystemNameBuffer)
wcscpy_s(FileSystemNameBuffer, FileSystemNameSize, L"Minix");
return 0;
}