| 1 | /*++ |
| 2 | |
| 3 | Copyright (c) Microsoft. All rights reserved. |
| 4 | |
| 5 | Module Name: |
| 6 | |
| 7 | WslCoreFilesystem.h |
| 8 | |
| 9 | Abstract: |
| 10 | |
| 11 | This file contains WSL Core filesystem helper function declarations. |
| 12 | |
| 13 | --*/ |
| 14 | |
| 15 | #pragma once |
| 16 | #include "precomp.h" |
| 17 | |
| 18 | #define MAX_VHD_COUNT 254 |
| 19 | |
| 20 | // Each virtiofs device uses the DAX cache, which is controlled by wslcore's caller, plus a couple |
| 21 | // of extra pages for configuration. MMIO space needs to be large page aligned (2MB), so request an |
| 22 | // additional 2MB to cover the couple of extra pages needed. |
| 23 | #define EXTRA_MMIO_SIZE_PER_VIRTIOFS_DEVICE_IN_MB 2 |
| 24 | |
| 25 | namespace wsl::core::filesystem { |
| 26 | |
| 27 | /// <summary> |
| 28 | /// Create a file owned by the specified user. |
| 29 | /// </summary> |
| 30 | wil::unique_hfile CreateFile( |
| 31 | _In_ LPCWSTR fileName, _In_ DWORD desiredAccess, _In_ DWORD shareMode, _In_ DWORD creationDisposition, _In_ DWORD flagsAndAttributes, _In_ PSID userSid); |
| 32 | |
| 33 | /// <summary> |
| 34 | /// Create a VHD of the specified size. |
| 35 | /// </summary> |
| 36 | void CreateVhd(_In_ LPCWSTR target, _In_ ULONGLONG maximumSize, _In_ PSID userSid, _In_ BOOL sparse, _In_ BOOL fixed); |
| 37 | |
| 38 | wil::unique_handle OpenVhd(_In_ LPCWSTR Path, _In_ VIRTUAL_DISK_ACCESS_MASK Mask); |
| 39 | |
| 40 | void CompactVhd(_In_ LPCWSTR Path); |
| 41 | |
| 42 | void ResizeExistingVhd(_In_ HANDLE diskHandle, _In_ ULONGLONG maximumSize, _In_ RESIZE_VIRTUAL_DISK_FLAG resizeFlag); |
| 43 | |
| 44 | ULONGLONG GetDiskSize(_In_ HANDLE diskHandle); |
| 45 | |
| 46 | } // namespace wsl::core::filesystem |