Changeset 99147 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Mar 23, 2023 5:08:44 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r99120 r99147 141 141 * Must be released via vgsvcGstCtrlSessionDirRelease(). 142 142 * 143 * @returns VBox status code.143 * @returns Guest directory entry on success, or NULL if not found. 144 144 * @param pSession Guest control session to acquire guest directory for. 145 145 * @param uHandle Handle of directory to acquire. … … 175 175 176 176 177 /** 178 * Free's a guest file entry. 179 * 180 * @returns VBox status code. 181 * @param pFile Guest file entry to free. 182 * The pointer wil be invalid on success. 183 */ 177 184 static int vgsvcGstCtrlSessionFileFree(PVBOXSERVICECTRLFILE pFile) 178 185 { … … 194 201 195 202 196 /** @todo No locking done yet! */ 197 static PVBOXSERVICECTRLFILE vgsvcGstCtrlSessionFileGetLocked(const PVBOXSERVICECTRLSESSION pSession, uint32_t uHandle) 203 /** 204 * Acquires an internal guest file entry. 205 * 206 * Must be released via vgsvcGstCtrlSessionFileRelease(). 207 * 208 * @returns Guest file entry on success, or NULL if not found. 209 * @param pSession Guest session to use. 210 * @param uHandle Handle of guest file entry to acquire. 211 * 212 * @note No locking done yet. 213 */ 214 static PVBOXSERVICECTRLFILE vgsvcGstCtrlSessionFileAcquire(const PVBOXSERVICECTRLSESSION pSession, uint32_t uHandle) 198 215 { 199 216 AssertPtrReturn(pSession, NULL); … … 208 225 209 226 return NULL; 227 } 228 229 230 /** 231 * Releases a formerly acquired guest file. 232 * 233 * @param pFile File to release. 234 */ 235 static void vgsvcGstCtrlSessionFileRelease(PVBOXSERVICECTRLFILE pFile) 236 { 237 RT_NOREF(pFile); 210 238 } 211 239 … … 514 542 if (RT_SUCCESS(rc)) 515 543 { 516 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFile GetLocked(pSession, uHandle);544 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileAcquire(pSession, uHandle); 517 545 if (pFile) 518 546 { … … 568 596 uint32_t offNew = 0; 569 597 size_t cbRead = 0; 570 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFile GetLocked(pSession, uHandle);598 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileAcquire(pSession, uHandle); 571 599 if (pFile) 572 600 { … … 577 605 offNew = (int64_t)RTFileTell(pFile->hFile); 578 606 VGSvcVerbose(5, "[File %s] Read %zu/%RU32 bytes, rc=%Rrc, offNew=%RI64\n", pFile->pszName, cbRead, cbToRead, rc, offNew); 607 vgsvcGstCtrlSessionFileRelease(pFile); 579 608 } 580 609 else … … 631 660 int64_t offNew = 0; 632 661 size_t cbRead = 0; 633 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFile GetLocked(pSession, uHandle);662 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileAcquire(pSession, uHandle); 634 663 if (pFile) 635 664 { … … 646 675 offNew = (int64_t)RTFileTell(pFile->hFile); 647 676 VGSvcVerbose(5, "[File %s] Read %zu bytes @ %RU64, rc=%Rrc, offNew=%RI64\n", pFile->pszName, cbRead, offReadAt, rc, offNew); 677 vgsvcGstCtrlSessionFileRelease(pFile); 648 678 } 649 679 else … … 699 729 int64_t offNew = 0; 700 730 size_t cbWritten = 0; 701 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFile GetLocked(pSession, uHandle);731 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileAcquire(pSession, uHandle); 702 732 if (pFile) 703 733 { … … 706 736 VGSvcVerbose(5, "[File %s] Writing %p LB %RU32 => %Rrc, cbWritten=%zu, offNew=%RI64\n", 707 737 pFile->pszName, *ppvScratchBuf, RT_MIN(cbToWrite, *pcbScratchBuf), rc, cbWritten, offNew); 738 vgsvcGstCtrlSessionFileRelease(pFile); 708 739 } 709 740 else … … 760 791 int64_t offNew = 0; 761 792 size_t cbWritten = 0; 762 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFile GetLocked(pSession, uHandle);793 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileAcquire(pSession, uHandle); 763 794 if (pFile) 764 795 { … … 778 809 VGSvcVerbose(5, "[File %s] Writing %p LB %RU32 @ %RU64 => %Rrc, cbWritten=%zu, offNew=%RI64\n", 779 810 pFile->pszName, *ppvScratchBuf, RT_MIN(cbToWrite, *pcbScratchBuf), offWriteAt, rc, cbWritten, offNew); 811 vgsvcGstCtrlSessionFileRelease(pFile); 780 812 } 781 813 else … … 839 871 * Locate the file and do the seek. 840 872 */ 841 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFile GetLocked(pSession, uHandle);873 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileAcquire(pSession, uHandle); 842 874 if (pFile) 843 875 { … … 845 877 VGSvcVerbose(5, "[File %s]: Seeking to offSeek=%RI64, uSeekMethodIPRT=%u, rc=%Rrc\n", 846 878 pFile->pszName, offSeek, s_abMethods[uSeekMethod], rc); 879 vgsvcGstCtrlSessionFileRelease(pFile); 847 880 } 848 881 else … … 894 927 */ 895 928 uint64_t offCurrent = 0; 896 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFile GetLocked(pSession, uHandle);929 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileAcquire(pSession, uHandle); 897 930 if (pFile) 898 931 { 899 932 offCurrent = RTFileTell(pFile->hFile); 900 933 VGSvcVerbose(5, "[File %s]: Telling offCurrent=%RU64\n", pFile->pszName, offCurrent); 934 vgsvcGstCtrlSessionFileRelease(pFile); 901 935 } 902 936 else … … 942 976 * Locate the file and ask for the current position. 943 977 */ 944 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFile GetLocked(pSession, uHandle);978 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileAcquire(pSession, uHandle); 945 979 if (pFile) 946 980 { 947 981 rc = RTFileSetSize(pFile->hFile, cbNew); 948 982 VGSvcVerbose(5, "[File %s]: Changing size to %RU64 (%#RX64), rc=%Rrc\n", pFile->pszName, cbNew, cbNew, rc); 983 vgsvcGstCtrlSessionFileRelease(pFile); 949 984 } 950 985 else … … 1111 1146 VGSvcVerbose(2, "[Dir %s] Closing (handle=%RU32)\n", pDir ? pDir->pszPathAbs : "<Not found>", uHandle); 1112 1147 rc = vgsvcGstCtrlSessionDirFree(pDir); 1113 1114 vgsvcGstCtrlSessionDirRelease(pDir);1115 1148 } 1116 1149 else
Note:
See TracChangeset
for help on using the changeset viewer.