diff options
author | Brian Cameron <Brian.Cameron@sun.com> | 2005-11-15 22:58:50 +0000 |
---|---|---|
committer | Brian Cameron <bcameron@src.gnome.org> | 2005-11-15 22:58:50 +0000 |
commit | 101707f46c49cc5a28d60b03d05dc58cac0978c8 (patch) | |
tree | 48fa06fa749aabf1447a30ce799b9e22da4fbfb4 | |
parent | bba6b21de5fd1142aeb314ba2d131078571cc104 (diff) | |
download | gdm-101707f46c49cc5a28d60b03d05dc58cac0978c8.tar.gz |
Change made on 11/03 to make GDM use VT_GETSTATE for peeking VT freeness
2005-11-15 Brian Cameron <Brian.Cameron@sun.com>
* daemon/getvt.c: Change made on 11/03 to make
GDM use VT_GETSTATE for peeking VT freeness broke
BSD builds. Put back code for BSD. Linux will
continue to use VT_GETSTATE. Fixes bug #321493.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | daemon/getvt.c | 80 |
2 files changed, 80 insertions, 7 deletions
@@ -1,3 +1,10 @@ +2005-11-15 Brian Cameron <Brian.Cameron@sun.com> + + * daemon/getvt.c: Change made on 11/03 to make + GDM use VT_GETSTATE for peeking VT freeness broke + BSD builds. Put back code for BSD. Linux will + continue to use VT_GETSTATE. Fixes bug #321493. + 2005-11-14 Brian Cameron <Brian.Cameron@sun.com> * Release 2.8.0.6. diff --git a/daemon/getvt.c b/daemon/getvt.c index 64d893b9..2ddadd70 100644 --- a/daemon/getvt.c +++ b/daemon/getvt.c @@ -18,16 +18,15 @@ extern int GdmFirstVT; extern gboolean GdmVTAllocation; -#if defined (__linux__) || defined (__FreeBSD__) || defined(__DragonFly__) +/* Virtual terminals only supported on Linux, FreeBSD, or DragonFly */ + +#if defined (__linux__) || defined (__FreeBSD__) || defined (__DragonFly__) #ifdef __linux__ #include <sys/vt.h> -#endif -#if defined(__FreeBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) #include <sys/consio.h> -#endif -#if defined( __FreeBSD__) || defined(__DragonFly__) static const char* __itovty(int val) { @@ -67,7 +66,7 @@ open_vt (int vtno) } static int -get_free_vt (int *vtfd) +get_free_vt_linux (int *vtfd) { int fd, fdv; int vtno; @@ -108,6 +107,68 @@ get_free_vt (int *vtfd) return vtno; } +static int +get_free_vt_freebsd_dragonfly (int *vtfd) +{ + int fd, fdv; + int vtno; + GList *to_close_vts = NULL, *li; + + *vtfd = -1; + + do { + errno = 0; + fd = open ("/dev/console", O_WRONLY +#ifdef O_NOCTTY + |O_NOCTTY +#endif + , 0); + } while G_UNLIKELY (errno == EINTR); + if (fd < 0) + return -1; + + if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) || (vtno == -1)) { + VE_IGNORE_EINTR (close (fd)); + return -1; + } + + fdv = open_vt (vtno); + if (fdv < 0) { + VE_IGNORE_EINTR (close (fd)); + return -1; + } + + while (vtno < GdmFirstVT) { + int oldvt = vtno; + to_close_vts = g_list_prepend (to_close_vts, + GINT_TO_POINTER (fdv)); + + if (ioctl(fd, VT_OPENQRY, &vtno) == -1) { + vtno = -1; + goto cleanup; + } + + if (oldvt == vtno) { + vtno = -1; + goto cleanup; + } + + fdv = open_vt (vtno); + if (fdv < 0) { + vtno = -1; + goto cleanup; + } + } + + *vtfd = fdv; + +cleanup: + for (li = to_close_vts; li != NULL; li = li->next) { + VE_IGNORE_EINTR (close (GPOINTER_TO_INT (li->data))); + } + return vtno; +} + char * gdm_get_empty_vt_argument (int *fd, int *vt) { @@ -116,7 +177,12 @@ gdm_get_empty_vt_argument (int *fd, int *vt) return NULL; } - *vt = get_free_vt (fd); +#if defined(__linux__) + *vt = get_free_vt_linux (fd); +#elif defined(__FreeBSD__) || defined(__DragonFly__) + *vt = get_free_vt_freebsd_dragonfly (fd); +#endif + if (*vt < 0) return NULL; else |