2
* FreeRDP: A Remote Desktop Protocol Implementation
3
* statvfs emulation for Windows
5
* Copyright 2012 Gerald Richter
7
* Licensed under the Apache License, Version 2.0 (the "License");
8
* you may not use this file except in compliance with the License.
9
* You may obtain a copy of the License at
11
* http://www.apache.org/licenses/LICENSE-2.0
13
* Unless required by applicable law or agreed to in writing, software
14
* distributed under the License is distributed on an "AS IS" BASIS,
15
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
* See the License for the specific language governing permissions and
17
* limitations under the License.
23
#include <winpr/crt.h>
24
#include <winpr/windows.h>
28
int statvfs(const char *path, struct statvfs *buf)
33
DWORD lpSectorsPerCluster;
34
DWORD lpBytesPerSector;
35
DWORD lpNumberOfFreeClusters;
36
DWORD lpTotalNumberOfClusters;
38
len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
39
unicodestr = (LPWSTR) malloc(len);
40
MultiByteToWideChar(CP_ACP, 0, path, -1, unicodestr, len);
42
res = GetDiskFreeSpace(unicodestr, &lpSectorsPerCluster, &lpBytesPerSector, &lpNumberOfFreeClusters, &lpTotalNumberOfClusters);
44
buf->f_bsize = lpBytesPerSector; /* file system block size */
45
buf->f_frsize = 0; /* fragment size */
46
buf->f_blocks = lpTotalNumberOfClusters; /* size of fs in f_frsize units */
47
buf->f_bfree = lpNumberOfFreeClusters; /* # free blocks */
48
buf->f_bavail = lpNumberOfFreeClusters; /* # free blocks for unprivileged users */
49
buf->f_files = 0; /* # inodes */
50
buf->f_ffree = 0; /* # free inodes */
51
buf->f_favail = 0; /* # free inodes for unprivileged users */
52
buf->f_fsid = lpNumberOfFreeClusters & 0xffff; /* file system ID */
53
buf->f_flag = 0; /* mount flags */
54
buf->f_namemax = 250; /* maximum filename length */