From 414f7cc1e62474da69058884c5b683dc20e3a8f6 Mon Sep 17 00:00:00 2001 From: Simon Zheng Date: Mon, 25 Feb 2008 17:14:11 -0500 Subject: properly get display device on Solaris Mapping between device path and (major, minor). "/dev/vt" -- (15,*) "/dev/pts" -- (24,*) "/dev/console" -- (0,0) "NO_TTY_VALUE" - (-1,-1) Also, solaris VT device is named like this. /dev/console --- VT #1 /dev/vt/2 --- VT #2 /dev/vt/3 --- VT #3 /dev/vt/N --- VT #4 --- src/ck-sysdeps-solaris.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ck-sysdeps-solaris.c b/src/ck-sysdeps-solaris.c index e32265e..87bf4fd 100644 --- a/src/ck-sysdeps-solaris.c +++ b/src/ck-sysdeps-solaris.c @@ -177,8 +177,11 @@ stat2proc (pid_t pid, snprintf (P->tty_text, sizeof P->tty_text, "%3d,%-3d", tty_maj, tty_min); + if (tty_maj == 15) { + snprintf (P->tty_text, sizeof P->tty_text, "/dev/vt/%u", tty_min); + } if (tty_maj == 24) { - snprintf (P->tty_text, sizeof P->tty_text, "pts/%-3u", tty_min); + snprintf (P->tty_text, sizeof P->tty_text, "/dev/pts/%u", tty_min); } if (P->tty == NO_TTY_VALUE) { @@ -197,7 +200,7 @@ stat2proc (pid_t pid, } if (P->tty == DEV_ENCODE(0,0)) { - memcpy (P->tty_text, "console", 8); + memcpy (P->tty_text, "/dev/console", 12); } if (P->pid != pid) { @@ -410,7 +413,10 @@ ck_get_console_device_for_num (guint num) { char *device; - device = g_strdup_printf ("/dev/vt/%u", num); + if (num == 1) + device = g_strdup_printf ("/dev/console", num); + else + device = g_strdup_printf ("/dev/vt/%u", num); return device; } @@ -429,7 +435,9 @@ ck_get_console_num_from_device (const char *device, return FALSE; } - if (sscanf (device, "/dev/vt/%u", &n) == 1) { + if (strcmp (device, "/dev/console") == 0) { + *num = 1; + } else if (sscanf (device, "/dev/vt/%u", &n) == 1) { ret = TRUE; } -- cgit