VirtualBox

source: vbox/trunk/src/VBox/Storage/testcase/VDMemDisk.h@ 93231

Last change on this file since 93231 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/** @file
2 *
3 * VBox HDD container test utility, memory disk/file.
4 */
5
6/*
7 * Copyright (C) 2011-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef VBOX_INCLUDED_SRC_testcase_VDMemDisk_h
19#define VBOX_INCLUDED_SRC_testcase_VDMemDisk_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <iprt/sg.h>
25
26/** Handle to the a memory disk. */
27typedef struct VDMEMDISK *PVDMEMDISK;
28/** Pointer to a memory disk handle. */
29typedef PVDMEMDISK *PPVDMEMDISK;
30
31/**
32 * Creates a new memory disk with the given size.
33 *
34 * @returns VBOX status code.
35 *
36 * @param ppMemDisk Where to store the memory disk handle.
37 * @param cbSize Size of the disk if it is fixed.
38 * If 0 the disk grows when it is written to
39 * and the size can be changed with
40 * VDMemDiskSetSize().
41 */
42int VDMemDiskCreate(PPVDMEMDISK ppMemDisk, uint64_t cbSize);
43
44/**
45 * Destroys a memory disk.
46 *
47 * @returns nothing.
48 *
49 * @param pMemDisk The memory disk to destroy.
50 */
51void VDMemDiskDestroy(PVDMEMDISK pMemDisk);
52
53/**
54 * Writes the specified amount of data from the S/G buffer at
55 * the given offset.
56 *
57 * @returns VBox status code.
58 *
59 * @param pMemDisk The memory disk handle.
60 * @param off Where to start writing to.
61 * @param cbWrite How many bytes to write.
62 * @param pSgBuf The S/G buffer to write from.
63 */
64int VDMemDiskWrite(PVDMEMDISK pMemDisk, uint64_t off, size_t cbWrite, PRTSGBUF pSgBuf);
65
66/**
67 * Reads the specified amount of data into the S/G buffer
68 * starting from the given offset.
69 *
70 * @returns VBox status code.
71 *
72 * @param pMemDisk The memory disk handle.
73 * @param off Where to start reading from.
74 * @param cbRead The amount of bytes to read.
75 * @param pSgBuf The S/G buffer to read into.
76 */
77int VDMemDiskRead(PVDMEMDISK pMemDisk, uint64_t off, size_t cbRead, PRTSGBUF pSgBuf);
78
79/**
80 * Sets the size of the memory disk.
81 *
82 * @returns VBox status code.
83 *
84 * @param pMemDisk The memory disk handle.
85 * @param cbSize The new size to set.
86 */
87int VDMemDiskSetSize(PVDMEMDISK pMemDisk, uint64_t cbSize);
88
89/**
90 * Gets the current size of the memory disk.
91 *
92 * @returns VBox status code.
93 *
94 * @param pMemDisk The memory disk handle.
95 * @param pcbSize Where to store the size of the memory
96 * disk.
97 */
98int VDMemDiskGetSize(PVDMEMDISK pMemDisk, uint64_t *pcbSize);
99
100/**
101 * Dumps the memory disk to a file.
102 *
103 * @returns VBox status code.
104 *
105 * @param pMemDisk The memory disk handle.
106 * @param pcszFilename Where to dump the content.
107 */
108int VDMemDiskWriteToFile(PVDMEMDISK pMemDisk, const char *pcszFilename);
109
110/**
111 * Reads the content of a file into the given memory disk.
112 * All data stored in the memory disk will be overwritten.
113 *
114 * @returns VBox status code.
115 *
116 * @param pMemDisk The memory disk handle.
117 * @param pcszFilename The file to load from.
118 */
119int VDMemDiskReadFromFile(PVDMEMDISK pMemDisk, const char *pcszFilename);
120
121/**
122 * Compares the given range of the memory disk with a provided S/G buffer.
123 *
124 * @returns whatever memcmp returns.
125 *
126 * @param pMemDisk The memory disk handle.
127 * @param off Where to start comparing.
128 * @param cbCmp How many bytes to compare.
129 * @param pSgBuf The S/G buffer to compare with.
130 */
131int VDMemDiskCmp(PVDMEMDISK pMemDisk, uint64_t off, size_t cbCmp, PRTSGBUF pSgBuf);
132
133#endif /* !VBOX_INCLUDED_SRC_testcase_VDMemDisk_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette