Changeset 79423 in vbox for trunk/src/VBox/ValidationKit/utils
- Timestamp:
- Jun 28, 2019 8:35:10 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/TestExecServ/TestExecService.cpp
r79416 r79423 355 355 356 356 pReply->cb = (uint32_t)sizeof(TXSPKTHDR) + (uint32_t)cbExtra; 357 pReply->uCrc32 = 0; 357 pReply->uCrc32 = 0; /* (txsSendPkt sets it) */ 358 358 359 359 return txsSendPkt(pReply); … … 629 629 } 630 630 } 631 /* Undo dollar escape sequences: $$ -> $ */ 632 else if (pszDollar[1] == '$') 633 { 634 size_t cchLeft = cchNew - (&pszDollar[1] - pszNew); 635 memmove(pszDollar, &pszDollar[1], cchLeft); 636 pszDollar[cchLeft] = '\0'; 637 cchNew -= 1; 638 } 631 639 } 632 640 … … 779 787 } 780 788 781 ///** 782 // * Expands the variables in the string and sends it back to the host. 783 // * 784 // * @returns IPRT status code from send. 785 // * @param pPktHdr The expand string packet. 786 // */ 787 //static int txsDoExpandString(PCTXSPKTHDR pPktHdr) 788 //{ 789 // int rc; 790 // char *pszIn; 791 // if (!txsIsStringPktValid(pPktHdr, "string", &pszIn, &rc)) 792 // return rc; 793 // 794 // txsReplyRc 795 // 796 //} 789 /** 790 * Expands the variables in the string and sends it back to the host. 791 * 792 * @returns IPRT status code from send. 793 * @param pPktHdr The expand string packet. 794 */ 795 static int txsDoExpandString(PCTXSPKTHDR pPktHdr) 796 { 797 int rc; 798 char *pszExpanded; 799 if (!txsIsStringPktValid(pPktHdr, "string", &pszExpanded, &rc)) 800 return rc; 801 802 struct 803 { 804 TXSPKTHDR Hdr; 805 char szString[_64K]; 806 char abPadding[TXSPKT_ALIGNMENT]; 807 } Pkt; 808 809 size_t const cbExpanded = strlen(pszExpanded) + 1; 810 if (cbExpanded <= sizeof(Pkt.szString)) 811 { 812 memcpy(Pkt.szString, pszExpanded, cbExpanded); 813 rc = txsReplyInternal(&Pkt.Hdr, "STRING ", cbExpanded); 814 } 815 else 816 { 817 memcpy(Pkt.szString, pszExpanded, sizeof(Pkt.szString)); 818 Pkt.szString[0] = '\0'; 819 rc = txsReplyInternal(&Pkt.Hdr, "SHORTSTR", sizeof(Pkt.szString)); 820 } 821 822 RTStrFree(pszExpanded); 823 return rc; 824 } 797 825 798 826 /** … … 1061 1089 } 1062 1090 1091 /** 1092 * Worker for STAT and LSTAT for packing down the file info reply. 1093 * 1094 * @returns IPRT status code from send. 1095 * @param pInfo The info to pack down. 1096 */ 1097 static int txsReplyObjInfo(PCRTFSOBJINFO pInfo) 1098 { 1099 struct 1100 { 1101 TXSPKTHDR Hdr; 1102 int64_t cbObject; 1103 int64_t cbAllocated; 1104 int64_t nsAccessTime; 1105 int64_t nsModificationTime; 1106 int64_t nsChangeTime; 1107 int64_t nsBirthTime; 1108 uint32_t fMode; 1109 uint32_t uid; 1110 uint32_t gid; 1111 uint32_t cHardLinks; 1112 uint64_t INodeIdDevice; 1113 uint64_t INodeId; 1114 uint64_t Device; 1115 char abPadding[TXSPKT_ALIGNMENT]; 1116 } Pkt; 1117 1118 Pkt.cbObject = pInfo->cbObject; 1119 Pkt.cbAllocated = pInfo->cbAllocated; 1120 Pkt.nsAccessTime = RTTimeSpecGetNano(&pInfo->AccessTime); 1121 Pkt.nsModificationTime = RTTimeSpecGetNano(&pInfo->ModificationTime); 1122 Pkt.nsChangeTime = RTTimeSpecGetNano(&pInfo->ChangeTime); 1123 Pkt.nsBirthTime = RTTimeSpecGetNano(&pInfo->BirthTime); 1124 Pkt.fMode = pInfo->Attr.fMode; 1125 Pkt.uid = pInfo->Attr.u.Unix.uid; 1126 Pkt.gid = pInfo->Attr.u.Unix.gid; 1127 Pkt.cHardLinks = pInfo->Attr.u.Unix.cHardlinks; 1128 Pkt.INodeIdDevice = pInfo->Attr.u.Unix.INodeIdDevice; 1129 Pkt.INodeId = pInfo->Attr.u.Unix.INodeId; 1130 Pkt.Device = pInfo->Attr.u.Unix.Device; 1131 1132 return txsReplyInternal(&Pkt.Hdr, "FILEINFO", sizeof(Pkt) - TXSPKT_ALIGNMENT - sizeof(TXSPKTHDR)); 1133 } 1063 1134 1064 1135 /** … … 1079 1150 rc = RTPathQueryInfoEx(pszPath, &Info, RTFSOBJATTRADD_UNIX, RTPATH_F_ON_LINK); 1080 1151 if (RT_SUCCESS(rc)) 1081 /** @todo figure out how to format the return buffer here. */ 1082 rc = txsReplyNotImplemented(pPktHdr); 1152 rc = txsReplyObjInfo(&Info); 1083 1153 else 1084 1154 rc = txsReplyRC(pPktHdr, rc, "RTPathQueryInfoEx(\"%s\",,UNIX,ON_LINK)", pszPath); … … 1104 1174 rc = RTPathQueryInfoEx(pszPath, &Info, RTFSOBJATTRADD_UNIX, RTPATH_F_FOLLOW_LINK); 1105 1175 if (RT_SUCCESS(rc)) 1106 /** @todo figure out how to format the return buffer here. */ 1107 rc = txsReplyNotImplemented(pPktHdr); 1176 rc = txsReplyObjInfo(&Info); 1108 1177 else 1109 1178 rc = txsReplyRC(pPktHdr, rc, "RTPathQueryInfoEx(\"%s\",,UNIX,FOLLOW_LINK)", pszPath); … … 1192 1261 1193 1262 /** 1194 * Changes the group of a file, directory ofsymbolic link.1263 * Changes the owner of a file, directory or symbolic link. 1195 1264 * 1196 1265 * @returns IPRT status code from send. 1197 1266 * @param pPktHdr The chmod packet. 1198 1267 */ 1199 static int txsDoChGrp(PCTXSPKTHDR pPktHdr) 1200 { 1268 static int txsDoChOwn(PCTXSPKTHDR pPktHdr) 1269 { 1270 #ifdef RT_OS_WINDOWS 1201 1271 return txsReplyNotImplemented(pPktHdr); 1202 } 1203 1204 /** 1205 * Changes the owner of a file, directory of symbolic link. 1206 * 1207 * @returns IPRT status code from send. 1208 * @param pPktHdr The chmod packet. 1209 */ 1210 static int txsDoChOwn(PCTXSPKTHDR pPktHdr) 1211 { 1212 return txsReplyNotImplemented(pPktHdr); 1272 #else 1273 /* After the packet header follows a 32-bit UID and 32-bit GID, while the 1274 remainder of the packet is the zero terminated path. */ 1275 size_t const cbMin = sizeof(TXSPKTHDR) + sizeof(RTFMODE) + 2; 1276 if (pPktHdr->cb < cbMin) 1277 return txsReplyBadMinSize(pPktHdr, cbMin); 1278 1279 int rc; 1280 char *pszPath; 1281 if (!txsIsStringValid(pPktHdr, "path", (const char *)(pPktHdr + 1) + sizeof(uint32_t) * 2, &pszPath, NULL, &rc)) 1282 return rc; 1283 1284 uint32_t uid = ((uint32_t const *)(pPktHdr + 1))[0]; 1285 uint32_t gid = ((uint32_t const *)(pPktHdr + 1))[1]; 1286 1287 rc = RTPathSetOwnerEx(pszPath, uid, gid, RTPATH_F_ON_LINK); 1288 1289 rc = txsReplyRC(pPktHdr, rc, "RTPathSetOwnerEx(\"%s\", %u, %u)", pszPath, uid, gid); 1290 RTStrFree(pszPath); 1291 return rc; 1292 #endif 1213 1293 } 1214 1294 … … 1350 1430 1351 1431 RTFMODE fMode = *(RTFMODE const *)(pPktHdr + 1); 1352 rc = RTDirCreateFullPath(pszPath, fMode); 1432 1433 rc = RTDirCreateFullPathEx(pszPath, fMode, RTDIRCREATE_FLAGS_IGNORE_UMASK); 1353 1434 1354 1435 rc = txsReplyRC(pPktHdr, rc, "RTDirCreateFullPath(\"%s\", %#x)", pszPath, fMode); … … 1377 1458 1378 1459 RTFMODE fMode = *(RTFMODE const *)(pPktHdr + 1); 1379 rc = RTDirCreate(pszPath, fMode, 0);1460 rc = RTDirCreate(pszPath, fMode, RTDIRCREATE_FLAGS_IGNORE_UMASK); 1380 1461 1381 1462 rc = txsReplyRC(pPktHdr, rc, "RTDirCreate(\"%s\", %#x)", pszPath, fMode); … … 2910 2991 else if (txsIsSameOpcode(pPktHdr, "CHOWN ")) 2911 2992 rc = txsDoChOwn(pPktHdr); 2912 else if (txsIsSameOpcode(pPktHdr, "CHGRP "))2913 rc = txsDoChGrp(pPktHdr);2914 2993 else if (txsIsSameOpcode(pPktHdr, "ISDIR ")) 2915 2994 rc = txsDoIsDir(pPktHdr); … … 2933 3012 rc = txsDoUnpackFile(pPktHdr); 2934 3013 /* Misc: */ 2935 //else if (txsIsSameOpcode(pPktHdr, "EXP STR "))2936 //rc = txsDoExpandString(pPktHdr);3014 else if (txsIsSameOpcode(pPktHdr, "EXP STR ")) 3015 rc = txsDoExpandString(pPktHdr); 2937 3016 else 2938 3017 rc = txsReplyUnknown(pPktHdr);
Note:
See TracChangeset
for help on using the changeset viewer.