Move most Wine could out to Wine file

This commit is contained in:
Marc Di Luzio 2019-05-22 16:54:54 +01:00
parent 75dc083616
commit 1df1852c76
3 changed files with 15 additions and 28 deletions

View File

@ -43,7 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
/** /**
* Detect if the process is a wine preloader process * Detect if the process is a wine preloader process
*/ */
bool game_mode_detect_wine_preloader(const char *exe) static bool game_mode_detect_wine_preloader(const char *exe)
{ {
return (strtail(exe, "/wine-preloader") || strtail(exe, "/wine64-preloader")); return (strtail(exe, "/wine-preloader") || strtail(exe, "/wine64-preloader"));
} }
@ -51,7 +51,7 @@ bool game_mode_detect_wine_preloader(const char *exe)
/** /**
* Detect if the process is a wine loader process * Detect if the process is a wine loader process
*/ */
bool game_mode_detect_wine_loader(const char *exe) static bool game_mode_detect_wine_loader(const char *exe)
{ {
return (strtail(exe, "/wine") || strtail(exe, "/wine64")); return (strtail(exe, "/wine") || strtail(exe, "/wine64"));
} }
@ -61,8 +61,15 @@ bool game_mode_detect_wine_loader(const char *exe)
* This function is used if game_mode_context_find_exe() identified the * This function is used if game_mode_context_find_exe() identified the
* process as wine-preloader. Returns NULL when resolve fails. * process as wine-preloader. Returns NULL when resolve fails.
*/ */
char *game_mode_resolve_wine_preloader(const pid_t pid) char *game_mode_resolve_wine_preloader(const char *exe, const pid_t pid)
{ {
/* Detect if the process is a wine loader process */
if (game_mode_detect_wine_preloader(exe) || game_mode_detect_wine_loader(exe)) {
LOG_MSG("Detected wine for client %d [%s].\n", pid, exe);
} else {
return NULL;
}
char buffer[PATH_MAX]; char buffer[PATH_MAX];
char *wine_exe = NULL, *wineprefix = NULL; char *wine_exe = NULL, *wineprefix = NULL;

View File

@ -748,31 +748,13 @@ static char *game_mode_context_find_exe(pid_t pid)
char *exe = strdup(buffer); char *exe = strdup(buffer);
/* Detect if the process is a wine loader process */ /* Resolve for wine if appropriate */
if (game_mode_detect_wine_preloader(exe)) { if ((wine_exe = game_mode_resolve_wine_preloader(exe, pid))) {
LOG_MSG("Detected wine preloader for client %d [%s].\n", pid, exe);
goto wine_preloader;
}
if (game_mode_detect_wine_loader(exe)) {
LOG_MSG("Detected wine loader for client %d [%s].\n", pid, exe);
goto wine_preloader;
}
return exe;
wine_preloader:
wine_exe = game_mode_resolve_wine_preloader(pid);
if (wine_exe) {
free(exe); free(exe);
exe = wine_exe; exe = wine_exe;
return exe;
} }
/* We have to ignore this because the wine process is in some sort return exe;
* of respawn mode
*/
free(exe);
fail: fail:
if (errno != 0) // otherwise a proper message was logged before if (errno != 0) // otherwise a proper message was logged before

View File

@ -149,9 +149,7 @@ void game_mode_apply_scheduling(const GameModeContext *self, const pid_t client)
* Provides internal API functions specific to handling wine * Provides internal API functions specific to handling wine
* prefixes. * prefixes.
*/ */
bool game_mode_detect_wine_loader(const char *exe); char *game_mode_resolve_wine_preloader(const char *exe, const pid_t pid);
bool game_mode_detect_wine_preloader(const char *exe);
char *game_mode_resolve_wine_preloader(const pid_t pid);
/** gamemode-tests.c /** gamemode-tests.c
* Provides a test suite to verify gamemode behaviour * Provides a test suite to verify gamemode behaviour