1 | /* $Id: HBDMgmt.h 93115 2022-01-01 11:31:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox storage devices: Host block device management API.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2015-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_Storage_HBDMgmt_h
|
---|
19 | #define VBOX_INCLUDED_SRC_Storage_HBDMgmt_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include <VBox/cdefs.h>
|
---|
25 |
|
---|
26 | RT_C_DECLS_BEGIN
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Opaque host block device manager.
|
---|
30 | */
|
---|
31 | typedef struct HBDMGRINT *HBDMGR;
|
---|
32 | /** Pointer to a block device manager. */
|
---|
33 | typedef HBDMGR *PHBDMGR;
|
---|
34 |
|
---|
35 | /* NIL HBD manager handle. */
|
---|
36 | #define NIL_HBDMGR ((HBDMGR)0)
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Creates host block device manager.
|
---|
40 | *
|
---|
41 | * @returns VBox status code.
|
---|
42 | * @param phHbdMgr Where to store the handle to the block device manager on success.
|
---|
43 | */
|
---|
44 | DECLHIDDEN(int) HBDMgrCreate(PHBDMGR phHbdMgr);
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * Destroys the given block device manager unclaiming all managed block devices.
|
---|
48 | *
|
---|
49 | * @returns nothing.
|
---|
50 | * @param hHbdMgr The block device manager.
|
---|
51 | */
|
---|
52 | DECLHIDDEN(void) HBDMgrDestroy(HBDMGR hHbdMgr);
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Returns whether a given filename resembles a block device which can
|
---|
56 | * be managed by this API.
|
---|
57 | *
|
---|
58 | * @returns true if the given filename point to a block device manageable
|
---|
59 | * by the given manager
|
---|
60 | * false otherwise.
|
---|
61 | * @param pszFilename The block device to check.
|
---|
62 | */
|
---|
63 | DECLHIDDEN(bool) HBDMgrIsBlockDevice(const char *pszFilename);
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Prepares the given block device for use by unmounting and claiming it for exclusive use.
|
---|
67 | *
|
---|
68 | * @returns VBox status code.
|
---|
69 | * @param hHbdMgr The block device manager.
|
---|
70 | * @param pszFilename The block device to claim.
|
---|
71 | */
|
---|
72 | DECLHIDDEN(int) HBDMgrClaimBlockDevice(HBDMGR hHbdMgr, const char *pszFilename);
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * Unclaims the given block device.
|
---|
76 | *
|
---|
77 | * @returns VBox status code.
|
---|
78 | * @param hHbdMgr The block device manager.
|
---|
79 | * @param pszFilename The block device to unclaim.
|
---|
80 | */
|
---|
81 | DECLHIDDEN(int) HBDMgrUnclaimBlockDevice(HBDMGR hHbdMgr, const char *pszFilename);
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * Returns whether the given block device is claimed by the manager.
|
---|
85 | *
|
---|
86 | * @returns true if the block device is claimed, false otherwisw.
|
---|
87 | * @param hHbdMgr The block device manager.
|
---|
88 | * @param pszFilename The block device to check.
|
---|
89 | */
|
---|
90 | DECLHIDDEN(bool) HBDMgrIsBlockDeviceClaimed(HBDMGR hHbdMgr, const char *pszFilename);
|
---|
91 |
|
---|
92 | RT_C_DECLS_END
|
---|
93 |
|
---|
94 | #endif /* !VBOX_INCLUDED_SRC_Storage_HBDMgmt_h */
|
---|