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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
|
/* $Id: RawHDDCore.cpp $ */
/** @file
* RawHDDCore - Raw Disk image, Core Code.
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_VD_RAW
#include <VBox/VBoxHDD-Plugin.h>
#include <VBox/err.h>
#include <VBox/log.h>
#include <iprt/assert.h>
#include <iprt/alloc.h>
#include <iprt/file.h>
/*******************************************************************************
* Constants And Macros, Structures and Typedefs *
*******************************************************************************/
/**
* Raw image data structure.
*/
typedef struct RAWIMAGE
{
/** Base image name. */
const char *pszFilename;
#ifndef VBOX_WITH_NEW_IO_CODE
/** File descriptor. */
RTFILE File;
#else
/** Storage handle. */
PVDIOSTORAGE pStorage;
/** I/O interface. */
PVDINTERFACE pInterfaceIO;
/** Async I/O interface callbacks. */
PVDINTERFACEIO pInterfaceIOCallbacks;
#endif
/** Pointer to the per-disk VD interface list. */
PVDINTERFACE pVDIfsDisk;
/** Pointer to the per-image VD interface list. */
PVDINTERFACE pVDIfsImage;
/** Error callback. */
PVDINTERFACE pInterfaceError;
/** Opaque data for error callback. */
PVDINTERFACEERROR pInterfaceErrorCallbacks;
/** Open flags passed by VBoxHD layer. */
unsigned uOpenFlags;
/** Image flags defined during creation or determined during open. */
unsigned uImageFlags;
/** Total size of the image. */
uint64_t cbSize;
/** Physical geometry of this image. */
PDMMEDIAGEOMETRY PCHSGeometry;
/** Logical geometry of this image. */
PDMMEDIAGEOMETRY LCHSGeometry;
} RAWIMAGE, *PRAWIMAGE;
/*******************************************************************************
* Static Variables *
*******************************************************************************/
/** NULL-terminated array of supported file extensions. */
static const char *const s_apszRawFileExtensions[] =
{
/** @todo At the monment this backend doesn't claim any extensions, but it might
* be useful to add a few later. However this needs careful testing, as the
* CheckIfValid function never returns success. */
NULL
};
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
static int rawFlushImage(PRAWIMAGE pImage);
static void rawFreeImage(PRAWIMAGE pImage, bool fDelete);
/**
* Internal: signal an error to the frontend.
*/
DECLINLINE(int) rawError(PRAWIMAGE pImage, int rc, RT_SRC_POS_DECL,
const char *pszFormat, ...)
{
va_list va;
va_start(va, pszFormat);
if (pImage->pInterfaceError)
pImage->pInterfaceErrorCallbacks->pfnError(pImage->pInterfaceError->pvUser, rc, RT_SRC_POS_ARGS,
pszFormat, va);
va_end(va);
return rc;
}
static int rawFileOpen(PRAWIMAGE pImage, bool fReadonly, bool fCreate)
{
int rc = VINF_SUCCESS;
AssertMsg(!(fReadonly && fCreate), ("Image can't be opened readonly while being created\n"));
#ifndef VBOX_WITH_NEW_IO_CODE
uint32_t fOpen = fReadonly ? RTFILE_O_READ | RTFILE_O_DENY_NONE
: RTFILE_O_READWRITE | RTFILE_O_DENY_WRITE;
if (fCreate)
fOpen |= RTFILE_O_CREATE;
else
fOpen |= RTFILE_O_OPEN;
rc = RTFileOpen(&pImage->File, pImage->pszFilename, fOpen);
#else
unsigned uOpenFlags = fReadonly ? VD_INTERFACEASYNCIO_OPEN_FLAGS_READONLY : 0;
if (fCreate)
uOpenFlags |= VD_INTERFACEASYNCIO_OPEN_FLAGS_CREATE;
rc = pImage->pInterfaceIOCallbacks->pfnOpen(pImage->pInterfaceIO->pvUser,
pImage->pszFilename,
uOpenFlags,
&pImage->pStorage);
#endif
return rc;
}
static int rawFileClose(PRAWIMAGE pImage)
{
int rc = VINF_SUCCESS;
#ifndef VBOX_WITH_NEW_IO_CODE
if (pImage->File != NIL_RTFILE)
rc = RTFileClose(pImage->File);
pImage->File = NIL_RTFILE;
#else
if (pImage->pStorage)
rc = pImage->pInterfaceIOCallbacks->pfnClose(pImage->pInterfaceIO->pvUser,
pImage->pStorage);
pImage->pStorage = NULL;
#endif
return rc;
}
static int rawFileFlushSync(PRAWIMAGE pImage)
{
int rc = VINF_SUCCESS;
#ifndef VBOX_WITH_NEW_IO_CODE
rc = RTFileFlush(pImage->File);
#else
rc = pImage->pInterfaceIOCallbacks->pfnFlushSync(pImage->pInterfaceIO->pvUser,
pImage->pStorage);
#endif
return rc;
}
static int rawFileGetSize(PRAWIMAGE pImage, uint64_t *pcbSize)
{
int rc = VINF_SUCCESS;
#ifndef VBOX_WITH_NEW_IO_CODE
rc = RTFileGetSize(pImage->File, pcbSize);
#else
rc = pImage->pInterfaceIOCallbacks->pfnGetSize(pImage->pInterfaceIO->pvUser,
pImage->pStorage,
pcbSize);
#endif
return rc;
}
static int rawFileSetSize(PRAWIMAGE pImage, uint64_t cbSize)
{
int rc = VINF_SUCCESS;
#ifndef VBOX_WITH_NEW_IO_CODE
rc = RTFileSetSize(pImage->File, cbSize);
#else
rc = pImage->pInterfaceIOCallbacks->pfnSetSize(pImage->pInterfaceIO->pvUser,
pImage->pStorage,
cbSize);
#endif
return rc;
}
static int rawFileWriteSync(PRAWIMAGE pImage, uint64_t off, const void *pcvBuf, size_t cbWrite, size_t *pcbWritten)
{
int rc = VINF_SUCCESS;
#ifndef VBOX_WITH_NEW_IO_CODE
rc = RTFileWriteAt(pImage->File, off, pcvBuf, cbWrite, pcbWritten);
#else
rc = pImage->pInterfaceIOCallbacks->pfnWriteSync(pImage->pInterfaceIO->pvUser,
pImage->pStorage,
off, cbWrite, pcvBuf,
pcbWritten);
#endif
return rc;
}
static int rawFileReadSync(PRAWIMAGE pImage, uint64_t off, void *pvBuf, size_t cbRead, size_t *pcbRead)
{
int rc = VINF_SUCCESS;
#ifndef VBOX_WITH_NEW_IO_CODE
rc = RTFileReadAt(pImage->File, off, pvBuf, cbRead, pcbRead);
#else
rc = pImage->pInterfaceIOCallbacks->pfnReadSync(pImage->pInterfaceIO->pvUser,
pImage->pStorage,
off, cbRead, pvBuf,
pcbRead);
#endif
return rc;
}
static bool rawFileOpened(PRAWIMAGE pImage)
{
#ifndef VBOX_WITH_NEW_IO_CODE
return pImage->File != NIL_RTFILE;
#else
return pImage->pStorage != NULL;
#endif
}
/**
* Internal: Open an image, constructing all necessary data structures.
*/
static int rawOpenImage(PRAWIMAGE pImage, unsigned uOpenFlags)
{
int rc;
if (uOpenFlags & VD_OPEN_FLAGS_ASYNC_IO)
return VERR_NOT_SUPPORTED;
pImage->uOpenFlags = uOpenFlags;
pImage->pInterfaceError = VDInterfaceGet(pImage->pVDIfsDisk, VDINTERFACETYPE_ERROR);
if (pImage->pInterfaceError)
pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError);
#ifdef VBOX_WITH_NEW_IO_CODE
/* Try to get I/O interface. */
pImage->pInterfaceIO = VDInterfaceGet(pImage->pVDIfsImage, VDINTERFACETYPE_IO);
AssertPtr(pImage->pInterfaceIO);
pImage->pInterfaceIOCallbacks = VDGetInterfaceIO(pImage->pInterfaceIO);
AssertPtr(pImage->pInterfaceIOCallbacks);
#endif
/*
* Open the image.
*/
rc = rawFileOpen(pImage, !!(uOpenFlags & VD_OPEN_FLAGS_READONLY), false);
if (RT_FAILURE(rc))
{
/* Do NOT signal an appropriate error here, as the VD layer has the
* choice of retrying the open if it failed. */
goto out;
}
rc = rawFileGetSize(pImage, &pImage->cbSize);
if (RT_FAILURE(rc))
goto out;
if (pImage->cbSize % 512)
{
rc = VERR_VD_RAW_INVALID_HEADER;
goto out;
}
pImage->uImageFlags |= VD_IMAGE_FLAGS_FIXED;
out:
if (RT_FAILURE(rc))
rawFreeImage(pImage, false);
return rc;
}
/**
* Internal: Create a raw image.
*/
static int rawCreateImage(PRAWIMAGE pImage, uint64_t cbSize,
unsigned uImageFlags, const char *pszComment,
PCPDMMEDIAGEOMETRY pPCHSGeometry,
PCPDMMEDIAGEOMETRY pLCHSGeometry,
PFNVDPROGRESS pfnProgress, void *pvUser,
unsigned uPercentStart, unsigned uPercentSpan)
{
int rc;
RTFOFF cbFree = 0;
uint64_t uOff;
size_t cbBuf = 128 * _1K;
void *pvBuf = NULL;
if (uImageFlags & VD_IMAGE_FLAGS_DIFF)
{
rc = rawError(pImage, VERR_VD_RAW_INVALID_TYPE, RT_SRC_POS, N_("Raw: cannot create diff image '%s'"), pImage->pszFilename);
goto out;
}
uImageFlags |= VD_IMAGE_FLAGS_FIXED;
pImage->uImageFlags = uImageFlags;
pImage->PCHSGeometry = *pPCHSGeometry;
pImage->LCHSGeometry = *pLCHSGeometry;
pImage->pInterfaceError = VDInterfaceGet(pImage->pVDIfsDisk, VDINTERFACETYPE_ERROR);
if (pImage->pInterfaceError)
pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError);
#ifdef VBOX_WITH_NEW_IO_CODE
/* Try to get async I/O interface. */
pImage->pInterfaceIO = VDInterfaceGet(pImage->pVDIfsImage, VDINTERFACETYPE_IO);
AssertPtr(pImage->pInterfaceIO);
pImage->pInterfaceIOCallbacks = VDGetInterfaceIO(pImage->pInterfaceIO);
AssertPtr(pImage->pInterfaceIOCallbacks);
#endif
/* Create image file. */
rc = rawFileOpen(pImage, false, true);
if (RT_FAILURE(rc))
{
rc = rawError(pImage, rc, RT_SRC_POS, N_("Raw: cannot create image '%s'"), pImage->pszFilename);
goto out;
}
/* Check the free space on the disk and leave early if there is not
* sufficient space available. */
rc = RTFsQuerySizes(pImage->pszFilename, NULL, &cbFree, NULL, NULL);
if (RT_SUCCESS(rc) /* ignore errors */ && ((uint64_t)cbFree < cbSize))
{
rc = rawError(pImage, VERR_DISK_FULL, RT_SRC_POS, N_("Raw: disk would overflow creating image '%s'"), pImage->pszFilename);
goto out;
}
/* Allocate & commit whole file if fixed image, it must be more
* effective than expanding file by write operations. */
rc = rawFileSetSize(pImage, cbSize);
if (RT_FAILURE(rc))
{
rc = rawError(pImage, rc, RT_SRC_POS, N_("Raw: setting image size failed for '%s'"), pImage->pszFilename);
goto out;
}
/* Fill image with zeroes. We do this for every fixed-size image since on
* some systems (for example Windows Vista), it takes ages to write a block
* near the end of a sparse file and the guest could complain about an ATA
* timeout. */
pvBuf = RTMemTmpAllocZ(cbBuf);
if (!pvBuf)
{
rc = VERR_NO_MEMORY;
goto out;
}
uOff = 0;
/* Write data to all image blocks. */
while (uOff < cbSize)
{
unsigned cbChunk = (unsigned)RT_MIN(cbSize, cbBuf);
rc = rawFileWriteSync(pImage, uOff, pvBuf, cbChunk, NULL);
if (RT_FAILURE(rc))
{
rc = rawError(pImage, rc, RT_SRC_POS, N_("Raw: writing block failed for '%s'"), pImage->pszFilename);
goto out;
}
uOff += cbChunk;
if (pfnProgress)
{
rc = pfnProgress(pvUser,
uPercentStart + uOff * uPercentSpan * 98 / (cbSize * 100));
if (RT_FAILURE(rc))
goto out;
}
}
RTMemTmpFree(pvBuf);
if (RT_SUCCESS(rc) && pfnProgress)
pfnProgress(pvUser, uPercentStart + uPercentSpan * 98 / 100);
pImage->cbSize = cbSize;
rc = rawFlushImage(pImage);
out:
if (RT_SUCCESS(rc) && pfnProgress)
pfnProgress(pvUser, uPercentStart + uPercentSpan);
if (RT_FAILURE(rc))
rawFreeImage(pImage, rc != VERR_ALREADY_EXISTS);
return rc;
}
/**
* Internal. Free all allocated space for representing an image, and optionally
* delete the image from disk.
*/
static void rawFreeImage(PRAWIMAGE pImage, bool fDelete)
{
Assert(pImage);
if (rawFileOpened(pImage))
{
if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
rawFlushImage(pImage);
rawFileClose(pImage);
}
if (fDelete && pImage->pszFilename)
RTFileDelete(pImage->pszFilename);
}
/**
* Internal. Flush image data to disk.
*/
static int rawFlushImage(PRAWIMAGE pImage)
{
int rc = VINF_SUCCESS;
if ( rawFileOpened(pImage)
&& !(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
rc = rawFileFlushSync(pImage);
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnCheckIfValid */
static int rawCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk)
{
LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename));
int rc = VINF_SUCCESS;
if ( !VALID_PTR(pszFilename)
|| !*pszFilename)
{
rc = VERR_INVALID_PARAMETER;
goto out;
}
/* Always return failure, to avoid opening everything as a raw image. */
rc = VERR_VD_RAW_INVALID_HEADER;
out:
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnOpen */
static int rawOpen(const char *pszFilename, unsigned uOpenFlags,
PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
void **ppBackendData)
{
LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData));
int rc;
PRAWIMAGE pImage;
/* Check open flags. All valid flags are supported. */
if (uOpenFlags & ~VD_OPEN_FLAGS_MASK)
{
rc = VERR_INVALID_PARAMETER;
goto out;
}
/* Check remaining arguments. */
if ( !VALID_PTR(pszFilename)
|| !*pszFilename)
{
rc = VERR_INVALID_PARAMETER;
goto out;
}
pImage = (PRAWIMAGE)RTMemAllocZ(sizeof(RAWIMAGE));
if (!pImage)
{
rc = VERR_NO_MEMORY;
goto out;
}
pImage->pszFilename = pszFilename;
#ifndef VBOX_WITH_NEW_IO_CODE
pImage->File = NIL_RTFILE;
#else
pImage->pStorage = NULL;
#endif
pImage->pVDIfsDisk = pVDIfsDisk;
pImage->pVDIfsImage = pVDIfsImage;
rc = rawOpenImage(pImage, uOpenFlags);
if (RT_SUCCESS(rc))
*ppBackendData = pImage;
else
RTMemFree(pImage);
out:
LogFlowFunc(("returns %Rrc (pBackendData=%#p)\n", rc, *ppBackendData));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnCreate */
static int rawCreate(const char *pszFilename, uint64_t cbSize,
unsigned uImageFlags, const char *pszComment,
PCPDMMEDIAGEOMETRY pPCHSGeometry,
PCPDMMEDIAGEOMETRY pLCHSGeometry, PCRTUUID pUuid,
unsigned uOpenFlags, unsigned uPercentStart,
unsigned uPercentSpan, PVDINTERFACE pVDIfsDisk,
PVDINTERFACE pVDIfsImage, PVDINTERFACE pVDIfsOperation,
void **ppBackendData)
{
LogFlowFunc(("pszFilename=\"%s\" cbSize=%llu uImageFlags=%#x pszComment=\"%s\" pPCHSGeometry=%#p pLCHSGeometry=%#p Uuid=%RTuuid uOpenFlags=%#x uPercentStart=%u uPercentSpan=%u pVDIfsDisk=%#p pVDIfsImage=%#p pVDIfsOperation=%#p ppBackendData=%#p", pszFilename, cbSize, uImageFlags, pszComment, pPCHSGeometry, pLCHSGeometry, pUuid, uOpenFlags, uPercentStart, uPercentSpan, pVDIfsDisk, pVDIfsImage, pVDIfsOperation, ppBackendData));
int rc;
PRAWIMAGE pImage;
PFNVDPROGRESS pfnProgress = NULL;
void *pvUser = NULL;
PVDINTERFACE pIfProgress = VDInterfaceGet(pVDIfsOperation,
VDINTERFACETYPE_PROGRESS);
PVDINTERFACEPROGRESS pCbProgress = NULL;
if (pIfProgress)
{
pCbProgress = VDGetInterfaceProgress(pIfProgress);
if (pCbProgress)
pfnProgress = pCbProgress->pfnProgress;
pvUser = pIfProgress->pvUser;
}
/* Check open flags. All valid flags are supported. */
if (uOpenFlags & ~VD_OPEN_FLAGS_MASK)
{
rc = VERR_INVALID_PARAMETER;
goto out;
}
/* Check remaining arguments. */
if ( !VALID_PTR(pszFilename)
|| !*pszFilename
|| !VALID_PTR(pPCHSGeometry)
|| !VALID_PTR(pLCHSGeometry))
{
rc = VERR_INVALID_PARAMETER;
goto out;
}
pImage = (PRAWIMAGE)RTMemAllocZ(sizeof(RAWIMAGE));
if (!pImage)
{
rc = VERR_NO_MEMORY;
goto out;
}
pImage->pszFilename = pszFilename;
#ifndef VBOX_WITH_NEW_IO_CODE
pImage->File = NIL_RTFILE;
#else
pImage->pStorage = NULL;
#endif
pImage->pVDIfsDisk = pVDIfsDisk;
pImage->pVDIfsImage = pVDIfsImage;
rc = rawCreateImage(pImage, cbSize, uImageFlags, pszComment,
pPCHSGeometry, pLCHSGeometry,
pfnProgress, pvUser, uPercentStart, uPercentSpan);
if (RT_SUCCESS(rc))
{
/* So far the image is opened in read/write mode. Make sure the
* image is opened in read-only mode if the caller requested that. */
if (uOpenFlags & VD_OPEN_FLAGS_READONLY)
{
rawFreeImage(pImage, false);
rc = rawOpenImage(pImage, uOpenFlags);
if (RT_FAILURE(rc))
{
RTMemFree(pImage);
goto out;
}
}
*ppBackendData = pImage;
}
else
RTMemFree(pImage);
out:
LogFlowFunc(("returns %Rrc (pBackendData=%#p)\n", rc, *ppBackendData));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnRename */
static int rawRename(void *pBackendData, const char *pszFilename)
{
LogFlowFunc(("pBackendData=%#p pszFilename=%#p\n", pBackendData, pszFilename));
int rc = VERR_NOT_IMPLEMENTED;
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnClose */
static int rawClose(void *pBackendData, bool fDelete)
{
LogFlowFunc(("pBackendData=%#p fDelete=%d\n", pBackendData, fDelete));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc = VINF_SUCCESS;
/* Freeing a never allocated image (e.g. because the open failed) is
* not signalled as an error. After all nothing bad happens. */
if (pImage)
{
rawFreeImage(pImage, fDelete);
RTMemFree(pImage);
}
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnRead */
static int rawRead(void *pBackendData, uint64_t uOffset, void *pvBuf,
size_t cbToRead, size_t *pcbActuallyRead)
{
LogFlowFunc(("pBackendData=%#p uOffset=%llu pvBuf=%#p cbToRead=%zu pcbActuallyRead=%#p\n", pBackendData, uOffset, pvBuf, cbToRead, pcbActuallyRead));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
Assert(uOffset % 512 == 0);
Assert(cbToRead % 512 == 0);
if ( uOffset + cbToRead > pImage->cbSize
|| cbToRead == 0)
{
rc = VERR_INVALID_PARAMETER;
goto out;
}
rc = rawFileReadSync(pImage, uOffset, pvBuf, cbToRead, NULL);
*pcbActuallyRead = cbToRead;
out:
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnWrite */
static int rawWrite(void *pBackendData, uint64_t uOffset, const void *pvBuf,
size_t cbToWrite, size_t *pcbWriteProcess,
size_t *pcbPreRead, size_t *pcbPostRead, unsigned fWrite)
{
LogFlowFunc(("pBackendData=%#p uOffset=%llu pvBuf=%#p cbToWrite=%zu pcbWriteProcess=%#p pcbPreRead=%#p pcbPostRead=%#p\n", pBackendData, uOffset, pvBuf, cbToWrite, pcbWriteProcess, pcbPreRead, pcbPostRead));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
Assert(uOffset % 512 == 0);
Assert(cbToWrite % 512 == 0);
if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
{
rc = VERR_VD_IMAGE_READ_ONLY;
goto out;
}
if ( uOffset + cbToWrite > pImage->cbSize
|| cbToWrite == 0)
{
rc = VERR_INVALID_PARAMETER;
goto out;
}
rc = rawFileWriteSync(pImage, uOffset, pvBuf, cbToWrite, NULL);
if (pcbWriteProcess)
*pcbWriteProcess = cbToWrite;
out:
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnFlush */
static int rawFlush(void *pBackendData)
{
LogFlowFunc(("pBackendData=%#p\n", pBackendData));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
rc = rawFlushImage(pImage);
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnGetVersion */
static unsigned rawGetVersion(void *pBackendData)
{
LogFlowFunc(("pBackendData=%#p\n", pBackendData));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
Assert(pImage);
if (pImage)
return 1;
else
return 0;
}
/** @copydoc VBOXHDDBACKEND::pfnGetSize */
static uint64_t rawGetSize(void *pBackendData)
{
LogFlowFunc(("pBackendData=%#p\n", pBackendData));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
Assert(pImage);
if (pImage)
return pImage->cbSize;
else
return 0;
}
/** @copydoc VBOXHDDBACKEND::pfnGetFileSize */
static uint64_t rawGetFileSize(void *pBackendData)
{
LogFlowFunc(("pBackendData=%#p\n", pBackendData));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
uint64_t cb = 0;
Assert(pImage);
if (pImage)
{
uint64_t cbFile;
if (rawFileOpened(pImage))
{
int rc = rawFileGetSize(pImage, &cbFile);
if (RT_SUCCESS(rc))
cb += cbFile;
}
}
LogFlowFunc(("returns %lld\n", cb));
return cb;
}
/** @copydoc VBOXHDDBACKEND::pfnGetPCHSGeometry */
static int rawGetPCHSGeometry(void *pBackendData,
PPDMMEDIAGEOMETRY pPCHSGeometry)
{
LogFlowFunc(("pBackendData=%#p pPCHSGeometry=%#p\n", pBackendData, pPCHSGeometry));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
if (pImage)
{
if (pImage->PCHSGeometry.cCylinders)
{
*pPCHSGeometry = pImage->PCHSGeometry;
rc = VINF_SUCCESS;
}
else
rc = VERR_VD_GEOMETRY_NOT_SET;
}
else
rc = VERR_VD_NOT_OPENED;
LogFlowFunc(("returns %Rrc (PCHS=%u/%u/%u)\n", rc, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnSetPCHSGeometry */
static int rawSetPCHSGeometry(void *pBackendData,
PCPDMMEDIAGEOMETRY pPCHSGeometry)
{
LogFlowFunc(("pBackendData=%#p pPCHSGeometry=%#p PCHS=%u/%u/%u\n", pBackendData, pPCHSGeometry, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
if (pImage)
{
if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
{
rc = VERR_VD_IMAGE_READ_ONLY;
goto out;
}
pImage->PCHSGeometry = *pPCHSGeometry;
rc = VINF_SUCCESS;
}
else
rc = VERR_VD_NOT_OPENED;
out:
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnGetLCHSGeometry */
static int rawGetLCHSGeometry(void *pBackendData,
PPDMMEDIAGEOMETRY pLCHSGeometry)
{
LogFlowFunc(("pBackendData=%#p pLCHSGeometry=%#p\n", pBackendData, pLCHSGeometry));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
if (pImage)
{
if (pImage->LCHSGeometry.cCylinders)
{
*pLCHSGeometry = pImage->LCHSGeometry;
rc = VINF_SUCCESS;
}
else
rc = VERR_VD_GEOMETRY_NOT_SET;
}
else
rc = VERR_VD_NOT_OPENED;
LogFlowFunc(("returns %Rrc (LCHS=%u/%u/%u)\n", rc, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnSetLCHSGeometry */
static int rawSetLCHSGeometry(void *pBackendData,
PCPDMMEDIAGEOMETRY pLCHSGeometry)
{
LogFlowFunc(("pBackendData=%#p pLCHSGeometry=%#p LCHS=%u/%u/%u\n", pBackendData, pLCHSGeometry, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
if (pImage)
{
if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
{
rc = VERR_VD_IMAGE_READ_ONLY;
goto out;
}
pImage->LCHSGeometry = *pLCHSGeometry;
rc = VINF_SUCCESS;
}
else
rc = VERR_VD_NOT_OPENED;
out:
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnGetImageFlags */
static unsigned rawGetImageFlags(void *pBackendData)
{
LogFlowFunc(("pBackendData=%#p\n", pBackendData));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
unsigned uImageFlags;
Assert(pImage);
if (pImage)
uImageFlags = pImage->uImageFlags;
else
uImageFlags = 0;
LogFlowFunc(("returns %#x\n", uImageFlags));
return uImageFlags;
}
/** @copydoc VBOXHDDBACKEND::pfnGetOpenFlags */
static unsigned rawGetOpenFlags(void *pBackendData)
{
LogFlowFunc(("pBackendData=%#p\n", pBackendData));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
unsigned uOpenFlags;
Assert(pImage);
if (pImage)
uOpenFlags = pImage->uOpenFlags;
else
uOpenFlags = 0;
LogFlowFunc(("returns %#x\n", uOpenFlags));
return uOpenFlags;
}
/** @copydoc VBOXHDDBACKEND::pfnSetOpenFlags */
static int rawSetOpenFlags(void *pBackendData, unsigned uOpenFlags)
{
LogFlowFunc(("pBackendData=%#p\n uOpenFlags=%#x", pBackendData, uOpenFlags));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
/* Image must be opened and the new flags must be valid. Just readonly and
* info flags are supported. */
if (!pImage || (uOpenFlags & ~(VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_INFO)))
{
rc = VERR_INVALID_PARAMETER;
goto out;
}
/* Implement this operation via reopening the image. */
rawFreeImage(pImage, false);
rc = rawOpenImage(pImage, uOpenFlags);
out:
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnGetComment */
static int rawGetComment(void *pBackendData, char *pszComment,
size_t cbComment)
{
LogFlowFunc(("pBackendData=%#p pszComment=%#p cbComment=%zu\n", pBackendData, pszComment, cbComment));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
if (pImage)
{
if (pszComment)
*pszComment = '\0';
rc = VINF_SUCCESS;
}
else
rc = VERR_VD_NOT_OPENED;
LogFlowFunc(("returns %Rrc comment='%s'\n", rc, pszComment));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnSetComment */
static int rawSetComment(void *pBackendData, const char *pszComment)
{
LogFlowFunc(("pBackendData=%#p pszComment=\"%s\"\n", pBackendData, pszComment));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
{
rc = VERR_VD_IMAGE_READ_ONLY;
goto out;
}
if (pImage)
rc = VERR_NOT_SUPPORTED;
else
rc = VERR_VD_NOT_OPENED;
out:
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnGetUuid */
static int rawGetUuid(void *pBackendData, PRTUUID pUuid)
{
LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
if (pImage)
rc = VERR_NOT_SUPPORTED;
else
rc = VERR_VD_NOT_OPENED;
LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnSetUuid */
static int rawSetUuid(void *pBackendData, PCRTUUID pUuid)
{
LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
LogFlowFunc(("%RTuuid\n", pUuid));
Assert(pImage);
if (pImage)
{
if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
rc = VERR_NOT_SUPPORTED;
else
rc = VERR_VD_IMAGE_READ_ONLY;
}
else
rc = VERR_VD_NOT_OPENED;
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnGetModificationUuid */
static int rawGetModificationUuid(void *pBackendData, PRTUUID pUuid)
{
LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
if (pImage)
rc = VERR_NOT_SUPPORTED;
else
rc = VERR_VD_NOT_OPENED;
LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnSetModificationUuid */
static int rawSetModificationUuid(void *pBackendData, PCRTUUID pUuid)
{
LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
if (pImage)
{
if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
rc = VERR_NOT_SUPPORTED;
else
rc = VERR_VD_IMAGE_READ_ONLY;
}
else
rc = VERR_VD_NOT_OPENED;
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnGetParentUuid */
static int rawGetParentUuid(void *pBackendData, PRTUUID pUuid)
{
LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
if (pImage)
rc = VERR_NOT_SUPPORTED;
else
rc = VERR_VD_NOT_OPENED;
LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnSetParentUuid */
static int rawSetParentUuid(void *pBackendData, PCRTUUID pUuid)
{
LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
if (pImage)
{
if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
rc = VERR_NOT_SUPPORTED;
else
rc = VERR_VD_IMAGE_READ_ONLY;
}
else
rc = VERR_VD_NOT_OPENED;
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnGetParentModificationUuid */
static int rawGetParentModificationUuid(void *pBackendData, PRTUUID pUuid)
{
LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
if (pImage)
rc = VERR_NOT_SUPPORTED;
else
rc = VERR_VD_NOT_OPENED;
LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnSetParentModificationUuid */
static int rawSetParentModificationUuid(void *pBackendData, PCRTUUID pUuid)
{
LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
int rc;
Assert(pImage);
if (pImage)
{
if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
rc = VERR_NOT_SUPPORTED;
else
rc = VERR_VD_IMAGE_READ_ONLY;
}
else
rc = VERR_VD_NOT_OPENED;
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
/** @copydoc VBOXHDDBACKEND::pfnDump */
static void rawDump(void *pBackendData)
{
PRAWIMAGE pImage = (PRAWIMAGE)pBackendData;
Assert(pImage);
if (pImage)
{
pImage->pInterfaceErrorCallbacks->pfnMessage(pImage->pInterfaceError->pvUser, "Header: Geometry PCHS=%u/%u/%u LCHS=%u/%u/%u cbSector=%llu\n",
pImage->PCHSGeometry.cCylinders, pImage->PCHSGeometry.cHeads, pImage->PCHSGeometry.cSectors,
pImage->LCHSGeometry.cCylinders, pImage->LCHSGeometry.cHeads, pImage->LCHSGeometry.cSectors,
pImage->cbSize / 512);
}
}
static int rawGetTimeStamp(void *pvBackendData, PRTTIMESPEC pTimeStamp)
{
int rc = VERR_NOT_IMPLEMENTED;
LogFlow(("%s: returned %Rrc\n", __FUNCTION__, rc));
return rc;
}
static int rawGetParentTimeStamp(void *pvBackendData, PRTTIMESPEC pTimeStamp)
{
int rc = VERR_NOT_IMPLEMENTED;
LogFlow(("%s: returned %Rrc\n", __FUNCTION__, rc));
return rc;
}
static int rawSetParentTimeStamp(void *pvBackendData, PCRTTIMESPEC pTimeStamp)
{
int rc = VERR_NOT_IMPLEMENTED;
LogFlow(("%s: returned %Rrc\n", __FUNCTION__, rc));
return rc;
}
static int rawGetParentFilename(void *pvBackendData, char **ppszParentFilename)
{
int rc = VERR_NOT_IMPLEMENTED;
LogFlow(("%s: returned %Rrc\n", __FUNCTION__, rc));
return rc;
}
static int rawSetParentFilename(void *pvBackendData, const char *pszParentFilename)
{
int rc = VERR_NOT_IMPLEMENTED;
LogFlow(("%s: returned %Rrc\n", __FUNCTION__, rc));
return rc;
}
static bool rawIsAsyncIOSupported(void *pvBackendData)
{
return true;
}
static int rawAsyncRead(void *pvBackendData, uint64_t uOffset, size_t cbRead,
PVDIOCTX pIoCtx, size_t *pcbActuallyRead)
{
int rc = VINF_SUCCESS;
PRAWIMAGE pImage = (PRAWIMAGE)pvBackendData;
rc = pImage->pInterfaceIOCallbacks->pfnReadUserAsync(pImage->pInterfaceIO->pvUser,
pImage->pStorage,
uOffset, pIoCtx, cbRead);
if (RT_SUCCESS(rc))
*pcbActuallyRead = cbRead;
return rc;
}
static int rawAsyncWrite(void *pvBackendData, uint64_t uOffset, size_t cbWrite,
PVDIOCTX pIoCtx,
size_t *pcbWriteProcess, size_t *pcbPreRead,
size_t *pcbPostRead, unsigned fWrite)
{
int rc = VINF_SUCCESS;
PRAWIMAGE pImage = (PRAWIMAGE)pvBackendData;
rc = pImage->pInterfaceIOCallbacks->pfnWriteUserAsync(pImage->pInterfaceIO->pvUser,
pImage->pStorage,
uOffset, pIoCtx, cbWrite);
if (RT_SUCCESS(rc))
{
*pcbWriteProcess = cbWrite;
*pcbPostRead = 0;
*pcbPreRead = 0;
}
return rc;
}
static int rawAsyncFlush(void *pvBackendData, PVDIOCTX pIoCtx)
{
int rc = VERR_NOT_IMPLEMENTED;
LogFlowFunc(("returns %Rrc\n", rc));
return rc;
}
VBOXHDDBACKEND g_RawBackend =
{
/* pszBackendName */
"raw",
/* cbSize */
sizeof(VBOXHDDBACKEND),
/* uBackendCaps */
VD_CAP_CREATE_FIXED | VD_CAP_FILE | VD_CAP_ASYNC,
/* papszFileExtensions */
s_apszRawFileExtensions,
/* paConfigInfo */
NULL,
/* hPlugin */
NIL_RTLDRMOD,
/* pfnCheckIfValid */
rawCheckIfValid,
/* pfnOpen */
rawOpen,
/* pfnCreate */
rawCreate,
/* pfnRename */
rawRename,
/* pfnClose */
rawClose,
/* pfnRead */
rawRead,
/* pfnWrite */
rawWrite,
/* pfnFlush */
rawFlush,
/* pfnGetVersion */
rawGetVersion,
/* pfnGetSize */
rawGetSize,
/* pfnGetFileSize */
rawGetFileSize,
/* pfnGetPCHSGeometry */
rawGetPCHSGeometry,
/* pfnSetPCHSGeometry */
rawSetPCHSGeometry,
/* pfnGetLCHSGeometry */
rawGetLCHSGeometry,
/* pfnSetLCHSGeometry */
rawSetLCHSGeometry,
/* pfnGetImageFlags */
rawGetImageFlags,
/* pfnGetOpenFlags */
rawGetOpenFlags,
/* pfnSetOpenFlags */
rawSetOpenFlags,
/* pfnGetComment */
rawGetComment,
/* pfnSetComment */
rawSetComment,
/* pfnGetUuid */
rawGetUuid,
/* pfnSetUuid */
rawSetUuid,
/* pfnGetModificationUuid */
rawGetModificationUuid,
/* pfnSetModificationUuid */
rawSetModificationUuid,
/* pfnGetParentUuid */
rawGetParentUuid,
/* pfnSetParentUuid */
rawSetParentUuid,
/* pfnGetParentModificationUuid */
rawGetParentModificationUuid,
/* pfnSetParentModificationUuid */
rawSetParentModificationUuid,
/* pfnDump */
rawDump,
/* pfnGetTimeStamp */
rawGetTimeStamp,
/* pfnGetParentTimeStamp */
rawGetParentTimeStamp,
/* pfnSetParentTimeStamp */
rawSetParentTimeStamp,
/* pfnGetParentFilename */
rawGetParentFilename,
/* pfnSetParentFilename */
rawSetParentFilename,
/* pfnIsAsyncIOSupported */
rawIsAsyncIOSupported,
/* pfnAsyncRead */
rawAsyncRead,
/* pfnAsyncWrite */
rawAsyncWrite,
/* pfnAsyncFlush */
rawAsyncFlush,
/* pfnComposeLocation */
genericFileComposeLocation,
/* pfnComposeName */
genericFileComposeName,
/* pfnCompact */
NULL
};
|