zsh: update to 5.7.1 & native build
[unleashed-userland.git] / components / ConsoleKit / patches / 07-sol-vt-major.patch
blobfb8c7727389100327dbf5fb61ab71c82820f690e
1 commit 42a909bbc8ede5c27e3d40606a98ab1251511dfc
2 Author: Halton Huo <halton.huo@sun.com>
3 Date: Tue Nov 3 11:42:07 2009 +0800
5 Identify major device number for vt rather than hard code as 15.
6 Fixes bug http://defect.opensolaris.org/bz/show_bug.cgi?id=12322
7 This is solaris only bug, won't affect other platform.
9 diff --git a/src/ck-sysdeps-solaris.c b/src/ck-sysdeps-solaris.c
10 index 607a3ae..335ab8b 100644
11 --- a/src/ck-sysdeps-solaris.c
12 +++ b/src/ck-sysdeps-solaris.c
13 @@ -124,6 +124,26 @@ ck_process_stat_get_tty (CkProcessStat *stat)
14 return g_strdup (stat->tty_text);
17 +#define VT0_FILE "/dev/vt/0"
18 +static int
19 +get_system_vt_major ()
21 + static ret = -1;
22 + struct stat st;
23 + int res;
25 + if (ret >= 0)
26 + return ret;
28 + res = stat (VT0_FILE, &st);
30 + if (res == 0) {
31 + ret = major (st.st_rdev);
32 + }
34 + return ret;
37 /* return 1 if it works, or 0 for failure */
38 static gboolean
39 stat2proc (pid_t pid,
40 @@ -177,7 +197,7 @@ stat2proc (pid_t pid,
42 snprintf (P->tty_text, sizeof P->tty_text, "%3d,%-3d", tty_maj, tty_min);
44 - if (tty_maj == 15) {
45 + if (tty_maj == get_system_vt_major ()) {
46 snprintf (P->tty_text, sizeof P->tty_text, "/dev/vt/%u", tty_min);
48 if (P->tty == NO_TTY_VALUE) {