multi-seat-x.c revision 49e942b2bc9fdedba79cd266a076ce9c9d91fc13
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2011 Lennart Poettering
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <string.h>
#include <unistd.h>
#include <libudev.h>
#include "util.h"
#include "mkdir.h"
int i;
char **new_argv;
int r;
/* This binary will go away as soon as X natively supports
* display enumeration with udev in a way that covers both PCI
* and USB. */
/* This will simply determine the fb device id of the graphics
* device assigned to a seat and write a configuration file
* from it and then spawn the real X server. */
/* If this file is removed, don't forget to remove the code
* that invokes this in gdm and other display managers. */
for (i = 1; i < argc; i++)
log_error("Failed to execute real X server: %m");
goto fail;
}
if (!udev) {
log_error("Failed to allocate udev environment.");
goto fail;
}
if (!enumerator) {
log_error("Failed to allocate udev enumerator.");
goto fail;
}
if (r < 0) {
log_error("Failed to enumerate devices.");
goto fail;
}
struct udev_device *d;
const char *dn;
if (!d)
continue;
dn = udev_device_get_devnode(d);
if (dn) {
if (!device_node) {
log_error("Out of memory.");
goto fail;
}
}
if (device_node)
break;
}
if (!device_node) {
goto fail;
}
if (r < 0) {
goto fail;
}
if (!path) {
log_error("Out of memory");
goto fail;
}
if (!f) {
log_error("Failed to write configuration file: %m");
goto fail;
}
fprintf(f,
"Section \"Device\"\n"
" Identifier \"udev\"\n"
" Driver \"fbdev\"\n"
" Option \"fbdev\" \"%s\"\n"
"EndSection\n"
"Section \"ServerFlags\"\n"
" Option \"AutoAddDevices\" \"True\"\n"
" Option \"AllowEmptyInput\" \"True\"\n"
" Option \"DontVTSwitch\" \"True\"\n"
"EndSection\n"
"Section \"InputClass\"\n"
" Identifier \"Force Input Devices to Seat\"\n"
" Option \"GrabDevice\" \"True\"\n"
"EndSection\n",
fflush(f);
if (ferror(f)) {
log_error("Failed to write configuration file: %m");
goto fail;
}
fclose(f);
f = NULL;
enumerator = NULL;
device_node = NULL;
log_error("Failed to execute real X server: %m");
fail:
if (enumerator)
if (udev)
if (f)
fclose(f);
return EXIT_FAILURE;
}