Changeset 98824 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Mar 2, 2023 5:06:36 PM (21 months ago)
- Location:
- trunk/src/VBox/Additions/common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibGuestCtrl.cpp
r98818 r98824 1071 1071 * @param pCtx Guest control command context to use. 1072 1072 * @param puHandle Where to return the directory handle to rewind. 1073 * @param pcbDirEntry Where to return the directory entry size. 1074 */ 1075 VBGLR3DECL(int) VbglR3GuestCtrlDirGetRead(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, uint32_t *pcbDirEntry) 1076 { 1077 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1078 AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER); 1073 */ 1074 VBGLR3DECL(int) VbglR3GuestCtrlDirGetRead(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle) 1075 { 1076 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1077 AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER); 1079 1078 1080 1079 AssertPtrReturn(puHandle, VERR_INVALID_POINTER); 1081 AssertPtrReturn(pcbDirEntry, VERR_INVALID_POINTER);1082 1080 1083 1081 int rc; … … 1088 1086 VbglHGCMParmUInt32Set(&Msg.context, HOST_MSG_DIR_READ); 1089 1087 VbglHGCMParmUInt32Set(&Msg.handle, 0); 1090 VbglHGCMParmUInt32Set(&Msg.max_entry_size, 0);1091 1088 1092 1089 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); … … 1095 1092 Msg.context.GetUInt32(&pCtx->uContextID); 1096 1093 Msg.handle.GetUInt32(puHandle); 1097 Msg.max_entry_size.GetUInt32(pcbDirEntry);1098 1094 } 1099 1095 } while (rc == VERR_INTERRUPTED && g_fVbglR3GuestCtrlHavePeekGetCancel); … … 2274 2270 * @param uRc Guest rc of operation (note: IPRT-style signed int). 2275 2271 * @param pEntry Directory entry to send. 2276 * @param cbSize Size (in bytes) of \a pDirEntry to send. 2277 * This might be needed as the size can be bigger than GSTCTLDIRENTRYEX. 2272 * @param cbSize Size (in bytes) of the OFFSET(GSTCTLDIRENTRYEX, szName[pEntry->cbName + 1]). 2278 2273 * See RTDirReadEx() for more information. 2279 2274 * @param pszUser Associated user ID (owner, uid) as a string. … … 2309 2304 * @param uRc Guest rc of operation (note: IPRT-style signed int). 2310 2305 * @param pEntry Directory entry to send. 2311 * @param cbSize Size (in bytes) of \a pDirEntry to send. 2312 * This might be needed as the size can be bigger than GSTCTLDIRENTRYEX. 2306 * @param cbSize Size (in bytes) of the OFFSET(GSTCTLDIRENTRYEX, szName[pEntry->cbName + 1]). 2313 2307 * See RTDirReadEx() for more information. 2314 2308 */ -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.h
r98818 r98824 33 33 34 34 #include <iprt/critsect.h> 35 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 36 # include <iprt/dir.h> 37 #endif 35 38 #include <iprt/list.h> 36 39 #include <iprt/req.h> … … 225 228 /** How many processes do we allow keeping around at a time? */ 226 229 uint32_t uProcsMaxKept; 230 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 227 231 /** The uid cache for this session. */ 228 232 VGSVCIDCACHE UidCache; 229 233 /** The gid cache for this session. */ 230 234 VGSVCIDCACHE GidCache; 235 /** Scratch buffer for holding the directory reading entry. 236 * Currently NOT serialized, i.e. only can be used for one read at a time. */ 237 PRTDIRENTRYEX pDirEntryEx; 238 /** Size (in bytes) of \a pDirEntryEx. */ 239 size_t cbDirEntryEx; 240 #endif 231 241 } VBOXSERVICECTRLSESSION; 232 242 /** Pointer to guest session. */ -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r98818 r98824 1142 1142 * Retrieve the message. 1143 1143 */ 1144 uint32_t uHandle; 1145 size_t cbDirEntry = 0; 1146 GSTCTLDIRENTRYEX DirEntryEx; 1147 int rc = VbglR3GuestCtrlDirGetRead(pHostCtx, &uHandle, (uint32_t *)&cbDirEntry); 1144 uint32_t uHandle; 1145 int rc = VbglR3GuestCtrlDirGetRead(pHostCtx, &uHandle); 1148 1146 if (RT_SUCCESS(rc)) 1149 1147 { … … 1151 1149 if (pDir) 1152 1150 { 1153 RT_ZERO(DirEntryEx); 1151 PRTDIRENTRYEX pDirEntryEx = pSession->pDirEntryEx; 1152 1153 size_t cbDirEntry = pSession->cbDirEntryEx; 1154 rc = RTDirReadEx(pDir->hDir, pDirEntryEx, &cbDirEntry, (RTFSOBJATTRADD)pDir->enmReadAttrAdd, pDir->fRead); 1155 1156 /* Paranoia. */ 1157 AssertStmt(cbDirEntry <= pSession->cbDirEntryEx, rc = VERR_BUFFER_OVERFLOW); 1158 1159 VGSvcVerbose(2, "[Dir %s] Read next entry '%s' -> %Rrc (%zu bytes)\n", 1160 pDir->pszPathAbs, RT_SUCCESS(rc) ? pDirEntryEx->szName : "<None>", rc, cbDirEntry); 1161 1162 const char *pszUser = VGSvcIdCacheGetUidName(&pSession->UidCache, 1163 pDirEntryEx->Info.Attr.u.Unix.uid, pDirEntryEx->szName, pDir->pszPathAbs); 1164 const char *pszGroup = VGSvcIdCacheGetGidName(&pSession->GidCache, 1165 pDirEntryEx->Info.Attr.u.Unix.gid, pDirEntryEx->szName, pDir->pszPathAbs); 1166 1167 VGSvcVerbose(2, "[Dir %s] Entry '%s': %zu bytes, uid=%s (%d), gid=%s (%d)\n", 1168 pDir->pszPathAbs, pDirEntryEx->szName, pDirEntryEx->Info.cbObject, 1169 pszUser ? pszUser : "", pDirEntryEx->Info.Attr.u.UnixOwner.uid, 1170 pszGroup ? pszGroup : "", pDirEntryEx->Info.Attr.u.UnixGroup.gid); 1154 1171 1155 1172 /* … … 1159 1176 * Ditto for RTFSOBJATTRADD == GSTCTLFSOBJATTRADD. 1160 1177 */ 1161 AssertCompileSize(DirEntryEx, sizeof(RTDIRENTRYEX)); 1162 AssertCompile (RT_OFFSETOF(GSTCTLDIRENTRYEX, Info) == RT_OFFSETOF(RTDIRENTRYEX, Info)); 1163 AssertCompile (RT_OFFSETOF(GSTCTLDIRENTRYEX, szName) == RT_OFFSETOF(RTDIRENTRYEX, szName)); 1164 AssertCompile (RT_OFFSETOF(GSTCTLFSOBJINFO, Attr) == RT_OFFSETOF(RTFSOBJINFO, Attr)); 1165 1166 PRTDIRENTRYEX pDirEntryExRuntime = (PRTDIRENTRYEX)&DirEntryEx; 1167 1168 rc = RTDirReadEx(pDir->hDir, pDirEntryExRuntime, &cbDirEntry, (RTFSOBJATTRADD)pDir->enmReadAttrAdd, pDir->fRead); 1169 1170 /* Paranoia. */ 1171 AssertStmt(cbDirEntry <= _256K, rc = VERR_BUFFER_OVERFLOW); 1172 1173 VGSvcVerbose(2, "[Dir %s] Read next entry '%s' -> %Rrc\n", 1174 pDir->pszPathAbs, RT_SUCCESS(rc) ? DirEntryEx.szName : "<None>", rc); 1175 1176 const char *pszUser = VGSvcIdCacheGetUidName(&pSession->UidCache, DirEntryEx.Info.Attr.u.Unix.uid, DirEntryEx.szName, 1177 pDir->pszPathAbs); 1178 const char *pszGroup = VGSvcIdCacheGetGidName(&pSession->GidCache, DirEntryEx.Info.Attr.u.Unix.gid, DirEntryEx.szName, 1179 pDir->pszPathAbs); 1180 1181 VGSvcVerbose(2, "[Dir %s] Entry '%s': %zu bytes, uid=%s (%d), gid=%s (%d)\n", 1182 pDir->pszPathAbs, DirEntryEx.szName, DirEntryEx.Info.cbObject, 1183 pszUser ? pszUser : "", DirEntryEx.Info.Attr.u.UnixOwner.uid, 1184 pszGroup ? pszGroup : "", DirEntryEx.Info.Attr.u.UnixGroup.gid); 1185 1186 int rc2 = VbglR3GuestCtrlDirCbReadEx(pHostCtx, rc, 1187 &DirEntryEx, (uint32_t)(sizeof(GSTCTLDIRENTRYEX) + cbDirEntry), 1188 pszUser, pszGroup); 1178 AssertCompile(sizeof(GSTCTLDIRENTRYEX) == sizeof(RTDIRENTRYEX)); 1179 AssertCompile(RT_OFFSETOF(GSTCTLDIRENTRYEX, Info) == RT_OFFSETOF(RTDIRENTRYEX, Info)); 1180 AssertCompile(RT_OFFSETOF(GSTCTLDIRENTRYEX, cbName) == RT_OFFSETOF(RTDIRENTRYEX, cbName)); 1181 AssertCompile(RT_OFFSETOF(GSTCTLDIRENTRYEX, szName) == RT_OFFSETOF(RTDIRENTRYEX, szName)); 1182 AssertCompile(RT_OFFSETOF(GSTCTLFSOBJINFO, Attr) == RT_OFFSETOF(RTFSOBJINFO, Attr)); 1183 1184 PGSTCTLDIRENTRYEX pGstCtlDirEntryEx = (PGSTCTLDIRENTRYEX)pDirEntryEx; 1185 1186 int rc2 = VbglR3GuestCtrlDirCbReadEx(pHostCtx, rc, pGstCtlDirEntryEx, cbDirEntry, pszUser, pszGroup); 1189 1187 if (RT_FAILURE(rc2)) 1190 1188 VGSvcError("Failed to report directory read status (%Rrc), rc=%Rrc\n", rc, rc2); … … 2728 2726 int rc = VGSvcGstCtrlSessionClose(pSession); 2729 2727 2728 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 2729 RTMemFree(pSession->pDirEntryEx); 2730 #endif 2731 2730 2732 /* Destroy critical section. */ 2731 2733 RTCritSectDelete(&pSession->CritSect); … … 2750 2752 pSession->fFlags = fFlags; 2751 2753 2754 #ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS 2752 2755 RT_ZERO(pSession->UidCache); 2753 2756 RT_ZERO(pSession->GidCache); 2757 2758 pSession->cbDirEntryEx = GSTCTL_DIRENTRY_MAX_SIZE; 2759 pSession->pDirEntryEx = (PRTDIRENTRYEX)RTMemAlloc(pSession->cbDirEntryEx); 2760 AssertPtrReturn(pSession->pDirEntryEx, VERR_NO_MEMORY); 2761 #endif 2754 2762 2755 2763 /* Init critical section for protecting the thread lists. */
Note:
See TracChangeset
for help on using the changeset viewer.