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
*/
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"));
}
@ -51,7 +51,7 @@ bool game_mode_detect_wine_preloader(const char *exe)
/**
* 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"));
}
@ -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
* 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 *wine_exe = NULL, *wineprefix = NULL;

View File

@ -748,32 +748,14 @@ static char *game_mode_context_find_exe(pid_t pid)
char *exe = strdup(buffer);
/* Detect if the process is a wine loader process */
if (game_mode_detect_wine_preloader(exe)) {
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;
/* Resolve for wine if appropriate */
if ((wine_exe = game_mode_resolve_wine_preloader(exe, pid))) {
free(exe);
exe = wine_exe;
}
return exe;
wine_preloader:
wine_exe = game_mode_resolve_wine_preloader(pid);
if (wine_exe) {
free(exe);
exe = wine_exe;
return exe;
}
/* We have to ignore this because the wine process is in some sort
* of respawn mode
*/
free(exe);
fail:
if (errno != 0) // otherwise a proper message was logged before
LOG_ERROR("Unable to find executable for PID %d: %s\n", pid, strerror(errno));

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
* prefixes.
*/
bool game_mode_detect_wine_loader(const char *exe);
bool game_mode_detect_wine_preloader(const char *exe);
char *game_mode_resolve_wine_preloader(const pid_t pid);
char *game_mode_resolve_wine_preloader(const char *exe, const pid_t pid);
/** gamemode-tests.c
* Provides a test suite to verify gamemode behaviour