Back to index

lightdm  1.3.2
Functions
vt.h File Reference
#include <glib-object.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

gint vt_get_active (void)
gint vt_get_unused (void)
gint vt_get_min (void)
void vt_ref (gint number)
void vt_unref (gint number)
void vt_set_active (gint number)

Function Documentation

gint vt_get_active ( void  )

Definition at line 40 of file vt.c.

{
#ifdef __linux__
    gint console_fd;
    gint active = -1;

    /* Pretend always active */
    if (getuid () != 0)
        return 1;

    console_fd = open_console ();
    if (console_fd >= 0)
    {
        struct vt_stat console_state = { 0 };
        if (ioctl (console_fd, VT_GETSTATE, &console_state) < 0)
            g_warning ("Error using VT_GETSTATE on /dev/console: %s", strerror (errno));
        else
            active = console_state.v_active;
        close (console_fd);
    }

    return active;
#else
    return -1;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

gint vt_get_min ( void  )

Definition at line 114 of file vt.c.

{
    gint number;

    number = config_get_integer (config_get_instance (), "LightDM", "minimum-vt");
    if (number < 1)
        number = 1;

    return number;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gint vt_get_unused ( void  )

Definition at line 126 of file vt.c.

{
    gint number;

    if (getuid () != 0)
        return -1;

    number = vt_get_min ();
    while (vt_is_used (number))
        number++;
 
    return number;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void vt_ref ( gint  number)

Definition at line 141 of file vt.c.

{
    g_debug ("Using VT %d", number);
    used_vts = g_list_append (used_vts, GINT_TO_POINTER (number)); 
}

Here is the caller graph for this function:

void vt_set_active ( gint  number)

Definition at line 68 of file vt.c.

{
#ifdef __linux__
    gint console_fd;

    g_debug ("Activating VT %d", number);

    /* Pretend always active */
    if (getuid () != 0)
        return;   

    console_fd = open_console ();
    if (console_fd >= 0)
    {
        int n = number;

        if (ioctl (console_fd, VT_ACTIVATE, n) < 0)
            g_warning ("Error using VT_ACTIVATE %d on /dev/console: %s", n, strerror (errno));

        /* Wait for the VT to become active to avoid a suspected
         * race condition somewhere between LightDM, X, ConsoleKit and the kernel.
         * See https://bugs.launchpad.net/bugs/851612 */
        if (ioctl (console_fd, VT_WAITACTIVE) < 0)
            g_warning ("Error using VT_WAITACTIVE %d on /dev/console: %s", n, strerror (errno));

        close (console_fd);
    }
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

void vt_unref ( gint  number)

Definition at line 148 of file vt.c.

{
    g_debug ("Releasing VT %d", number);
    used_vts = g_list_remove (used_vts, GINT_TO_POINTER (number));
}

Here is the caller graph for this function: