vbox的更動 60622 路徑 trunk/src/VBox/Additions
- 時間撮記:
- 2016-4-21 下午01:00:20 (9 年 以前)
- 位置:
- trunk/src/VBox/Additions/common/VBoxService
- 檔案:
-
- 新增 1 筆資料
- 修改 5 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp
r60583 r60622 91 91 #ifdef VBOX_WITH_VBOXSERVICE_CONTROL 92 92 # include "VBoxServiceControl.h" 93 #endif 94 #ifdef VBOX_WITH_VBOXSERVICE_TOOLBOX 95 # include "VBoxServiceToolBox.h" 93 96 #endif 94 97 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.h
r59134 r60622 5 5 6 6 /* 7 * Copyright (C) 2013-201 5Oracle Corporation7 * Copyright (C) 2013-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 24 24 25 25 #include <VBox/VBoxGuestLib.h> 26 #include <VBox/GuestHost/GuestControl.h> 26 27 #include <VBox/HostServices/GuestControlSvc.h> 27 28 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlProcess.cpp
r60583 r60622 40 40 #include "VBoxServiceInternal.h" 41 41 #include "VBoxServiceControl.h" 42 #include "VBoxServiceToolBox.h" 42 43 43 44 using namespace guestControl; -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h
r60583 r60622 200 200 #endif 201 201 202 #ifdef VBOX_WITH_VBOXSERVICE_TOOLBOX203 extern bool VGSvcToolboxMain(int argc, char **argv, RTEXITCODE *prcExit);204 #endif205 206 202 #ifdef RT_OS_WINDOWS 207 203 # ifdef VBOX_WITH_GUEST_PROPS -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceToolBox.cpp
r58089 r60622 5 5 6 6 /* 7 * Copyright (C) 2012-201 5Oracle Corporation7 * Copyright (C) 2012-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 41 41 #include <VBox/VBoxGuestLib.h> 42 42 #include <VBox/version.h> 43 44 #include <VBox/GuestHost/GuestControl.h> 45 43 46 #include "VBoxServiceInternal.h" 47 #include "VBoxServiceToolBox.h" 44 48 #include "VBoxServiceUtils.h" 45 49 50 using namespace guestControl; 46 51 47 52 /********************************************************************************************************************************* … … 78 83 } VBOXSERVICETOOLBOXOUTPUTFLAG; 79 84 85 /********************************************************************************************************************************* 86 * Prototypes * 87 *********************************************************************************************************************************/ 88 static RTEXITCODE vgsvcToolboxCat(int argc, char **argv); 89 static RTEXITCODE vgsvcToolboxLs(int argc, char **argv); 90 static RTEXITCODE vgsvcToolboxRm(int argc, char **argv); 91 static RTEXITCODE vgsvcToolboxMkTemp(int argc, char **argv); 92 static RTEXITCODE vgsvcToolboxMkDir(int argc, char **argv); 93 static RTEXITCODE vgsvcToolboxStat(int argc, char **argv); 80 94 81 95 /********************************************************************************************************************************* 82 96 * Structures and Typedefs * 83 97 *********************************************************************************************************************************/ 84 /** Pointer to a handler function. */98 /** Pointer to a tool handler function. */ 85 99 typedef RTEXITCODE (*PFNHANDLER)(int , char **); 100 101 /** Definition for a specific toolbox tool. */ 102 typedef struct VBOXSERVICETOOLBOXTOOL 103 { 104 /** Friendly name of the tool. */ 105 const char *pszName; 106 /** Main handler to be invoked to use the tool. */ 107 RTEXITCODE (*pfnHandler)(int argc, char **argv); 108 /** Conversion routine to convert the tool's exit code back to an IPRT rc. Optional. */ 109 int (*pfnExitCodeConvertToRc)(RTEXITCODE rcExit); 110 } VBOXSERVICETOOLBOXTOOL, *PVBOXSERVICETOOLBOXTOOL; 111 112 static VBOXSERVICETOOLBOXTOOL s_aTools[] = 113 { 114 { VBOXSERVICE_TOOL_CAT, vgsvcToolboxCat , NULL }, 115 { VBOXSERVICE_TOOL_LS, vgsvcToolboxLs , NULL }, 116 { VBOXSERVICE_TOOL_RM, vgsvcToolboxRm , NULL }, 117 { VBOXSERVICE_TOOL_MKTEMP, vgsvcToolboxMkTemp, NULL }, 118 { VBOXSERVICE_TOOL_MKDIR, vgsvcToolboxMkDir , NULL }, 119 { VBOXSERVICE_TOOL_STAT, vgsvcToolboxStat , NULL } 120 }; 86 121 87 122 /** … … 468 503 } 469 504 470 /* If no tinput files were defined, process stdin. */505 /* If no input files were defined, process stdin. */ 471 506 if (RTListNodeIsFirst(&inputList, &inputList)) 472 507 rc = vgsvcToolboxCatOutput(hInput, hOutput); … … 478 513 vgsvcToolboxPathBufDestroy(&inputList); 479 514 480 return RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 515 if (RT_FAILURE(rc)) 516 { 517 switch (rc) 518 { 519 case VERR_ACCESS_DENIED: 520 return (RTEXITCODE)VBOXSERVICETOOLBOX_CAT_EXITCODE_ACCESS_DENIED; 521 522 case VERR_FILE_NOT_FOUND: 523 return (RTEXITCODE)VBOXSERVICETOOLBOX_CAT_EXITCODE_FILE_NOT_FOUND; 524 525 case VERR_PATH_NOT_FOUND: 526 return (RTEXITCODE)VBOXSERVICETOOLBOX_CAT_EXITCODE_PATH_NOT_FOUND; 527 528 case VERR_SHARING_VIOLATION: 529 return (RTEXITCODE)VBOXSERVICETOOLBOX_CAT_EXITCODE_SHARING_VIOLATION; 530 531 default: 532 AssertMsgFailed(("Exit code for %Rrc not implemented\n", rc)); 533 break; 534 } 535 536 return RTEXITCODE_FAILURE; 537 } 538 539 return RTEXITCODE_SUCCESS; 481 540 } 482 541 … … 1403 1462 if (RT_FAILURE(rc2)) 1404 1463 { 1405 /** @todo r=bird: You can get a number of other errors here, like access denied. */1406 1464 if (!(fOutputFlags & VBOXSERVICETOOLBOXOUTPUTFLAG_PARSEABLE)) 1407 RTMsgError("Cannot stat for '%s': No such file or directory (%Rrc)\n", pNodeIt->pszName, rc); 1408 rc = VERR_FILE_NOT_FOUND; 1409 /* Do not break here -- process every element in the list 1410 * and keep failing rc. */ 1465 RTMsgError("Cannot stat for '%s': %Rrc\n", pNodeIt->pszName, rc2); 1411 1466 } 1412 1467 else … … 1416 1471 fOutputFlags, 1417 1472 &objInfo); 1418 if (RT_FAILURE(rc2))1419 rc = rc2;1420 1473 } 1474 1475 if (RT_SUCCESS(rc)) 1476 rc = rc2; 1477 /* Do not break here -- process every element in the list 1478 * and keep (initial) failing rc. */ 1421 1479 } 1422 1480 … … 1433 1491 1434 1492 vgsvcToolboxPathBufDestroy(&fileList); 1435 return RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 1436 } 1437 1438 1439 1440 /** 1441 * Looks up the handler for the tool give by @a pszTool. 1442 * 1443 * @returns Pointer to handler function. NULL if not found. 1493 1494 if (RT_FAILURE(rc)) 1495 { 1496 switch (rc) 1497 { 1498 case VERR_ACCESS_DENIED: 1499 return (RTEXITCODE)VBOXSERVICETOOLBOX_STAT_EXITCODE_ACCESS_DENIED; 1500 1501 case VERR_FILE_NOT_FOUND: 1502 return (RTEXITCODE)VBOXSERVICETOOLBOX_STAT_EXITCODE_FILE_NOT_FOUND; 1503 1504 case VERR_PATH_NOT_FOUND: 1505 return (RTEXITCODE)VBOXSERVICETOOLBOX_STAT_EXITCODE_PATH_NOT_FOUND; 1506 1507 default: 1508 AssertMsgFailed(("Exit code for %Rrc not implemented\n", rc)); 1509 break; 1510 } 1511 1512 return RTEXITCODE_FAILURE; 1513 } 1514 1515 return RTEXITCODE_SUCCESS; 1516 } 1517 1518 1519 /** 1520 * Looks up the tool definition entry for the tool give by @a pszTool. 1521 * 1522 * @returns Pointer to the tool definition. NULL if not found. 1444 1523 * @param pszTool The name of the tool. 1445 1524 */ 1446 static PFNHANDLER vgsvcToolboxLookUpHandler(const char *pszTool) 1447 { 1448 static struct 1449 { 1450 const char *pszName; 1451 RTEXITCODE (*pfnHandler)(int argc, char **argv); 1452 } 1453 const s_aTools[] = 1454 { 1455 { "cat", vgsvcToolboxCat }, 1456 { "ls", vgsvcToolboxLs }, 1457 { "rm", vgsvcToolboxRm }, 1458 { "mktemp", vgsvcToolboxMkTemp }, 1459 { "mkdir", vgsvcToolboxMkDir }, 1460 { "stat", vgsvcToolboxStat }, 1461 }; 1462 1463 /* Skip optional 'vbox_' prefix. */ 1464 if ( pszTool[0] == 'v' 1465 && pszTool[1] == 'b' 1466 && pszTool[2] == 'o' 1467 && pszTool[3] == 'x' 1468 && pszTool[4] == '_') 1469 pszTool += 5; 1525 static PVBOXSERVICETOOLBOXTOOL const vgsvcToolboxLookUp(const char *pszTool) 1526 { 1527 AssertPtrReturn(pszTool, NULL); 1470 1528 1471 1529 /* Do a linear search, since we don't have that much stuff in the table. */ 1472 1530 for (unsigned i = 0; i < RT_ELEMENTS(s_aTools); i++) 1473 1531 if (!strcmp(s_aTools[i].pszName, pszTool)) 1474 return s_aTools[i].pfnHandler;1532 return &s_aTools[i]; 1475 1533 1476 1534 return NULL; 1535 } 1536 1537 1538 /** 1539 * Converts a tool's exit code back to an IPRT error code. 1540 * 1541 * @return Converted IPRT status code. 1542 * @param pszTool Name of the toolbox tool to convert exit code for. 1543 * @param rcExit The tool's exit code to convert. 1544 */ 1545 int VGSvcToolboxExitCodeConvertToRc(const char *pszTool, RTEXITCODE rcExit) 1546 { 1547 AssertPtrReturn(pszTool, VERR_INVALID_POINTER); 1548 1549 PVBOXSERVICETOOLBOXTOOL pTool = vgsvcToolboxLookUp(pszTool); 1550 if (pTool) 1551 return pTool->pfnExitCodeConvertToRc(rcExit); 1552 1553 AssertMsgFailed(("Tool '%s' not found\n", pszTool)); 1554 return VERR_GENERAL_FAILURE; /* Lookup failed, should not happen. */ 1477 1555 } 1478 1556 … … 1494 1572 */ 1495 1573 AssertReturn(argc > 0, false); 1496 const char *pszTool= RTPathFilename(argv[0]);1497 P FNHANDLER pfnHandler = vgsvcToolboxLookUpHandler(pszTool);1498 if (!p fnHandler)1574 const char *pszTool = RTPathFilename(argv[0]); 1575 PVBOXSERVICETOOLBOXTOOL pTool = vgsvcToolboxLookUp(pszTool); 1576 if (!pTool) 1499 1577 { 1500 1578 /* … … 1507 1585 argv += 2; 1508 1586 pszTool = argv[0]; 1509 p fnHandler = vgsvcToolboxLookUpHandler(pszTool);1510 if (!p fnHandler)1587 pTool = vgsvcToolboxLookUp(pszTool); 1588 if (!pTool) 1511 1589 { 1512 1590 *prcExit = RTEXITCODE_SUCCESS; … … 1528 1606 */ 1529 1607 RTMsgSetProgName("VBoxService/%s", pszTool); 1530 *prcExit = pfnHandler(argc, argv); 1608 AssertPtr(pTool); 1609 *prcExit = pTool->pfnHandler(argc, argv); 1531 1610 1532 1611 return true;
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器