|
| 1 | +//********************************************************************* |
| 2 | +// Copyright (C) Microsoft Corporation. |
| 3 | +// |
| 4 | +// @File: vdi.h |
| 5 | +// @Owner: <owner alias> |
| 6 | +// |
| 7 | +// Purpose: |
| 8 | +// <description> |
| 9 | +// |
| 10 | +// Notes: |
| 11 | +// <special-instructions> |
| 12 | +// |
| 13 | +//********************************************************************* |
| 14 | +#ifndef __vdi_h__ |
| 15 | +#define __vdi_h__ |
| 16 | + |
| 17 | +#pragma once |
| 18 | + |
| 19 | +#ifdef __cplusplus |
| 20 | +extern "C" { |
| 21 | +#endif |
| 22 | + |
| 23 | +#pragma pack(push, _vdi_h_) |
| 24 | + |
| 25 | +#include <time.h> |
| 26 | +#include <stdint.h> |
| 27 | + |
| 28 | +// Errors that need to be passed back to SQL Server, originally defined |
| 29 | +// in Windows.h or similar |
| 30 | +// |
| 31 | +#define ERROR_SUCCESS 0L |
| 32 | +#define ERROR_ARENA_TRASHED 7L |
| 33 | +#define ERROR_HANDLE_EOF 38L |
| 34 | +#define ERROR_HANDLE_DISK_FULL 39L |
| 35 | +#define ERROR_NOT_SUPPORTED 50L |
| 36 | +#define ERROR_DISK_FULL 112L |
| 37 | +#define ERROR_OPERATION_ABORTED 995L |
| 38 | + |
| 39 | +#pragma pack(8) |
| 40 | +struct VDConfig |
| 41 | +{ |
| 42 | + uint32_t deviceCount; |
| 43 | + uint32_t features; |
| 44 | + uint32_t prefixZoneSize; |
| 45 | + uint32_t alignment; |
| 46 | + uint32_t softFileMarkBlockSize; |
| 47 | + uint32_t EOMWarningSize; |
| 48 | + uint32_t serverTimeOut; |
| 49 | + uint32_t blockSize; |
| 50 | + uint32_t maxIODepth; |
| 51 | + uint32_t maxTransferSize; |
| 52 | + uint32_t bufferAreaSize; |
| 53 | +}; |
| 54 | + |
| 55 | +enum VDFeatures |
| 56 | +{ VDF_Removable = 0x1, |
| 57 | + VDF_Rewind = 0x2, |
| 58 | + VDF_Position = 0x10, |
| 59 | + VDF_SkipBlocks = 0x20, |
| 60 | + VDF_ReversePosition = 0x40, |
| 61 | + VDF_Discard = 0x80, |
| 62 | + VDF_FileMarks = 0x100, |
| 63 | + VDF_RandomAccess = 0x200, |
| 64 | + VDF_SnapshotPrepare = 0x400, |
| 65 | + VDF_EnumFrozenFiles = 0x800, |
| 66 | + VDF_VSSWriter = 0x1000, |
| 67 | + VDF_RequestComplete = 0x2000, |
| 68 | + VDF_WriteMedia = 0x10000, |
| 69 | + VDF_ReadMedia = 0x20000, |
| 70 | + VDF_CompleteEnabled = 0x40000, |
| 71 | + VDF_LatchStats = 0x80000000, |
| 72 | + VDF_LikePipe = 0, |
| 73 | + VDF_LikeTape = |
| 74 | + ( ( ( ( ( VDF_FileMarks | VDF_Removable ) | VDF_Rewind ) | VDF_Position ) | |
| 75 | + VDF_SkipBlocks ) | VDF_ReversePosition ), |
| 76 | + VDF_LikeDisk = VDF_RandomAccess}; |
| 77 | + |
| 78 | +enum VDCommands |
| 79 | +{ VDC_Read = 1, |
| 80 | + VDC_Write = ( VDC_Read + 1 ), |
| 81 | + VDC_ClearError = ( VDC_Write + 1 ), |
| 82 | + VDC_Rewind = ( VDC_ClearError + 1 ), |
| 83 | + VDC_WriteMark = ( VDC_Rewind + 1 ), |
| 84 | + VDC_SkipMarks = ( VDC_WriteMark + 1 ), |
| 85 | + VDC_SkipBlocks = ( VDC_SkipMarks + 1 ), |
| 86 | + VDC_Load = ( VDC_SkipBlocks + 1 ), |
| 87 | + VDC_GetPosition = ( VDC_Load + 1 ), |
| 88 | + VDC_SetPosition = ( VDC_GetPosition + 1 ), |
| 89 | + VDC_Discard = ( VDC_SetPosition + 1 ), |
| 90 | + VDC_Flush = ( VDC_Discard + 1 ), |
| 91 | + VDC_Snapshot = ( VDC_Flush + 1 ), |
| 92 | + VDC_MountSnapshot = ( VDC_Snapshot + 1 ), |
| 93 | + VDC_PrepareToFreeze = ( VDC_MountSnapshot + 1 ), |
| 94 | + VDC_FileInfoBegin = ( VDC_PrepareToFreeze + 1 ), |
| 95 | + VDC_FileInfoEnd = ( VDC_FileInfoBegin + 1 ), |
| 96 | + VDC_GetError = (VDC_FileInfoEnd + 1), |
| 97 | + VDC_Complete = (VDC_GetError + 1)}; |
| 98 | + |
| 99 | +enum VDWhence |
| 100 | +{ VDC_Beginning = 0, |
| 101 | + VDC_Current = ( VDC_Beginning + 1 ), |
| 102 | + VDC_End = ( VDC_Current + 1 )}; |
| 103 | + |
| 104 | +struct VDC_Command |
| 105 | +{ |
| 106 | + int32_t commandCode; |
| 107 | + int32_t size; |
| 108 | + int64_t position; |
| 109 | + uint8_t* buffer; |
| 110 | +}; |
| 111 | + |
| 112 | +struct VDS_Command |
| 113 | +{ |
| 114 | + int32_t commandCode; |
| 115 | + int32_t size; |
| 116 | + int64_t inPosition; |
| 117 | + int64_t outPosition; |
| 118 | + uint8_t* buffer; |
| 119 | + uint8_t* completionRoutine; |
| 120 | + uint8_t* completionContext; |
| 121 | + int32_t completionCode; |
| 122 | + int32_t bytesTransferred; |
| 123 | +}; |
| 124 | + |
| 125 | +//---------------------------------------------------------------------------- |
| 126 | +// NAME: ClientVirtualDevice |
| 127 | +// |
| 128 | +// PURPOSE: |
| 129 | +// |
| 130 | +// Implement the ClientVirtualDevice component. |
| 131 | +// |
| 132 | +class CVDS; |
| 133 | +class CVD; |
| 134 | +class ClientVirtualDeviceSet; |
| 135 | + |
| 136 | +class ClientVirtualDevice |
| 137 | +{ |
| 138 | +public: |
| 139 | + ClientVirtualDevice(); |
| 140 | + |
| 141 | + ~ClientVirtualDevice(); |
| 142 | + |
| 143 | + int |
| 144 | + GetCommand( |
| 145 | + time_t timeOut, |
| 146 | + VDC_Command** ppCmd); |
| 147 | + |
| 148 | + int |
| 149 | + CompleteCommand( |
| 150 | + VDC_Command* pCmd, |
| 151 | + int completionCode, |
| 152 | + unsigned long bytesTransferred, |
| 153 | + int64_t position); |
| 154 | + |
| 155 | +private: |
| 156 | + CVD* cvd; |
| 157 | + friend class ClientVirtualDeviceSet; |
| 158 | +}; |
| 159 | + |
| 160 | +//---------------------------------------------------------------------------- |
| 161 | +// NAME: ClientVirtualDeviceSet |
| 162 | +// |
| 163 | +// PURPOSE: |
| 164 | +// |
| 165 | +// Implement the ClientVirtualDeviceSet component. |
| 166 | +// |
| 167 | + |
| 168 | +class ClientVirtualDeviceSet |
| 169 | +{ |
| 170 | +public: |
| 171 | + int |
| 172 | + Create( |
| 173 | + char* name, |
| 174 | + VDConfig* cfg); |
| 175 | + |
| 176 | + int |
| 177 | + GetConfiguration( |
| 178 | + time_t timeout, |
| 179 | + VDConfig* cfg); |
| 180 | + |
| 181 | + int |
| 182 | + OpenDevice( |
| 183 | + char* name, |
| 184 | + ClientVirtualDevice** ppVirtualDevice); |
| 185 | + |
| 186 | + int |
| 187 | + Close(); |
| 188 | + |
| 189 | + int |
| 190 | + SignalAbort(); |
| 191 | + |
| 192 | + int |
| 193 | + OpenInSecondary( |
| 194 | + char* setName); |
| 195 | + |
| 196 | + int |
| 197 | + GetBufferHandle( |
| 198 | + uint8_t* pBuffer, |
| 199 | + unsigned int* pBufferHandle); |
| 200 | + |
| 201 | + int |
| 202 | + MapBufferHandle( |
| 203 | + int dwBuffer, |
| 204 | + uint8_t** ppBuffer); |
| 205 | + |
| 206 | + void |
| 207 | + RegisterDeviceClosed(); |
| 208 | + |
| 209 | + ClientVirtualDeviceSet (); |
| 210 | + ~ClientVirtualDeviceSet (); |
| 211 | + |
| 212 | +private: |
| 213 | + CVDS* cvds; |
| 214 | +}; |
| 215 | + |
| 216 | +#pragma pack(pop, _vdi_h_) |
| 217 | + |
| 218 | +#ifdef __cplusplus |
| 219 | +} |
| 220 | +#endif |
| 221 | + |
| 222 | +#endif |
0 commit comments