Changeset 81052 in vbox for trunk/src/VBox/Additions/x11
- Timestamp:
- Sep 27, 2019 12:44:45 PM (5 years ago)
- Location:
- trunk/src/VBox/Additions/x11/VBoxClient
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/Makefile.kmk
r80862 r81052 26 26 VBoxClient_TEMPLATE = NewVBoxGuestR3Exe 27 27 VBoxClient_DEFS += VBOX_X11_CLIPBOARD VBOX_WITH_HGCM 28 VBoxClient_DEFS += VBOX_BUILD_TARGET=\"$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)\" 28 29 ifdef VBOX_WITH_DBUS 29 30 VBoxClient_DEFS += VBOX_WITH_DBUS -
trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h
r81042 r81052 38 38 struct VBCLSERVICE 39 39 { 40 /** Returns the (friendly) name of the service. */ 41 const char *(*getName)(void); 40 42 /** Get the services default path to pidfile, relative to $HOME */ 41 43 /** @todo Should this also have a component relative to the X server number? -
trunk/src/VBox/Additions/x11/VBoxClient/clipboard.cpp
r81044 r81052 285 285 } 286 286 287 static const char *getName() 288 { 289 return "Shared Clipboard"; 290 } 291 287 292 static const char *getPidFilePath() 288 293 { … … 314 319 struct VBCLSERVICE vbclClipboardInterface = 315 320 { 321 getName, 316 322 getPidFilePath, 317 323 VBClServiceDefaultHandler, /* init */ -
trunk/src/VBox/Additions/x11/VBoxClient/display-svga-x11.cpp
r81040 r81052 223 223 if (!_XReply(pContext->pDisplay, (xReply *)&repGetScreen, 0, xTrue)) 224 224 VBClLogFatalError("%s failed to set resolution\n", __func__); 225 } 226 227 static const char *getName() 228 { 229 return "Display SVGA X11"; 225 230 } 226 231 … … 295 300 static struct VBCLSERVICE interface = 296 301 { 302 getName, 297 303 getPidFilePath, 298 304 VBClServiceDefaultHandler, /* Init */ -
trunk/src/VBox/Additions/x11/VBoxClient/display-svga.cpp
r81040 r81052 165 165 if (RT_FAILURE(rc) && rc != VERR_INVALID_PARAMETER) 166 166 VBClLogFatalError("Failure updating layout, rc=%Rrc\n", rc); 167 } 168 169 static const char *getName() 170 { 171 return "Display SVGA"; 167 172 } 168 173 … … 239 244 static struct VBCLSERVICE interface = 240 245 { 246 getName, 241 247 getPidFilePath, 242 248 VBClServiceDefaultHandler, /* Init */ -
trunk/src/VBox/Additions/x11/VBoxClient/display.cpp
r81040 r81052 222 222 } 223 223 224 static const char *getName() 225 { 226 return "Display"; 227 } 228 224 229 static const char *getPidFilePath() 225 230 { … … 263 268 struct VBCLSERVICE vbclDisplayInterface = 264 269 { 270 getName, 265 271 getPidFilePath, 266 272 init, -
trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp
r81042 r81052 3479 3479 }; 3480 3480 3481 static const char *getName() 3482 { 3483 return "Drag and Drop (DnD)"; 3484 } 3485 3481 3486 static const char *getPidFilePath() 3482 3487 { … … 3513 3518 struct VBCLSERVICE vbclDragAndDropInterface = 3514 3519 { 3520 getName, 3515 3521 getPidFilePath, 3516 3522 init, -
trunk/src/VBox/Additions/x11/VBoxClient/hostversion.cpp
r81042 r81052 34 34 #include "VBoxClient.h" 35 35 36 static const char *getName() 37 { 38 return "Host Version Check"; 39 } 40 36 41 static const char *getPidFilePath() 37 42 { … … 200 205 struct VBCLSERVICE vbclHostVersionInterface = 201 206 { 207 getName, 202 208 getPidFilePath, 203 209 VBClServiceDefaultHandler, /* init */ -
trunk/src/VBox/Additions/x11/VBoxClient/main.cpp
r81040 r81052 33 33 #include <X11/Xatom.h> 34 34 35 #include <package-generated.h> 36 #include "product-generated.h" 37 35 38 #include <iprt/buildconfig.h> 36 39 #include <iprt/critsect.h> … … 41 44 #include <iprt/path.h> 42 45 #include <iprt/param.h> 46 #include <iprt/process.h> 43 47 #include <iprt/stream.h> 44 48 #include <iprt/string.h> 49 #include <iprt/system.h> 45 50 #include <iprt/types.h> 46 51 #include <VBox/VBoxGuestLib.h> … … 61 66 /** The name of our pidfile. It is global for the benefit of the cleanup 62 67 * routine. */ 63 static char g_szPidFile[RTPATH_MAX] = "";68 static char g_szPidFile[RTPATH_MAX] = ""; 64 69 /** The file handle of our pidfile. It is global for the benefit of the 65 70 * cleanup routine. */ 66 static RTFILE g_hPidFile;71 static RTFILE g_hPidFile; 67 72 /** Global critical section held during the clean-up routine (to prevent it 68 73 * being called on multiple threads at once) or things which may not happen 69 74 * during clean-up (e.g. pausing and resuming the service). 70 75 */ 71 RTCRITSECTg_critSect;76 static RTCRITSECT g_critSect; 72 77 /** Counter of how often our daemon has been respawned. */ 73 unsignedg_cRespawn = 0;78 static unsigned g_cRespawn = 0; 74 79 /** Logging verbosity level. */ 75 unsigned g_cVerbosity = 0; 80 static unsigned g_cVerbosity = 0; 81 static char g_szLogFile[RTPATH_MAX + 128] = ""; 82 /** Logging parameters. */ 83 /** @todo Make this configurable later. */ 84 static PRTLOGGER g_pLoggerRelease = NULL; 85 static uint32_t g_cHistory = 10; /* Enable log rotation, 10 files. */ 86 static uint32_t g_uHistoryFileTime = RT_SEC_1DAY; /* Max 1 day per file. */ 87 static uint64_t g_uHistoryFileSize = 100 * _1M; /* Max 100MB per file. */ 76 88 77 89 /** … … 179 191 AssertPtr(psz); 180 192 LogFlowFunc(("%s", psz)); 181 LogRel 2(("%s", psz));193 LogRel(("%s", psz)); 182 194 183 195 RTStrFree(psz); 196 } 197 198 /** 199 * @callback_method_impl{FNRTLOGPHASE, Release logger callback} 200 */ 201 static DECLCALLBACK(void) vbClLogHeaderFooter(PRTLOGGER pLoggerRelease, RTLOGPHASE enmPhase, PFNRTLOGPHASEMSG pfnLog) 202 { 203 /* Some introductory information. */ 204 static RTTIMESPEC s_TimeSpec; 205 char szTmp[256]; 206 if (enmPhase == RTLOGPHASE_BEGIN) 207 RTTimeNow(&s_TimeSpec); 208 RTTimeSpecToString(&s_TimeSpec, szTmp, sizeof(szTmp)); 209 210 switch (enmPhase) 211 { 212 case RTLOGPHASE_BEGIN: 213 { 214 pfnLog(pLoggerRelease, 215 "VBoxClient %s r%s (verbosity: %u) %s (%s %s) release log\n" 216 "Log opened %s\n", 217 RTBldCfgVersion(), RTBldCfgRevisionStr(), g_cVerbosity, VBOX_BUILD_TARGET, 218 __DATE__, __TIME__, szTmp); 219 220 int vrc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szTmp, sizeof(szTmp)); 221 if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) 222 pfnLog(pLoggerRelease, "OS Product: %s\n", szTmp); 223 vrc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szTmp, sizeof(szTmp)); 224 if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) 225 pfnLog(pLoggerRelease, "OS Release: %s\n", szTmp); 226 vrc = RTSystemQueryOSInfo(RTSYSOSINFO_VERSION, szTmp, sizeof(szTmp)); 227 if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) 228 pfnLog(pLoggerRelease, "OS Version: %s\n", szTmp); 229 vrc = RTSystemQueryOSInfo(RTSYSOSINFO_SERVICE_PACK, szTmp, sizeof(szTmp)); 230 if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) 231 pfnLog(pLoggerRelease, "OS Service Pack: %s\n", szTmp); 232 233 /* the package type is interesting for Linux distributions */ 234 char szExecName[RTPATH_MAX]; 235 char *pszExecName = RTProcGetExecutablePath(szExecName, sizeof(szExecName)); 236 pfnLog(pLoggerRelease, 237 "Executable: %s\n" 238 "Process ID: %u\n" 239 "Package type: %s" 240 #ifdef VBOX_OSE 241 " (OSE)" 242 #endif 243 "\n", 244 pszExecName ? pszExecName : "unknown", 245 RTProcSelf(), 246 VBOX_PACKAGE_STRING); 247 break; 248 } 249 250 case RTLOGPHASE_PREROTATE: 251 pfnLog(pLoggerRelease, "Log rotated - Log started %s\n", szTmp); 252 break; 253 254 case RTLOGPHASE_POSTROTATE: 255 pfnLog(pLoggerRelease, "Log continuation - Log started %s\n", szTmp); 256 break; 257 258 case RTLOGPHASE_END: 259 pfnLog(pLoggerRelease, "End of log file - Log started %s\n", szTmp); 260 break; 261 262 default: 263 /* nothing */ 264 break; 265 } 266 } 267 268 /** 269 * Creates the default release logger outputting to the specified file. 270 * 271 * Pass NULL to disabled logging. 272 * 273 * @return IPRT status code. 274 * @param pszLogFile Filename for log output. NULL disables logging 275 * (r=bird: No, it doesn't!). 276 */ 277 int VBClLogCreate(const char *pszLogFile) 278 { 279 /* Create release logger (stdout + file). */ 280 static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES; 281 RTUINT fFlags = RTLOGFLAGS_PREFIX_THREAD | RTLOGFLAGS_PREFIX_TIME; 282 #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2) 283 fFlags |= RTLOGFLAGS_USECRLF; 284 #endif 285 int rc = RTLogCreateEx(&g_pLoggerRelease, fFlags, "all", 286 #ifdef DEBUG 287 "VBOXCLIENT_LOG", 288 #else 289 "VBOXCLIENT_RELEASE_LOG", 290 #endif 291 RT_ELEMENTS(s_apszGroups), s_apszGroups, UINT32_MAX /*cMaxEntriesPerGroup*/, 292 RTLOGDEST_STDOUT | RTLOGDEST_USER, 293 vbClLogHeaderFooter, g_cHistory, g_uHistoryFileSize, g_uHistoryFileTime, 294 NULL /*pErrInfo*/, "%s", pszLogFile ? pszLogFile : ""); 295 if (RT_SUCCESS(rc)) 296 { 297 /* register this logger as the release logger */ 298 RTLogRelSetDefaultInstance(g_pLoggerRelease); 299 300 /* Explicitly flush the log in case of VBOXSERVICE_RELEASE_LOG=buffered. */ 301 RTLogFlush(g_pLoggerRelease); 302 } 303 304 return rc; 305 } 306 307 /** 308 * Destroys the currently active logging instance. 309 */ 310 void VBClLogDestroy(void) 311 { 312 RTLogDestroy(RTLogRelSetDefaultInstance(NULL)); 184 313 } 185 314 … … 201 330 if (g_szPidFile[0] && g_hPidFile) 202 331 VbglR3ClosePidFile(g_szPidFile, g_hPidFile); 332 333 VBClLogDestroy(); 334 203 335 if (fExit) 204 336 exit(RTEXITCODE_SUCCESS); … … 434 566 if (RT_FAILURE(rc)) 435 567 VBClLogFatalError("VbglR3InitUser failed: %Rrc", rc); 568 569 rc = VBClLogCreate(g_szLogFile[0] ? g_szLogFile : NULL); 570 if (RT_FAILURE(rc)) 571 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to create release log '%s', rc=%Rrc\n", 572 g_szLogFile[0] ? g_szLogFile : "<None>", rc); 573 574 LogRel(("Service: %s\n", (*g_pService)->getName())); 436 575 437 576 if (!fDaemonise) -
trunk/src/VBox/Additions/x11/VBoxClient/seamless.cpp
r81042 r81052 267 267 }; 268 268 269 static const char *getName() 270 { 271 return "Seamless"; 272 } 273 269 274 static const char *getPidFilePath(void) 270 275 { … … 318 323 struct VBCLSERVICE vbclSeamlessInterface = 319 324 { 325 getName, 320 326 getPidFilePath, 321 327 init,
Note:
See TracChangeset
for help on using the changeset viewer.