VirtualBox

source: vbox/trunk/src/VBox/Main/src-client/GuestDirectoryImpl.cpp@ 98709

Last change on this file since 98709 was 98709, checked in by vboxsync, 2 years ago

Guest Control: Implemented directory handling / walking as non-toolbox variants. bugref:9783

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 39.2 KB
Line 
1/* $Id: GuestDirectoryImpl.cpp 98709 2023-02-24 08:49:40Z vboxsync $ */
2/** @file
3 * VirtualBox Main - Guest directory handling.
4 */
5
6/*
7 * Copyright (C) 2012-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
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#define LOG_GROUP LOG_GROUP_MAIN_GUESTDIRECTORY
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 "GuestImpl.h"
39#include "GuestDirectoryImpl.h"
40#include "GuestSessionImpl.h"
41#include "GuestCtrlImplPrivate.h"
42#include "VirtualBoxErrorInfoImpl.h"
43
44#include "Global.h"
45#include "AutoCaller.h"
46#include "VBoxEvents.h"
47
48#include <VBox/com/array.h>
49#include <VBox/com/listeners.h>
50#include <VBox/AssertGuest.h>
51
52
53/**
54 * Internal listener class to serve events in an
55 * active manner, e.g. without polling delays.
56 */
57class GuestDirectoryListener
58{
59public:
60
61 GuestDirectoryListener(void)
62 {
63 }
64
65 virtual ~GuestDirectoryListener()
66 {
67 }
68
69 HRESULT init(GuestDirectory *pDir)
70 {
71 AssertPtrReturn(pDir, E_POINTER);
72 mDir = pDir;
73 return S_OK;
74 }
75
76 void uninit(void)
77 {
78 mDir = NULL;
79 }
80
81 STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent)
82 {
83 switch (aType)
84 {
85 case VBoxEventType_OnGuestDirectoryStateChanged:
86 RT_FALL_THROUGH();
87 case VBoxEventType_OnGuestDirectoryRead:
88 {
89 AssertPtrReturn(mDir, E_POINTER);
90 int vrc2 = mDir->signalWaitEvent(aType, aEvent);
91 RT_NOREF(vrc2);
92#ifdef DEBUG_andy
93 LogFlowFunc(("Signalling events of type=%RU32, dir=%p resulted in vrc=%Rrc\n",
94 aType, mDir, vrc2));
95#endif
96 break;
97 }
98
99 default:
100 AssertMsgFailed(("Unhandled event %RU32\n", aType));
101 break;
102 }
103
104 return S_OK;
105 }
106
107private:
108
109 /** Weak pointer to the guest directory object to listen for. */
110 GuestDirectory *mDir;
111};
112typedef ListenerImpl<GuestDirectoryListener, GuestDirectory *> GuestDirectoryListenerImpl;
113
114VBOX_LISTENER_DECLARE(GuestDirectoryListenerImpl)
115
116// constructor / destructor
117/////////////////////////////////////////////////////////////////////////////
118
119DEFINE_EMPTY_CTOR_DTOR(GuestDirectory)
120
121HRESULT GuestDirectory::FinalConstruct(void)
122{
123 LogFlowThisFunc(("\n"));
124 return BaseFinalConstruct();
125}
126
127void GuestDirectory::FinalRelease(void)
128{
129 LogFlowThisFuncEnter();
130 uninit();
131 BaseFinalRelease();
132 LogFlowThisFuncLeave();
133}
134
135// public initializer/uninitializer for internal purposes only
136/////////////////////////////////////////////////////////////////////////////
137
138int GuestDirectory::init(Console *pConsole, GuestSession *pSession, ULONG aObjectID, const GuestDirectoryOpenInfo &openInfo)
139{
140 LogFlowThisFunc(("pConsole=%p, pSession=%p, aObjectID=%RU32, strPath=%s, enmFilter=%#x, fFlags=%x\n",
141 pConsole, pSession, aObjectID, openInfo.mPath.c_str(), openInfo.menmFilter, openInfo.mFlags));
142
143 AssertPtrReturn(pConsole, VERR_INVALID_POINTER);
144 AssertPtrReturn(pSession, VERR_INVALID_POINTER);
145
146 /* Enclose the state transition NotReady->InInit->Ready. */
147 AutoInitSpan autoInitSpan(this);
148 AssertReturn(autoInitSpan.isOk(), VERR_OBJECT_DESTROYED);
149
150 int vrc = bindToSession(pConsole, pSession, aObjectID);
151 if (RT_SUCCESS(vrc))
152 {
153 mSession = pSession;
154 mObjectID = aObjectID;
155
156 mData.mOpenInfo = openInfo;
157 mData.mStatus = DirectoryStatus_Undefined;
158 mData.mLastError = VINF_SUCCESS;
159
160 unconst(mEventSource).createObject();
161 HRESULT hr = mEventSource->init();
162 if (FAILED(hr))
163 vrc = VERR_COM_UNEXPECTED;
164 }
165
166 if (RT_SUCCESS(vrc))
167 {
168 try
169 {
170 GuestDirectoryListener *pListener = new GuestDirectoryListener();
171 ComObjPtr<GuestDirectoryListenerImpl> thisListener;
172 HRESULT hr = thisListener.createObject();
173 if (SUCCEEDED(hr))
174 hr = thisListener->init(pListener, this);
175
176 if (SUCCEEDED(hr))
177 {
178 com::SafeArray <VBoxEventType_T> eventTypes;
179 eventTypes.push_back(VBoxEventType_OnGuestDirectoryStateChanged);
180 eventTypes.push_back(VBoxEventType_OnGuestDirectoryRead);
181 hr = mEventSource->RegisterListener(thisListener,
182 ComSafeArrayAsInParam(eventTypes),
183 TRUE /* Active listener */);
184 if (SUCCEEDED(hr))
185 {
186 vrc = baseInit();
187 if (RT_SUCCESS(vrc))
188 {
189 mLocalListener = thisListener;
190 }
191 }
192 else
193 vrc = VERR_COM_UNEXPECTED;
194 }
195 else
196 vrc = VERR_COM_UNEXPECTED;
197 }
198 catch(std::bad_alloc &)
199 {
200 vrc = VERR_NO_MEMORY;
201 }
202 }
203
204 /* Confirm a successful initialization when it's the case. */
205 if (RT_SUCCESS(vrc))
206 autoInitSpan.setSucceeded();
207 else
208 autoInitSpan.setFailed();
209
210 LogFlowFuncLeaveRC(vrc);
211 return vrc;
212}
213
214/**
215 * Uninitializes the instance.
216 * Called from FinalRelease().
217 */
218void GuestDirectory::uninit(void)
219{
220 LogFlowThisFuncEnter();
221
222 /* Enclose the state transition Ready->InUninit->NotReady. */
223 AutoUninitSpan autoUninitSpan(this);
224 if (autoUninitSpan.uninitDone())
225 return;
226
227 LogFlowThisFuncLeave();
228}
229
230// implementation of private wrapped getters/setters for attributes
231/////////////////////////////////////////////////////////////////////////////
232
233HRESULT GuestDirectory::getDirectoryName(com::Utf8Str &aDirectoryName)
234{
235 LogFlowThisFuncEnter();
236
237 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
238
239 aDirectoryName = mData.mOpenInfo.mPath;
240
241 return S_OK;
242}
243
244HRESULT GuestDirectory::getEventSource(ComPtr<IEventSource> &aEventSource)
245{
246 /* No need to lock - lifetime constant. */
247 mEventSource.queryInterfaceTo(aEventSource.asOutParam());
248
249 return S_OK;
250}
251
252HRESULT GuestDirectory::getFilter(com::Utf8Str &aFilter)
253{
254 LogFlowThisFuncEnter();
255
256 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
257
258 aFilter = mData.mOpenInfo.mFilter;
259
260 return S_OK;
261}
262
263HRESULT GuestDirectory::getId(ULONG *aId)
264{
265 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
266
267 *aId = mObjectID;
268
269 return S_OK;
270}
271
272HRESULT GuestDirectory::getStatus(DirectoryStatus_T *aStatus)
273{
274 LogFlowThisFuncEnter();
275
276 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
277
278 *aStatus = mData.mStatus;
279
280 return S_OK;
281}
282
283// private methods
284/////////////////////////////////////////////////////////////////////////////
285
286/**
287 * Entry point for guest side directory callbacks.
288 *
289 * @returns VBox status code.
290 * @param pCbCtx Host callback context.
291 * @param pSvcCb Host callback data.
292 */
293int GuestDirectory::i_callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb)
294{
295 AssertPtrReturn(pCbCtx, VERR_INVALID_POINTER);
296 AssertPtrReturn(pSvcCb, VERR_INVALID_POINTER);
297
298 LogFlowThisFunc(("strPath=%s, uContextID=%RU32, uMessage=%RU32, pSvcCb=%p\n",
299 mData.mOpenInfo.mPath.c_str(), pCbCtx->uContextID, pCbCtx->uMessage, pSvcCb));
300
301 int vrc;
302 switch (pCbCtx->uMessage)
303 {
304 case GUEST_MSG_DISCONNECTED:
305 /** @todo vrc = i_onGuestDisconnected(pCbCtx, pSvcCb); */
306 vrc = VINF_SUCCESS; /// @todo To be implemented
307 break;
308
309 case GUEST_MSG_DIR_NOTIFY:
310 {
311 vrc = i_onDirNotify(pCbCtx, pSvcCb);
312 break;
313 }
314
315 default:
316 /* Silently ignore not implemented functions. */
317 vrc = VERR_NOT_SUPPORTED;
318 break;
319 }
320
321 LogFlowFuncLeaveRC(vrc);
322 return vrc;
323}
324
325/**
326 * Opens the directory on the guest side.
327 *
328 * @return VBox status code.
329 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned.
330 */
331int GuestDirectory::i_open(int *pvrcGuest)
332{
333 int vrc;
334#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
335 if ((mSession->i_getParent()->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS))
336 {
337 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
338
339 GuestWaitEvent *pEvent = NULL;
340 GuestEventTypes eventTypes;
341 try
342 {
343 eventTypes.push_back(VBoxEventType_OnGuestDirectoryStateChanged);
344
345 vrc = registerWaitEvent(eventTypes, &pEvent);
346 }
347 catch (std::bad_alloc &)
348 {
349 vrc = VERR_NO_MEMORY;
350 }
351
352 if (RT_FAILURE(vrc))
353 return vrc;
354
355 /* Prepare HGCM call. */
356 VBOXHGCMSVCPARM paParms[8];
357 int i = 0;
358 HGCMSvcSetU32(&paParms[i++], pEvent->ContextID());
359 HGCMSvcSetStr(&paParms[i++], mData.mOpenInfo.mPath.c_str());
360 HGCMSvcSetU32(&paParms[i++], mData.mOpenInfo.menmFilter);
361 HGCMSvcSetU32(&paParms[i++], mData.mOpenInfo.mFlags);
362
363 alock.release(); /* Drop lock before sending. */
364
365 vrc = sendMessage(HOST_MSG_DIR_OPEN, i, paParms);
366 if (RT_SUCCESS(vrc))
367 vrc = i_waitForStatusChange(pEvent, 30 * 1000, NULL /* FileStatus */, pvrcGuest);
368 }
369 else
370#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
371 {
372 vrc = i_openViaToolbox(pvrcGuest);
373 }
374
375 return vrc;
376}
377
378#ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT
379/**
380 * Opens the directory on the guest side (legacy version).
381 *
382 * @returns VBox status code.
383 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned.
384 *
385 * @note This uses an own guest process via the built-in toolbox in VBoxSerivce.
386 */
387int GuestDirectory::i_openViaToolbox(int *pvrcGuest)
388{
389 /* Start the directory process on the guest. */
390 GuestProcessStartupInfo procInfo;
391 procInfo.mName.printf(tr("Opening directory \"%s\""), mData.mOpenInfo.mPath.c_str());
392 procInfo.mTimeoutMS = 5 * 60 * 1000; /* 5 minutes timeout. */
393 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut;
394 procInfo.mExecutable= Utf8Str(VBOXSERVICE_TOOL_LS);
395
396 procInfo.mArguments.push_back(procInfo.mExecutable);
397 procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
398 /* We want the long output format which contains all the object details. */
399 procInfo.mArguments.push_back(Utf8Str("-l"));
400# if 0 /* Flags are not supported yet. */
401 if (uFlags & DirectoryOpenFlag_NoSymlinks)
402 procInfo.mArguments.push_back(Utf8Str("--nosymlinks")); /** @todo What does GNU here? */
403# endif
404 /** @todo Recursion support? */
405 procInfo.mArguments.push_back(mData.mOpenInfo.mPath); /* The directory we want to open. */
406
407 /*
408 * Start the process synchronously and keep it around so that we can use
409 * it later in subsequent read() calls.
410 */
411 int vrc = mData.mProcessTool.init(mSession, procInfo, false /*fAsync*/, NULL /*pvrcGuest*/);
412 if (RT_SUCCESS(vrc))
413 {
414 /* As we need to know if the directory we were about to open exists and and is accessible,
415 * do the first read here in order to return a meaningful status here. */
416 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS;
417 vrc = i_readInternal(mData.mObjData, &vrcGuest);
418 if (RT_FAILURE(vrc))
419 {
420 /*
421 * We need to actively terminate our process tool in case of an error here,
422 * as this otherwise would be done on (directory) object destruction implicitly.
423 * This in turn then will run into a timeout, as the directory object won't be
424 * around anymore at that time. Ugly, but that's how it is for the moment.
425 */
426 /* ignore rc */ mData.mProcessTool.terminate(30 * RT_MS_1SEC, NULL /* pvrcGuest */);
427 }
428
429 if (pvrcGuest)
430 *pvrcGuest = vrcGuest;
431 }
432
433 return vrc;
434}
435#endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */
436
437/**
438 * Called when the guest side notifies the host of a directory event.
439 *
440 * @returns VBox status code.
441 * @param pCbCtx Host callback context.
442 * @param pSvcCbData Host callback data.
443 */
444int GuestDirectory::i_onDirNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData)
445{
446#ifndef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
447 RT_NOREF(pCbCtx, pSvcCbData);
448 return VERR_NOT_SUPPORTED;
449#else
450 AssertPtrReturn(pCbCtx, VERR_INVALID_POINTER);
451 AssertPtrReturn(pSvcCbData, VERR_INVALID_POINTER);
452
453 LogFlowThisFuncEnter();
454
455 if (pSvcCbData->mParms < 3)
456 return VERR_INVALID_PARAMETER;
457
458 int idx = 1; /* Current parameter index. */
459 CALLBACKDATA_DIR_NOTIFY dataCb;
460 RT_ZERO(dataCb);
461 /* pSvcCb->mpaParms[0] always contains the context ID. */
462 HGCMSvcGetU32(&pSvcCbData->mpaParms[idx++], &dataCb.uType);
463 HGCMSvcGetU32(&pSvcCbData->mpaParms[idx++], &dataCb.rc);
464
465 int vrcGuest = (int)dataCb.rc; /* uint32_t vs. int. */
466
467 LogFlowThisFunc(("uType=%RU32, vrcGuest=%Rrc\n", dataCb.uType, vrcGuest));
468
469 if (RT_FAILURE(vrcGuest))
470 {
471 /** @todo Set status? */
472
473 /* Ignore return code, as the event to signal might not be there (anymore). */
474 signalWaitEventInternal(pCbCtx, vrcGuest, NULL /* pPayload */);
475 return VINF_SUCCESS; /* Report to the guest. */
476 }
477
478 int vrc = VERR_NOT_SUPPORTED; /* Play safe by default. */
479
480 ComObjPtr<VirtualBoxErrorInfo> errorInfo;
481 HRESULT hrc = errorInfo.createObject();
482 ComAssertComRCRet(hrc, VERR_COM_UNEXPECTED);
483 if (RT_FAILURE(vrcGuest))
484 {
485 hrc = errorInfo->initEx(VBOX_E_GSTCTL_GUEST_ERROR, vrcGuest,
486 COM_IIDOF(IGuestDirectory), getComponentName(),
487 i_guestErrorToString(vrcGuest, mData.mOpenInfo.mPath.c_str()));
488 ComAssertComRCRet(hrc, VERR_COM_UNEXPECTED);
489 }
490
491 switch (dataCb.uType)
492 {
493 case GUEST_DIR_NOTIFYTYPE_ERROR:
494 {
495 vrc = i_setStatus(DirectoryStatus_Error, vrcGuest);
496 break;
497 }
498
499 case GUEST_DIR_NOTIFYTYPE_OPEN:
500 {
501 AssertBreakStmt(pSvcCbData->mParms >= 4, vrc = VERR_INVALID_PARAMETER);
502 vrc = HGCMSvcGetU32(&pSvcCbData->mpaParms[idx++], &dataCb.u.open.uHandle /* Guest native file handle */);
503 AssertRCBreak(vrc);
504 vrc = i_setStatus(DirectoryStatus_Open, vrcGuest);
505 break;
506 }
507
508 case GUEST_DIR_NOTIFYTYPE_CLOSE:
509 {
510 vrc = i_setStatus(DirectoryStatus_Close, vrcGuest);
511 break;
512 }
513
514 case GUEST_DIR_NOTIFYTYPE_READ:
515 {
516 ASSERT_GUEST_MSG_STMT_BREAK(pSvcCbData->mParms == 7, ("mParms=%u\n", pSvcCbData->mParms),
517 vrc = VERR_WRONG_PARAMETER_COUNT);
518 ASSERT_GUEST_MSG_STMT_BREAK(pSvcCbData->mpaParms[idx].type == VBOX_HGCM_SVC_PARM_PTR,
519 ("type=%u\n", pSvcCbData->mpaParms[idx].type),
520 vrc = VERR_WRONG_PARAMETER_TYPE);
521 PGSTCTLDIRENTRYEX pEntry;
522 uint32_t cbEntry;
523 vrc = HGCMSvcGetPv(&pSvcCbData->mpaParms[idx++], (void **)&pEntry, &cbEntry);
524 AssertRCBreak(vrc);
525 AssertBreakStmt( cbEntry >= sizeof(GSTCTLDIRENTRYEX)
526 && cbEntry <= GSTCTL_DIRENTRY_MAX_SIZE, VERR_INVALID_PARAMETER);
527 dataCb.u.read.pEntry = (PGSTCTLDIRENTRYEX)RTMemDup(pEntry, cbEntry);
528 AssertPtrBreakStmt(dataCb.u.read.pEntry, vrc = VERR_NO_MEMORY);
529 dataCb.u.read.cbEntry = cbEntry;
530
531 char *pszUser;
532 uint32_t cbUser;
533 vrc = HGCMSvcGetStr(&pSvcCbData->mpaParms[idx++], &pszUser, &cbUser);
534 AssertRCBreak(vrc);
535 dataCb.u.read.pszUser = RTStrDup(pszUser);
536 AssertPtrBreakStmt(dataCb.u.read.pszUser, vrc = VERR_NO_MEMORY);
537 dataCb.u.read.cbUser = cbUser;
538
539 char *pszGroups;
540 uint32_t cbGroups;
541 vrc = HGCMSvcGetStr(&pSvcCbData->mpaParms[idx++], &pszGroups, &cbGroups);
542 AssertRCBreak(vrc);
543 dataCb.u.read.pszGroups = RTStrDup(pszGroups);
544 AssertPtrBreakStmt(dataCb.u.read.pszGroups, vrc = VERR_NO_MEMORY);
545 dataCb.u.read.cbGroups = cbGroups;
546
547 /** @todo ACLs not implemented yet. */
548
549 GuestFsObjData fsObjData(dataCb.u.read.pEntry->szName);
550 vrc = fsObjData.FromGuestFsObjInfo(&dataCb.u.read.pEntry->Info);
551 AssertRCBreak(vrc);
552 ComObjPtr<GuestFsObjInfo> ptrFsObjInfo;
553 hrc = ptrFsObjInfo.createObject();
554 ComAssertComRCBreak(hrc, vrc = VERR_COM_UNEXPECTED);
555 vrc = ptrFsObjInfo->init(fsObjData);
556 AssertRCBreak(vrc);
557
558 ::FireGuestDirectoryReadEvent(mEventSource, mSession, this,
559 dataCb.u.read.pEntry->szName, ptrFsObjInfo, dataCb.u.read.pszUser, dataCb.u.read.pszGroups);
560 break;
561 }
562
563 case GUEST_DIR_NOTIFYTYPE_REWIND:
564 {
565 /* Note: This does not change the overall status of the directory (i.e. open). */
566 ::FireGuestDirectoryStateChangedEvent(mEventSource, mSession, this, DirectoryStatus_Rewind, errorInfo);
567 break;
568 }
569
570 default:
571 AssertFailed();
572 break;
573 }
574
575 try
576 {
577 if (RT_SUCCESS(vrc))
578 {
579 GuestWaitEventPayload payload(dataCb.uType, &dataCb, sizeof(dataCb));
580
581 /* Ignore return code, as the event to signal might not be there (anymore). */
582 signalWaitEventInternal(pCbCtx, vrcGuest, &payload);
583 }
584 else /* OOM situation, wrong HGCM parameters or smth. not expected. */
585 {
586 /* Ignore return code, as the event to signal might not be there (anymore). */
587 signalWaitEventInternalEx(pCbCtx, vrc, 0 /* guestRc */, NULL /* pPayload */);
588 }
589 }
590 catch (int vrcEx) /* Thrown by GuestWaitEventPayload constructor. */
591 {
592 /* Also try to signal the waiter, to let it know of the OOM situation.
593 * Ignore return code, as the event to signal might not be there (anymore). */
594 signalWaitEventInternalEx(pCbCtx, vrcEx, 0 /* guestRc */, NULL /* pPayload */);
595 vrc = vrcEx;
596 }
597
598 LogFlowThisFunc(("uType=%RU32, rcGuest=%Rrc, vrc=%Rrc\n", dataCb.uType, vrcGuest, vrc));
599 return vrc;
600#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
601}
602
603/**
604 * Converts a given guest directory error to a string.
605 *
606 * @returns Error string.
607 * @param vrcGuest Guest directory error to return string for.
608 * @param pcszWhat Hint of what was involved when the error occurred.
609 */
610/* static */
611Utf8Str GuestDirectory::i_guestErrorToString(int vrcGuest, const char *pcszWhat)
612{
613 AssertPtrReturn(pcszWhat, "");
614
615#define CASE_MSG(a_iRc, ...) \
616 case a_iRc: strErr.printf(__VA_ARGS__); break;
617
618 Utf8Str strErr;
619 switch (vrcGuest)
620 {
621 CASE_MSG(VERR_ACCESS_DENIED, tr("Access to guest directory \"%s\" is denied"), pcszWhat);
622 CASE_MSG(VERR_ALREADY_EXISTS, tr("Guest directory \"%s\" already exists"), pcszWhat);
623 CASE_MSG(VERR_CANT_CREATE, tr("Guest directory \"%s\" cannot be created"), pcszWhat);
624 CASE_MSG(VERR_DIR_NOT_EMPTY, tr("Guest directory \"%s\" is not empty"), pcszWhat);
625 default:
626 strErr.printf(tr("Error %Rrc for guest directory \"%s\" occurred\n"), vrcGuest, pcszWhat);
627 break;
628 }
629
630#undef CASE_MSG
631
632 return strErr;
633}
634
635/**
636 * @copydoc GuestObject::i_onUnregister
637 */
638int GuestDirectory::i_onUnregister(void)
639{
640 LogFlowThisFuncEnter();
641
642 int vrc = VINF_SUCCESS;
643
644 LogFlowFuncLeaveRC(vrc);
645 return vrc;
646}
647
648/**
649 * @copydoc GuestObject::i_onSessionStatusChange
650 */
651int GuestDirectory::i_onSessionStatusChange(GuestSessionStatus_T enmSessionStatus)
652{
653 RT_NOREF(enmSessionStatus);
654
655 LogFlowThisFuncEnter();
656
657 int vrc = VINF_SUCCESS;
658
659 LogFlowFuncLeaveRC(vrc);
660 return vrc;
661}
662
663/**
664 * Closes this guest directory and removes it from the
665 * guest session's directory list.
666 *
667 * @return VBox status code.
668 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned.
669 */
670int GuestDirectory::i_close(int *pvrcGuest)
671{
672 int vrc;
673#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
674 if (mSession->i_getParent()->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS)
675 {
676 GuestWaitEvent *pEvent = NULL;
677 GuestEventTypes eventTypes;
678 try
679 {
680 eventTypes.push_back(VBoxEventType_OnGuestDirectoryStateChanged);
681
682 vrc = registerWaitEvent(eventTypes, &pEvent);
683 }
684 catch (std::bad_alloc &)
685 {
686 vrc = VERR_NO_MEMORY;
687 }
688
689 if (RT_FAILURE(vrc))
690 return vrc;
691
692 /* Prepare HGCM call. */
693 VBOXHGCMSVCPARM paParms[2];
694 int i = 0;
695 HGCMSvcSetU32(&paParms[i++], pEvent->ContextID());
696 HGCMSvcSetU32(&paParms[i++], mObjectID /* Guest directory handle */);
697
698 vrc = sendMessage(HOST_MSG_DIR_CLOSE, i, paParms);
699 if (RT_SUCCESS(vrc))
700 {
701 vrc = pEvent->Wait(30 * 1000);
702 if (RT_SUCCESS(vrc))
703 {
704 // Nothing to do here.
705 }
706 else if (pEvent->HasGuestError() && pvrcGuest)
707 *pvrcGuest = pEvent->GuestResult();
708 }
709 }
710 else
711#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
712 {
713 vrc = i_closeViaToolbox(pvrcGuest);
714 }
715
716 AssertPtr(mSession);
717 int vrc2 = mSession->i_directoryUnregister(this);
718 if (RT_SUCCESS(vrc))
719 vrc = vrc2;
720
721 LogFlowThisFunc(("Returning vrc=%Rrc\n", vrc));
722 return vrc;
723}
724
725#ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT
726/**
727 * Closes this guest directory and removes it from the guest session's directory list (legacy version).
728 *
729 * @return VBox status code.
730 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned.
731 *
732 * @note This uses an own guest process via the built-in toolbox in VBoxSerivce.
733 */
734int GuestDirectory::i_closeViaToolbox(int *pvrcGuest)
735{
736 return mData.mProcessTool.terminate(30 * 1000 /* 30s timeout */, pvrcGuest);
737}
738#endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */
739
740/**
741 * Reads the next directory entry, internal version.
742 *
743 * @return VBox status code. Will return VERR_NO_MORE_FILES if no more entries are available.
744 * @param objData Where to store the read directory entry as internal object data.
745 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned.
746 */
747int GuestDirectory::i_readInternal(GuestFsObjData &objData, int *pvrcGuest)
748{
749 AssertPtrReturn(pvrcGuest, VERR_INVALID_POINTER);
750
751 int vrc;
752 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS;
753
754#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
755 if (mSession->i_getParent()->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS)
756 {
757 GuestWaitEvent *pEvent = NULL;
758 GuestEventTypes eventTypes;
759 try
760 {
761 vrc = registerWaitEvent(eventTypes, &pEvent);
762 }
763 catch (std::bad_alloc &)
764 {
765 vrc = VERR_NO_MEMORY;
766 }
767
768 if (RT_FAILURE(vrc))
769 return vrc;
770
771 /* Prepare HGCM call. */
772 VBOXHGCMSVCPARM paParms[8];
773 int i = 0;
774 HGCMSvcSetU32(&paParms[i++], pEvent->ContextID());
775 HGCMSvcSetU32(&paParms[i++], mObjectID /* Guest directory handle */);
776 HGCMSvcSetU32(&paParms[i++], GSTCTL_DIRENTRY_MAX_SIZE);
777 HGCMSvcSetU32(&paParms[i++], GSTCTLFSOBJATTRADD_UNIX /* Implicit */);
778 HGCMSvcSetU32(&paParms[i++], GSTCTL_PATH_F_ON_LINK);
779
780 vrc = sendMessage(HOST_MSG_DIR_READ, i, paParms);
781 if (RT_SUCCESS(vrc))
782 {
783 vrc = pEvent->Wait(30 * 1000);
784 if (RT_SUCCESS(vrc))
785 {
786 PCALLBACKDATA_DIR_NOTIFY const pDirNotify = (PCALLBACKDATA_DIR_NOTIFY)pEvent->Payload().Raw();
787 AssertPtrReturn(pDirNotify, VERR_INVALID_POINTER);
788 vrcGuest = (int)pDirNotify->rc;
789 if (RT_SUCCESS(vrcGuest))
790 {
791 AssertReturn(pDirNotify->uType == GUEST_DIR_NOTIFYTYPE_READ, VERR_INVALID_PARAMETER);
792 AssertPtrReturn(pDirNotify->u.read.pEntry, VERR_INVALID_POINTER);
793 objData.Init(pDirNotify->u.read.pEntry->szName);
794 vrc = objData.FromGuestFsObjInfo(&pDirNotify->u.read.pEntry->Info,
795 pDirNotify->u.read.pszUser, pDirNotify->u.read.pszGroups);
796 RTMemFree(pDirNotify->u.read.pEntry);
797 RTStrFree(pDirNotify->u.read.pszUser);
798 RTStrFree(pDirNotify->u.read.pszGroups);
799 }
800 else
801 {
802 if (pvrcGuest)
803 *pvrcGuest = vrcGuest;
804 vrc = VERR_GSTCTL_GUEST_ERROR;
805 }
806 }
807 else if (pEvent->HasGuestError() && pvrcGuest)
808 *pvrcGuest = pEvent->GuestResult();
809 }
810 }
811 else
812#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
813 {
814 vrc = i_readInternalViaToolbox(objData, pvrcGuest);
815 }
816
817 LogFlowThisFunc(("Returning vrc=%Rrc\n", vrc));
818 return vrc;
819}
820
821#ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT
822/**
823 * Reads the next directory entry, internal version (legacy version).
824 *
825 * @return VBox status code. Will return VERR_NO_MORE_FILES if no more entries are available.
826 * @param objData Where to store the read directory entry as internal object data.
827 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned.
828 *
829 * @note This uses an own guest process via the built-in toolbox in VBoxSerivce.
830 */
831int GuestDirectory::i_readInternalViaToolbox(GuestFsObjData &objData, int *pvrcGuest)
832{
833 GuestToolboxStreamBlock curBlock;
834 int vrc = mData.mProcessTool.waitEx(GUESTPROCESSTOOL_WAIT_FLAG_STDOUT_BLOCK, &curBlock, pvrcGuest);
835 if (RT_SUCCESS(vrc))
836 {
837 /*
838 * Note: The guest process can still be around to serve the next
839 * upcoming stream block next time.
840 */
841 if (!mData.mProcessTool.isRunning())
842 vrc = mData.mProcessTool.getTerminationStatus(); /* Tool process is not running (anymore). Check termination status. */
843
844 if (RT_SUCCESS(vrc))
845 {
846 if (curBlock.GetCount()) /* Did we get content? */
847 {
848 if (curBlock.GetString("name"))
849 {
850 vrc = objData.FromToolboxLs(curBlock, true /* fLong */);
851 }
852 else
853 vrc = VERR_PATH_NOT_FOUND;
854 }
855 else
856 {
857 /* Nothing to read anymore. Tell the caller. */
858 vrc = VERR_NO_MORE_FILES;
859 }
860 }
861 }
862
863 return vrc;
864}
865#endif /* VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT */
866
867/**
868 * Reads the next directory entry.
869 *
870 * @return VBox status code. Will return VERR_NO_MORE_FILES if no more entries are available.
871 * @param fsObjInfo Where to store the read directory entry.
872 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned.
873 */
874int GuestDirectory::i_read(ComObjPtr<GuestFsObjInfo> &fsObjInfo, int *pvrcGuest)
875{
876 AssertPtrReturn(pvrcGuest, VERR_INVALID_POINTER);
877
878 /* Create the FS info object. */
879 HRESULT hr = fsObjInfo.createObject();
880 if (FAILED(hr))
881 return VERR_COM_UNEXPECTED;
882
883 int vrc;
884
885 /* If we have a valid object data cache, read from it. */
886 if (mData.mObjData.mName.isNotEmpty())
887 {
888 vrc = fsObjInfo->init(mData.mObjData);
889 if (RT_SUCCESS(vrc))
890 {
891 mData.mObjData.mName = ""; /* Mark the object data as being empty (beacon). */
892 }
893 }
894 else /* Otherwise ask the guest for the next object data. */
895 {
896
897 GuestFsObjData objData;
898 vrc = i_readInternal(objData, pvrcGuest);
899 if (RT_SUCCESS(vrc))
900 vrc = fsObjInfo->init(objData);
901 }
902
903 LogFlowThisFunc(("Returning vrc=%Rrc\n", vrc));
904 return vrc;
905}
906
907/**
908 * Rewinds the directory reading.
909 *
910 * @returns VBox status code.
911 * @retval VERR_GSTCTL_GUEST_ERROR when an error from the guest side has been received.
912 * @param uTimeoutMS Timeout (in ms) to wait.
913 * @param pvrcGuest Where to store the guest result code in case VERR_GSTCTL_GUEST_ERROR is returned.
914 */
915int GuestDirectory::i_rewind(uint32_t uTimeoutMS, int *pvrcGuest)
916{
917 RT_NOREF(pvrcGuest);
918#ifndef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
919 RT_NOREF(uTimeoutMS, pvrcGuest);
920#else
921 /* Only available for Guest Additions 7.1+. */
922 if (mSession->i_getParent()->i_getGuestControlFeatures0() & VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS)
923 {
924 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
925
926 int vrc;
927
928 GuestWaitEvent *pEvent = NULL;
929 GuestEventTypes eventTypes;
930 try
931 {
932 eventTypes.push_back(VBoxEventType_OnGuestDirectoryStateChanged);
933 vrc = registerWaitEvent(eventTypes, &pEvent);
934 }
935 catch (std::bad_alloc &)
936 {
937 vrc = VERR_NO_MEMORY;
938 }
939
940 if (RT_FAILURE(vrc))
941 return vrc;
942
943 /* Prepare HGCM call. */
944 VBOXHGCMSVCPARM paParms[4];
945 int i = 0;
946 HGCMSvcSetU32(&paParms[i++], pEvent->ContextID());
947 HGCMSvcSetU32(&paParms[i++], mObjectID /* Directory handle */);
948
949 alock.release(); /* Drop lock before sending. */
950
951 vrc = sendMessage(HOST_MSG_DIR_REWIND, i, paParms);
952 if (RT_SUCCESS(vrc))
953 {
954 VBoxEventType_T evtType;
955 ComPtr<IEvent> pIEvent;
956 vrc = waitForEvent(pEvent, uTimeoutMS, &evtType, pIEvent.asOutParam());
957 if (RT_SUCCESS(vrc))
958 {
959 if (evtType == VBoxEventType_OnGuestDirectoryStateChanged)
960 {
961 ComPtr<IGuestDirectoryStateChangedEvent> pEvt = pIEvent;
962 Assert(!pEvt.isNull());
963 }
964 else
965 vrc = VWRN_GSTCTL_OBJECTSTATE_CHANGED;
966 }
967 else if (pEvent->HasGuestError()) /* Return guest vrc if available. */
968 vrc = pEvent->GuestResult();
969 }
970
971 unregisterWaitEvent(pEvent);
972 return vrc;
973 }
974#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
975
976 return VERR_NOT_SUPPORTED;
977}
978
979/**
980 * Sets the current internal directory object status.
981 *
982 * @returns VBox status code.
983 * @param enmStatus New directory status to set.
984 * @param vrcDir New result code to set.
985 *
986 * @note Takes the write lock.
987 */
988int GuestDirectory::i_setStatus(DirectoryStatus_T enmStatus, int vrcDir)
989{
990 LogFlowThisFuncEnter();
991
992 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
993
994 LogFlowThisFunc(("oldStatus=%RU32, newStatus=%RU32, vrcDir=%Rrc\n", mData.mStatus, enmStatus, vrcDir));
995
996#ifdef VBOX_STRICT
997 if (enmStatus == DirectoryStatus_Error)
998 AssertMsg(RT_FAILURE(vrcDir), ("Guest vrc must be an error (%Rrc)\n", vrcDir));
999 else
1000 AssertMsg(RT_SUCCESS(vrcDir), ("Guest vrc must not be an error (%Rrc)\n", vrcDir));
1001#endif
1002
1003 if (mData.mStatus != enmStatus)
1004 {
1005 mData.mStatus = enmStatus;
1006 mData.mLastError = vrcDir;
1007
1008 ComObjPtr<VirtualBoxErrorInfo> errorInfo;
1009 HRESULT hrc = errorInfo.createObject();
1010 ComAssertComRCRet(hrc, VERR_COM_UNEXPECTED);
1011 if (RT_FAILURE(vrcDir))
1012 {
1013 hrc = errorInfo->initEx(VBOX_E_GSTCTL_GUEST_ERROR, vrcDir,
1014 COM_IIDOF(IGuestDirectory), getComponentName(),
1015 i_guestErrorToString(vrcDir, mData.mOpenInfo.mPath.c_str()));
1016 ComAssertComRCRet(hrc, VERR_COM_UNEXPECTED);
1017 }
1018 /* Note: On vrcDir success, errorInfo is set to S_OK and also sent via the event below. */
1019
1020 alock.release(); /* Release lock before firing off event. */
1021
1022 ::FireGuestDirectoryStateChangedEvent(mEventSource, mSession, this, mData.mStatus, errorInfo);
1023 }
1024
1025 return VINF_SUCCESS;
1026}
1027
1028/**
1029 * Waits for a guest directory status change.
1030 *
1031 * @note Similar code in GuestFile::i_waitForStatusChange().
1032 *
1033 * @returns VBox status code.
1034 * @retval VERR_GSTCTL_GUEST_ERROR when an error from the guest side has been received.
1035 * @param pEvent Guest wait event to wait for.
1036 * @param uTimeoutMS Timeout (in ms) to wait.
1037 * @param penmStatus Where to return the directoy status on success.
1038 * @param prcGuest Where to return the guest error when VERR_GSTCTL_GUEST_ERROR was returned.
1039 */
1040int GuestDirectory::i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS,
1041 DirectoryStatus_T *penmStatus, int *prcGuest)
1042{
1043 AssertPtrReturn(pEvent, VERR_INVALID_POINTER);
1044 /* penmStatus is optional. */
1045
1046 VBoxEventType_T evtType;
1047 ComPtr<IEvent> pIEvent;
1048 int vrc = waitForEvent(pEvent, uTimeoutMS, &evtType, pIEvent.asOutParam());
1049 if (RT_SUCCESS(vrc))
1050 {
1051 AssertReturn(evtType == VBoxEventType_OnGuestDirectoryStateChanged, VERR_WRONG_TYPE);
1052 ComPtr<IGuestDirectoryStateChangedEvent> pDirectoryEvent = pIEvent;
1053 AssertReturn(!pDirectoryEvent.isNull(), VERR_COM_UNEXPECTED);
1054
1055 HRESULT hr;
1056 if (penmStatus)
1057 {
1058 hr = pDirectoryEvent->COMGETTER(Status)(penmStatus);
1059 ComAssertComRC(hr);
1060 }
1061
1062 ComPtr<IVirtualBoxErrorInfo> errorInfo;
1063 hr = pDirectoryEvent->COMGETTER(Error)(errorInfo.asOutParam());
1064 ComAssertComRC(hr);
1065
1066 LONG lGuestRc;
1067 hr = errorInfo->COMGETTER(ResultDetail)(&lGuestRc);
1068 ComAssertComRC(hr);
1069
1070 LogFlowThisFunc(("resultDetail=%RI32 (%Rrc)\n", lGuestRc, lGuestRc));
1071
1072 if (RT_FAILURE((int)lGuestRc))
1073 vrc = VERR_GSTCTL_GUEST_ERROR;
1074
1075 if (prcGuest)
1076 *prcGuest = (int)lGuestRc;
1077 }
1078 /* waitForEvent may also return VERR_GSTCTL_GUEST_ERROR like we do above, so make prcGuest is set. */
1079 /** @todo Also see todo in GuestFile::i_waitForStatusChange(). */
1080 else if (vrc == VERR_GSTCTL_GUEST_ERROR && prcGuest)
1081 *prcGuest = pEvent->GuestResult();
1082 Assert(vrc != VERR_GSTCTL_GUEST_ERROR || !prcGuest || *prcGuest != (int)0xcccccccc);
1083
1084 return vrc;
1085}
1086
1087// implementation of public methods
1088/////////////////////////////////////////////////////////////////////////////
1089HRESULT GuestDirectory::close()
1090{
1091 AutoCaller autoCaller(this);
1092 if (FAILED(autoCaller.hrc())) return autoCaller.hrc();
1093
1094 LogFlowThisFuncEnter();
1095
1096 HRESULT hrc = S_OK;
1097
1098 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS;
1099 int vrc = i_close(&vrcGuest);
1100 if (RT_FAILURE(vrc))
1101 {
1102 switch (vrc)
1103 {
1104 case VERR_GSTCTL_GUEST_ERROR:
1105 {
1106 GuestErrorInfo ge(GuestErrorInfo::Type_Directory, vrcGuest, mData.mOpenInfo.mPath.c_str());
1107 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Closing guest directory failed: %s"),
1108 GuestBase::getErrorAsString(ge).c_str());
1109 break;
1110 }
1111 case VERR_NOT_SUPPORTED:
1112 /* Silently skip old Guest Additions which do not support killing the
1113 * the guest directory handling process. */
1114 break;
1115
1116 default:
1117 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc,
1118 tr("Closing guest directory \"%s\" failed: %Rrc"), mData.mOpenInfo.mPath.c_str(), vrc);
1119 break;
1120 }
1121 }
1122
1123 return hrc;
1124}
1125
1126HRESULT GuestDirectory::read(ComPtr<IFsObjInfo> &aObjInfo)
1127{
1128 AutoCaller autoCaller(this);
1129 if (FAILED(autoCaller.hrc())) return autoCaller.hrc();
1130
1131 LogFlowThisFuncEnter();
1132
1133 HRESULT hrc = S_OK;
1134
1135 ComObjPtr<GuestFsObjInfo> fsObjInfo;
1136 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS;
1137 int vrc = i_read(fsObjInfo, &vrcGuest);
1138 if (RT_SUCCESS(vrc))
1139 {
1140 /* Return info object to the caller. */
1141 hrc = fsObjInfo.queryInterfaceTo(aObjInfo.asOutParam());
1142 }
1143 else
1144 {
1145 switch (vrc)
1146 {
1147 case VERR_GSTCTL_GUEST_ERROR:
1148 {
1149 GuestErrorInfo ge(
1150#ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT
1151 GuestErrorInfo::Type_ToolLs
1152#else
1153 GuestErrorInfo::Type_Fs
1154#endif
1155 , vrcGuest, mData.mOpenInfo.mPath.c_str());
1156 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Reading guest directory failed: %s"),
1157 GuestBase::getErrorAsString(ge).c_str());
1158 break;
1159 }
1160
1161#ifdef VBOX_WITH_GSTCTL_TOOLBOX_SUPPORT
1162 case VERR_GSTCTL_PROCESS_EXIT_CODE:
1163 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading guest directory \"%s\" failed: %Rrc"),
1164 mData.mOpenInfo.mPath.c_str(), mData.mProcessTool.getRc());
1165 break;
1166#endif
1167 case VERR_PATH_NOT_FOUND:
1168 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading guest directory \"%s\" failed: Path not found"),
1169 mData.mOpenInfo.mPath.c_str());
1170 break;
1171
1172 case VERR_NO_MORE_FILES:
1173 /* See SDK reference. */
1174 hrc = setErrorBoth(VBOX_E_OBJECT_NOT_FOUND, vrc, tr("Reading guest directory \"%s\" failed: No more entries"),
1175 mData.mOpenInfo.mPath.c_str());
1176 break;
1177
1178 default:
1179 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading guest directory \"%s\" returned unhandled error: %Rrc\n"),
1180 mData.mOpenInfo.mPath.c_str(), vrc);
1181 break;
1182 }
1183 }
1184
1185 LogFlowThisFunc(("Returning hrc=%Rhrc / vrc=%Rrc\n", hrc, vrc));
1186 return hrc;
1187}
1188
1189HRESULT GuestDirectory::rewind(void)
1190{
1191 AutoCaller autoCaller(this);
1192 if (FAILED(autoCaller.hrc())) return autoCaller.hrc();
1193
1194 int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS;
1195 int vrc = i_rewind(30 * 1000 /* Timeout in ms */, &vrcGuest);
1196 if (RT_SUCCESS(vrc))
1197 return S_OK;
1198
1199 GuestErrorInfo ge(GuestErrorInfo::Type_Directory, vrcGuest, mData.mOpenInfo.mPath.c_str());
1200 return setErrorBoth(VBOX_E_IPRT_ERROR, vrcGuest, tr("Rewinding guest directory failed: %s"),
1201 GuestBase::getErrorAsString(ge).c_str());
1202}
1203
Note: See TracBrowser for help on using the repository browser.

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