Try to make API requests using the new pidfd based APIs. If getting
the pidfds fails or if the remote (daemon) does not support the new
pidfd based D-Bus API, transparently fall back to the old API.
Switch the dbus implementation for the client from systemd to
libdbus. The main reason is that, in flatpaks systemd is not easily
available. No phenomenological change for users of the library,
hopefully.
When we detect that we are running inside a flatpak, talk to the
flatpak portal D-Bus service instead of the session daemon. This
is necessary because flatpak uses pid namespace isolation (see
man pid_namespaces(7)) and thus the pid needs to be translated
from the flatpak pid namespace to the host namespace. This
translation is happening inside the GameMode xdg-desktop-portal.
On each gamemode_request call a new connection to d-bus is opened
but the reference was never release thus leaking the connection
and associated memory.
This allows the client to query the daemon about the status of gamemode.
Returns the following:
0 if gamemode is inactive
1 if gamemode is active
2 if gamemode is active and this client is registered
-1 if the query failed
Passing -s to gamemoded will simply query and print the current status.
Allows for more comprehensive testing when using 'gamemoded -r' as well as more reactionary program behaviour
The systemd bus headers aren't setting a POSIX compliance level so we
define the catch-all to ensure the build doesn't error out, as seen with
issue #3. This is due to the reliance of `siginfo_t`, which requires a
minimum POSIX level of `199309L` when using glibc.
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This exposed a bunch of issues that needed dealing with to ensure the
code is clean and sane. Notably the dlopen/dlsym routine has been altered
to closer match the LSI approach of safe symbol binding, by not attempting
to directly cast the result of a dlsym operation. Instead, if we succeed
in getting the dlsym() pointer, we memcpy this to the target and ensure
we have the correct constraints.
Note that in sanitizing the log helpers, I opted to remove the varargs
ability from FATAL_ERRNO given this is used exactly like perror() and
there are no examples currently using varargs with this in the tree.
This allowed me to keep the log helpers as macros and not have to implement
wrapper functions.
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This is a small daemon/libary to enable games to request a
performance "game mode" from the system.
Currently only implemented to upgrade the CPU governor and
automatically downgrade it once done.
A game only needs to load libgamemodeauto to activate the request.
Which means an LD_PRELOAD can be applied to any game to activate
the mode as needed.
However gamemode_client.h can be used to manually activate/deactivate
the mode as needed, and also perform error checking.
The libs are miminal loaders to call into an installed libgamemode
which, if the daemon is installed and running, will send through
the equivelant game mode request, and magic will happen.
See the README.md for more details.
Currently licensed under the BSD 3 clause license.