[arch-commits] Commit in gdm/trunk (PKGBUILD gdm-vt-allocation-hack.patch)
Jan de Groot
jgc at archlinux.org
Tue Aug 10 18:56:53 UTC 2010
Date: Tuesday, August 10, 2010 @ 14:56:52
Author: jgc
Revision: 87106
upgpkg: gdm 2.30.4-2
Add patch to allocate VT starting from 7. Fixes issues with agetty claiming the TTY after gdm has started X on it
Added:
gdm/trunk/gdm-vt-allocation-hack.patch
Modified:
gdm/trunk/PKGBUILD
------------------------------+
PKGBUILD | 3 +
gdm-vt-allocation-hack.patch | 118 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 121 insertions(+)
Modified: PKGBUILD
===================================================================
--- PKGBUILD 2010-08-10 18:56:47 UTC (rev 87105)
+++ PKGBUILD 2010-08-10 18:56:52 UTC (rev 87106)
@@ -19,12 +19,14 @@
source=(http://ftp.gnome.org/pub/gnome/sources/${pkgname}/2.30/${pkgname}-${pkgver}.tar.bz2
04_fix_external_program_directories.patch
ck-since.patch
+ gdm-vt-allocation-hack.patch
gdm.pam
gdm-autologin.pam
gdm)
sha256sums=('3a1c7fd590622d5291584d98ce5cf3e7888adf949655041549561f3a5983b5a9'
'cb585c39c6671387b5a25f21a99c97e3a20eaf4188fea1b62871681a1ebf8bff'
'bbe7dcfa162fd4eb362e15d5742beef6881535bd449524097a14c54afec99bff'
+ '3c8b588d4af08d94dc93bcd5e4c2a983c3f4fbbbe40833bceac2a1df4f1e8215'
'f1dfa4d88288d4b0a631a68a51b46c2da537bee8fe5a99f9f288c8ff75a50b19'
'3daff680ff6b7ea56f84f40843e46e72477c81e9e405028203c942af04d07ae5'
'272c08d8e8b50bf424d0705ac864d4c18c47ec4f6893b1af732c2efbc86c9550')
@@ -33,6 +35,7 @@
cd "${srcdir}/${pkgname}-${pkgver}"
patch -Np1 -i "${srcdir}/04_fix_external_program_directories.patch"
patch -Np1 -i "${srcdir}/ck-since.patch"
+ patch -Np1 -i "${srcdir}/gdm-vt-allocation-hack.patch"
./configure --prefix=/usr --sysconfdir=/etc \
--libexecdir=/usr/lib/gdm --localstatedir=/var --disable-static \
--with-at-spi-registryd-directory=/usr/lib/at-spi \
Added: gdm-vt-allocation-hack.patch
===================================================================
--- gdm-vt-allocation-hack.patch (rev 0)
+++ gdm-vt-allocation-hack.patch 2010-08-10 18:56:52 UTC (rev 87106)
@@ -0,0 +1,118 @@
+diff --git a/daemon/gdm-server.c b/daemon/gdm-server.c
+index 39def47..03488fd 100644
+--- a/daemon/gdm-server.c
++++ b/daemon/gdm-server.c
+@@ -33,6 +33,8 @@
+ #include <grp.h>
+ #include <signal.h>
+ #include <sys/resource.h>
++#include <sys/ioctl.h>
++#include <sys/vt.h>
+
+ #include <glib.h>
+ #include <glib/gi18n.h>
+@@ -150,6 +152,92 @@ _gdm_server_query_ck_for_display_device (GdmServer *server)
+ return out;
+ }
+
++#ifndef O_NOCTTY
++# define O_NOCTTY 0
++#endif
++
++static int
++open_vt (int vtno)
++{
++ char *vtname;
++ int fd;
++
++ vtname = g_strdup_printf ("/dev/tty%d", vtno);
++
++ do {
++ errno = 0;
++ fd = open (vtname, O_RDWR | O_NOCTTY, 0);
++ } while (errno == EINTR);
++
++ g_free (vtname);
++ return fd;
++}
++
++static gint
++find_first_probably_free_vt (void)
++{
++ int fd, fdv;
++ int vtno;
++ unsigned short vtmask;
++ struct vt_stat vtstat;
++ guint v_state;
++
++ fdv = -1;
++
++ do {
++ errno = 0;
++ fd = open ("/dev/console", O_WRONLY | O_NOCTTY, 0);
++ } while (errno == EINTR);
++
++ if (fd >= 0) {
++ if (ioctl (fd, VT_GETSTATE, &vtstat) >= 0) {
++ v_state = vtstat.v_state;
++ } else {
++ close (fd);
++ v_state = 0;
++ fd = -1;
++ }
++ } else {
++ v_state = 0;
++ }
++
++ if (fd < 0) {
++ do {
++ errno = 0;
++ fd = open ("/dev/console", O_RDONLY | O_NOCTTY, 0);
++ } while (errno == EINTR);
++
++ if (fd >= 0) {
++ if (ioctl (fd, VT_GETSTATE, &vtstat) >= 0)
++ v_state = vtstat.v_state;
++ }
++ }
++
++ for (vtno = 7, vtmask = 1 << vtno; vtmask; vtno++, vtmask <<= 1) {
++ /* Is this console in use? */
++ if (v_state & vtmask)
++ continue;
++
++ /* No, try to open it */
++ fdv = open_vt (vtno);
++ if (fdv >= 0)
++ break;
++
++ /* If we're here, kernel indicated that the console was free,
++ * but we failed to open it. Just go on to higher VTs. */
++ }
++
++ if (fdv >= 0)
++ close (fdv);
++ else
++ vtno = -1;
++
++ if (fd >= 0)
++ close (fd);
++
++ return vtno;
++}
++
+ char *
+ gdm_server_get_display_device (GdmServer *server)
+ {
+@@ -310,6 +398,11 @@ gdm_server_resolve_command_line (GdmServer *server,
+
+ if (vtarg != NULL && ! gotvtarg) {
+ argv[len++] = g_strdup (vtarg);
++ } else if (!query_in_arglist && !gotvtarg) {
++ gint vtnum = find_first_probably_free_vt ();
++
++ if (vtnum > 0)
++ argv [len++] = g_strdup_printf ("vt%d", vtnum);
+ }
+
+ argv[len++] = NULL;
More information about the arch-commits
mailing list