1 | /* $Id: GuestFsInfoImpl.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Main - Guest file system information handling.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2023-2024 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 |
|
---|
29 | /*********************************************************************************************************************************
|
---|
30 | * Header Files *
|
---|
31 | *********************************************************************************************************************************/
|
---|
32 | #define LOG_GROUP LOG_GROUP_MAIN_GUESTFSINFO
|
---|
33 | #include "LoggingNew.h"
|
---|
34 |
|
---|
35 | #ifndef VBOX_WITH_GUEST_CONTROL
|
---|
36 | # error "VBOX_WITH_GUEST_CONTROL must defined in this file"
|
---|
37 | #endif
|
---|
38 | #include "GuestFsInfoImpl.h"
|
---|
39 | #include "GuestCtrlImplPrivate.h"
|
---|
40 |
|
---|
41 | #include "Global.h"
|
---|
42 | #include "AutoCaller.h"
|
---|
43 |
|
---|
44 | #include <VBox/com/array.h>
|
---|
45 |
|
---|
46 |
|
---|
47 |
|
---|
48 | // constructor / destructor
|
---|
49 | /////////////////////////////////////////////////////////////////////////////
|
---|
50 |
|
---|
51 | DEFINE_EMPTY_CTOR_DTOR(GuestFsInfo)
|
---|
52 |
|
---|
53 | HRESULT GuestFsInfo::FinalConstruct(void)
|
---|
54 | {
|
---|
55 | LogFlowThisFuncEnter();
|
---|
56 | return BaseFinalConstruct();
|
---|
57 | }
|
---|
58 |
|
---|
59 | void GuestFsInfo::FinalRelease(void)
|
---|
60 | {
|
---|
61 | LogFlowThisFuncEnter();
|
---|
62 | uninit();
|
---|
63 | BaseFinalRelease();
|
---|
64 | LogFlowThisFuncLeave();
|
---|
65 | }
|
---|
66 |
|
---|
67 | // public initializer/uninitializer for internal purposes only
|
---|
68 | /////////////////////////////////////////////////////////////////////////////
|
---|
69 |
|
---|
70 | int GuestFsInfo::init(PCGSTCTLFSINFO pFsInfo)
|
---|
71 | {
|
---|
72 | AssertPtrReturn(pFsInfo, VERR_INVALID_POINTER);
|
---|
73 |
|
---|
74 | LogFlowThisFuncEnter();
|
---|
75 |
|
---|
76 | /* Enclose the state transition NotReady->InInit->Ready. */
|
---|
77 | AutoInitSpan autoInitSpan(this);
|
---|
78 | AssertReturn(autoInitSpan.isOk(), VERR_OBJECT_DESTROYED);
|
---|
79 |
|
---|
80 | mData = *pFsInfo;
|
---|
81 |
|
---|
82 | /* Confirm a successful initialization when it's the case. */
|
---|
83 | autoInitSpan.setSucceeded();
|
---|
84 |
|
---|
85 | return VINF_SUCCESS;
|
---|
86 | }
|
---|
87 |
|
---|
88 | /**
|
---|
89 | * Uninitializes the instance.
|
---|
90 | * Called from FinalRelease().
|
---|
91 | */
|
---|
92 | void GuestFsInfo::uninit(void)
|
---|
93 | {
|
---|
94 | /* Enclose the state transition Ready->InUninit->NotReady. */
|
---|
95 | AutoUninitSpan autoUninitSpan(this);
|
---|
96 | if (autoUninitSpan.uninitDone())
|
---|
97 | return;
|
---|
98 |
|
---|
99 | LogFlowThisFuncEnter();
|
---|
100 | }
|
---|
101 |
|
---|
102 | // implementation of wrapped private getters/setters for attributes
|
---|
103 | /////////////////////////////////////////////////////////////////////////////
|
---|
104 |
|
---|
105 | HRESULT GuestFsInfo::getFreeSize(LONG64 *aFreeSize)
|
---|
106 | {
|
---|
107 | *aFreeSize = mData.cbFree;
|
---|
108 | return S_OK;
|
---|
109 | }
|
---|
110 |
|
---|
111 | HRESULT GuestFsInfo::getTotalSize(LONG64 *aTotalSize)
|
---|
112 | {
|
---|
113 | *aTotalSize = mData.cbTotalSize;
|
---|
114 | return S_OK;
|
---|
115 | }
|
---|
116 |
|
---|
117 | HRESULT GuestFsInfo::getBlockSize(ULONG *aBlockSize)
|
---|
118 | {
|
---|
119 | *aBlockSize = mData.cbBlockSize;
|
---|
120 | return S_OK;
|
---|
121 | }
|
---|
122 |
|
---|
123 | HRESULT GuestFsInfo::getSectorSize(ULONG *aSectorSize)
|
---|
124 | {
|
---|
125 | *aSectorSize = mData.cbSectorSize;
|
---|
126 | return S_OK;
|
---|
127 | }
|
---|
128 |
|
---|
129 | HRESULT GuestFsInfo::getSerialNumber(ULONG *aSerialNumber)
|
---|
130 | {
|
---|
131 | *aSerialNumber = mData.uSerialNumber;
|
---|
132 | return S_OK;
|
---|
133 | }
|
---|
134 |
|
---|
135 | HRESULT GuestFsInfo::getIsRemote(BOOL *aIsRemote)
|
---|
136 | {
|
---|
137 | *aIsRemote = mData.fFlags & GSTCTLFSINFO_F_IS_REMOTE;
|
---|
138 | return S_OK;
|
---|
139 | }
|
---|
140 |
|
---|
141 | HRESULT GuestFsInfo::getIsCaseSensitive(BOOL *aIsCaseSensitive)
|
---|
142 | {
|
---|
143 | *aIsCaseSensitive = mData.fFlags & GSTCTLFSINFO_F_IS_CASE_SENSITIVE;
|
---|
144 | return S_OK;
|
---|
145 | }
|
---|
146 |
|
---|
147 | HRESULT GuestFsInfo::getIsReadOnly(BOOL *aIsReadOnly)
|
---|
148 | {
|
---|
149 | *aIsReadOnly = mData.fFlags & GSTCTLFSINFO_F_IS_READ_ONLY;
|
---|
150 | return S_OK;
|
---|
151 | }
|
---|
152 |
|
---|
153 | HRESULT GuestFsInfo::getIsCompressed(BOOL *aIsCompressed)
|
---|
154 | {
|
---|
155 | *aIsCompressed = mData.fFlags & GSTCTLFSINFO_F_IS_COMPRESSED;
|
---|
156 | return S_OK;
|
---|
157 | }
|
---|
158 |
|
---|
159 | HRESULT GuestFsInfo::getSupportsFileCompression(BOOL *aSupportsFileCompression)
|
---|
160 | {
|
---|
161 | *aSupportsFileCompression = mData.fFeatures & GSTCTLFSINFO_FEATURE_F_FILE_COMPRESSION;
|
---|
162 | return S_OK;
|
---|
163 | }
|
---|
164 |
|
---|
165 | HRESULT GuestFsInfo::getMaxComponent(ULONG *aMaxComponent)
|
---|
166 | {
|
---|
167 | *aMaxComponent = mData.cMaxComponent;
|
---|
168 | return S_OK;
|
---|
169 | }
|
---|
170 |
|
---|
171 | HRESULT GuestFsInfo::getType(com::Utf8Str &aType)
|
---|
172 | {
|
---|
173 | aType = mData.szName;
|
---|
174 | return S_OK;
|
---|
175 | }
|
---|
176 |
|
---|
177 | HRESULT GuestFsInfo::getLabel(com::Utf8Str &aLabel)
|
---|
178 | {
|
---|
179 | aLabel = mData.szLabel;
|
---|
180 | return S_OK;
|
---|
181 | }
|
---|
182 |
|
---|
183 | HRESULT GuestFsInfo::getMountPoint(com::Utf8Str &aMountPoint)
|
---|
184 | {
|
---|
185 | if (mData.cbMountpoint)
|
---|
186 | aMountPoint.assignEx(mData.szMountpoint, mData.cbMountpoint);
|
---|
187 | return S_OK;
|
---|
188 | }
|
---|
189 |
|
---|