1 | /* $Id: HBDMgmt.h 99739 2023-05-11 01:01:08Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox storage devices: Host block device management API.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2015-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef VBOX_INCLUDED_SRC_Storage_HBDMgmt_h
|
---|
29 | #define VBOX_INCLUDED_SRC_Storage_HBDMgmt_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include <VBox/cdefs.h>
|
---|
35 |
|
---|
36 | RT_C_DECLS_BEGIN
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Opaque host block device manager.
|
---|
40 | */
|
---|
41 | typedef struct HBDMGRINT *HBDMGR;
|
---|
42 | /** Pointer to a block device manager. */
|
---|
43 | typedef HBDMGR *PHBDMGR;
|
---|
44 |
|
---|
45 | /* NIL HBD manager handle. */
|
---|
46 | #define NIL_HBDMGR ((HBDMGR)0)
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Creates host block device manager.
|
---|
50 | *
|
---|
51 | * @returns VBox status code.
|
---|
52 | * @param phHbdMgr Where to store the handle to the block device manager on success.
|
---|
53 | */
|
---|
54 | DECLHIDDEN(int) HBDMgrCreate(PHBDMGR phHbdMgr);
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Destroys the given block device manager unclaiming all managed block devices.
|
---|
58 | *
|
---|
59 | * @param hHbdMgr The block device manager.
|
---|
60 | */
|
---|
61 | DECLHIDDEN(void) HBDMgrDestroy(HBDMGR hHbdMgr);
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * Returns whether a given filename resembles a block device which can
|
---|
65 | * be managed by this API.
|
---|
66 | *
|
---|
67 | * @returns true if the given filename point to a block device manageable
|
---|
68 | * by the given manager
|
---|
69 | * false otherwise.
|
---|
70 | * @param pszFilename The block device to check.
|
---|
71 | */
|
---|
72 | DECLHIDDEN(bool) HBDMgrIsBlockDevice(const char *pszFilename);
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * Prepares the given block device for use by unmounting and claiming it for exclusive use.
|
---|
76 | *
|
---|
77 | * @returns VBox status code.
|
---|
78 | * @param hHbdMgr The block device manager.
|
---|
79 | * @param pszFilename The block device to claim.
|
---|
80 | */
|
---|
81 | DECLHIDDEN(int) HBDMgrClaimBlockDevice(HBDMGR hHbdMgr, const char *pszFilename);
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * Unclaims the given block device.
|
---|
85 | *
|
---|
86 | * @returns VBox status code.
|
---|
87 | * @param hHbdMgr The block device manager.
|
---|
88 | * @param pszFilename The block device to unclaim.
|
---|
89 | */
|
---|
90 | DECLHIDDEN(int) HBDMgrUnclaimBlockDevice(HBDMGR hHbdMgr, const char *pszFilename);
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * Returns whether the given block device is claimed by the manager.
|
---|
94 | *
|
---|
95 | * @returns true if the block device is claimed, false otherwisw.
|
---|
96 | * @param hHbdMgr The block device manager.
|
---|
97 | * @param pszFilename The block device to check.
|
---|
98 | */
|
---|
99 | DECLHIDDEN(bool) HBDMgrIsBlockDeviceClaimed(HBDMGR hHbdMgr, const char *pszFilename);
|
---|
100 |
|
---|
101 | RT_C_DECLS_END
|
---|
102 |
|
---|
103 | #endif /* !VBOX_INCLUDED_SRC_Storage_HBDMgmt_h */
|
---|