Changeset 98288 in vbox for trunk/src/VBox/Main/src-server/generic/AutostartDb-generic.cpp
- Timestamp:
- Jan 24, 2023 3:32:43 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/generic/AutostartDb-generic.cpp
r98103 r98288 47 47 int AutostartDb::autostartModifyDb(bool fAutostart, bool fAddVM) 48 48 { 49 int rc = VINF_SUCCESS;49 int vrc = VINF_SUCCESS; 50 50 char *pszUser = NULL; 51 51 … … 54 54 return VERR_PATH_NOT_FOUND; 55 55 56 rc = RTProcQueryUsernameA(RTProcSelf(), &pszUser);57 if (RT_SUCCESS( rc))56 vrc = RTProcQueryUsernameA(RTProcSelf(), &pszUser); 57 if (RT_SUCCESS(vrc)) 58 58 { 59 59 char *pszFile; … … 68 68 fOpen |= RTFILE_O_OPEN; 69 69 70 rc = RTStrAPrintf(&pszFile, "%s/%s.%s", 71 m_pszAutostartDbPath, pszUser, fAutostart ? "start" : "stop"); 72 if (RT_SUCCESS(rc)) 70 vrc = RTStrAPrintf(&pszFile, "%s/%s.%s", m_pszAutostartDbPath, pszUser, fAutostart ? "start" : "stop"); 71 if (RT_SUCCESS(vrc)) 73 72 { 74 rc = RTFileOpen(&hAutostartFile, pszFile, fOpen);75 if (RT_SUCCESS( rc))73 vrc = RTFileOpen(&hAutostartFile, pszFile, fOpen); 74 if (RT_SUCCESS(vrc)) 76 75 { 77 76 uint64_t cbFile; … … 82 81 * should be really really small. Anything else is bogus. 83 82 */ 84 rc = RTFileQuerySize(hAutostartFile, &cbFile);85 if ( RT_SUCCESS( rc)83 vrc = RTFileQuerySize(hAutostartFile, &cbFile); 84 if ( RT_SUCCESS(vrc) 86 85 && cbFile <= 16) 87 86 { … … 94 93 if (cbFile) 95 94 { 96 rc = RTFileRead(hAutostartFile, abBuf, (size_t)cbFile, NULL);97 if (RT_SUCCESS( rc))95 vrc = RTFileRead(hAutostartFile, abBuf, (size_t)cbFile, NULL); 96 if (RT_SUCCESS(vrc)) 98 97 { 99 rc = RTStrToUInt32Ex(abBuf, NULL, 10 /* uBase */, &cAutostartVms);100 if ( rc == VWRN_TRAILING_CHARS101 || rc == VWRN_TRAILING_SPACES)102 rc = VINF_SUCCESS;98 vrc = RTStrToUInt32Ex(abBuf, NULL, 10 /* uBase */, &cAutostartVms); 99 if ( vrc == VWRN_TRAILING_CHARS 100 || vrc == VWRN_TRAILING_SPACES) 101 vrc = VINF_SUCCESS; 103 102 } 104 103 } 105 104 106 if (RT_SUCCESS( rc))105 if (RT_SUCCESS(vrc)) 107 106 { 108 107 size_t cbBuf; … … 117 116 { 118 117 cbBuf = RTStrPrintf(abBuf, sizeof(abBuf), "%u", cAutostartVms); 119 rc = RTFileSetSize(hAutostartFile, cbBuf);120 if (RT_SUCCESS( rc))121 rc = RTFileWriteAt(hAutostartFile, 0, abBuf, cbBuf, NULL);118 vrc = RTFileSetSize(hAutostartFile, cbBuf); 119 if (RT_SUCCESS(vrc)) 120 vrc = RTFileWriteAt(hAutostartFile, 0, abBuf, cbBuf, NULL); 122 121 } 123 122 else … … 130 129 } 131 130 } 132 else if (RT_SUCCESS( rc))133 rc = VERR_FILE_TOO_BIG;131 else if (RT_SUCCESS(vrc)) 132 vrc = VERR_FILE_TOO_BIG; 134 133 135 134 if (hAutostartFile != NIL_RTFILE) … … 142 141 } 143 142 144 return rc;143 return vrc; 145 144 } 146 145 … … 150 149 { 151 150 #ifdef RT_OS_LINUX 152 int rc = RTCritSectInit(&this->CritSect);153 NOREF( rc);151 int vrc = RTCritSectInit(&this->CritSect); 152 NOREF(vrc); 154 153 m_pszAutostartDbPath = NULL; 155 154 #endif … … 192 191 int AutostartDb::addAutostartVM(const char *pszVMId) 193 192 { 194 int rc = VERR_NOT_SUPPORTED;195 196 #if defined(RT_OS_LINUX) 197 NOREF(pszVMId); /* Not needed */ 198 199 RTCritSectEnter(&this->CritSect); 200 rc = autostartModifyDb(true /* fAutostart */, true /* fAddVM */);193 int vrc = VERR_NOT_SUPPORTED; 194 195 #if defined(RT_OS_LINUX) 196 NOREF(pszVMId); /* Not needed */ 197 198 RTCritSectEnter(&this->CritSect); 199 vrc = autostartModifyDb(true /* fAutostart */, true /* fAddVM */); 201 200 RTCritSectLeave(&this->CritSect); 202 201 #elif defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_WINDOWS) 203 202 NOREF(pszVMId); /* Not needed */ 204 rc = VINF_SUCCESS;205 #else 206 NOREF(pszVMId); 207 rc = VERR_NOT_SUPPORTED;208 #endif 209 210 return rc;203 vrc = VINF_SUCCESS; 204 #else 205 NOREF(pszVMId); 206 vrc = VERR_NOT_SUPPORTED; 207 #endif 208 209 return vrc; 211 210 } 212 211 213 212 int AutostartDb::removeAutostartVM(const char *pszVMId) 214 213 { 215 int rc = VINF_SUCCESS;216 217 #if defined(RT_OS_LINUX) 218 NOREF(pszVMId); /* Not needed */ 219 RTCritSectEnter(&this->CritSect); 220 rc = autostartModifyDb(true /* fAutostart */, false /* fAddVM */);214 int vrc = VINF_SUCCESS; 215 216 #if defined(RT_OS_LINUX) 217 NOREF(pszVMId); /* Not needed */ 218 RTCritSectEnter(&this->CritSect); 219 vrc = autostartModifyDb(true /* fAutostart */, false /* fAddVM */); 221 220 RTCritSectLeave(&this->CritSect); 222 221 #elif defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_WINDOWS) 223 222 NOREF(pszVMId); /* Not needed */ 224 rc = VINF_SUCCESS;225 #else 226 NOREF(pszVMId); 227 rc = VERR_NOT_SUPPORTED;228 #endif 229 230 return rc;223 vrc = VINF_SUCCESS; 224 #else 225 NOREF(pszVMId); 226 vrc = VERR_NOT_SUPPORTED; 227 #endif 228 229 return vrc; 231 230 } 232 231 233 232 int AutostartDb::addAutostopVM(const char *pszVMId) 234 233 { 235 int rc = VINF_SUCCESS;236 237 #if defined(RT_OS_LINUX) 238 NOREF(pszVMId); /* Not needed */ 239 RTCritSectEnter(&this->CritSect); 240 rc = autostartModifyDb(false /* fAutostart */, true /* fAddVM */);234 int vrc = VINF_SUCCESS; 235 236 #if defined(RT_OS_LINUX) 237 NOREF(pszVMId); /* Not needed */ 238 RTCritSectEnter(&this->CritSect); 239 vrc = autostartModifyDb(false /* fAutostart */, true /* fAddVM */); 241 240 RTCritSectLeave(&this->CritSect); 242 241 #elif defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS) 243 242 NOREF(pszVMId); /* Not needed */ 244 rc = VINF_SUCCESS;245 #else 246 NOREF(pszVMId); 247 rc = VERR_NOT_SUPPORTED;248 #endif 249 250 return rc;243 vrc = VINF_SUCCESS; 244 #else 245 NOREF(pszVMId); 246 vrc = VERR_NOT_SUPPORTED; 247 #endif 248 249 return vrc; 251 250 } 252 251 253 252 int AutostartDb::removeAutostopVM(const char *pszVMId) 254 253 { 255 int rc = VINF_SUCCESS;256 257 #if defined(RT_OS_LINUX) 258 NOREF(pszVMId); /* Not needed */ 259 RTCritSectEnter(&this->CritSect); 260 rc = autostartModifyDb(false /* fAutostart */, false /* fAddVM */);254 int vrc = VINF_SUCCESS; 255 256 #if defined(RT_OS_LINUX) 257 NOREF(pszVMId); /* Not needed */ 258 RTCritSectEnter(&this->CritSect); 259 vrc = autostartModifyDb(false /* fAutostart */, false /* fAddVM */); 261 260 RTCritSectLeave(&this->CritSect); 262 261 #elif defined(RT_OS_DARWIN) || defined (RT_OS_WINDOWS) 263 262 NOREF(pszVMId); /* Not needed */ 264 rc = VINF_SUCCESS;265 #else 266 NOREF(pszVMId); 267 rc = VERR_NOT_SUPPORTED;268 #endif 269 270 return rc;271 } 272 263 vrc = VINF_SUCCESS; 264 #else 265 NOREF(pszVMId); 266 vrc = VERR_NOT_SUPPORTED; 267 #endif 268 269 return vrc; 270 } 271
Note:
See TracChangeset
for help on using the changeset viewer.