From owner-freebsd-gnome@FreeBSD.ORG Mon Feb 2 18:16:20 2009 Return-Path: Delivered-To: freebsd-gnome@FreeBSD.org Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by hub.freebsd.org (Postfix) with ESMTP id C3B4D1065692 for ; Mon, 2 Feb 2009 18:16:12 +0000 (UTC) (envelope-from jkim@FreeBSD.org) From: Jung-uk Kim To: freebsd-gnome@FreeBSD.org Date: Mon, 2 Feb 2009 13:15:43 -0500 User-Agent: KMail/1.6.2 MIME-Version: 1.0 Content-Disposition: inline Content-Type: Multipart/Mixed; boundary="Boundary-00=_RhzhJs1nVb18nkr" Message-Id: <200902021315.45623.jkim@FreeBSD.org> Cc: Subject: [PATCH] sysutils/consolekit X-BeenThere: freebsd-gnome@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GNOME for FreeBSD -- porting and maintaining List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Feb 2009 18:16:31 -0000 --Boundary-00=_RhzhJs1nVb18nkr Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline The attached patch removes unnecessary open/close of /dev/ttyv* and unnecessary sorting of globing result when counting number of consoles. Please review. Thanks, Jung-uk Kim --Boundary-00=_RhzhJs1nVb18nkr Content-Type: text/plain; charset="iso-8859-1"; name="ck.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ck.diff" Index: sysutils/consolekit/Makefile =================================================================== RCS file: /home/pcvs/ports/sysutils/consolekit/Makefile,v retrieving revision 1.8 diff -u -r1.8 Makefile --- sysutils/consolekit/Makefile 10 Jan 2009 05:21:48 -0000 1.8 +++ sysutils/consolekit/Makefile 2 Feb 2009 18:00:37 -0000 @@ -7,7 +7,7 @@ PORTNAME= consolekit PORTVERSION= 0.3.0 -PORTREVISION= 3 +PORTREVISION= 4 CATEGORIES= sysutils gnome MASTER_SITES= http://people.freedesktop.org/~mccann/dist/ DISTFILES= ConsoleKit-${PORTVERSION}${EXTRACT_SUFX} Index: sysutils/consolekit/files/patch-src_ck-sysdeps-freebsd.c =================================================================== RCS file: /home/pcvs/ports/sysutils/consolekit/files/patch-src_ck-sysdeps-freebsd.c,v retrieving revision 1.1 diff -u -r1.1 patch-src_ck-sysdeps-freebsd.c --- sysutils/consolekit/files/patch-src_ck-sysdeps-freebsd.c 24 Mar 2008 03:50:11 -0000 1.1 +++ sysutils/consolekit/files/patch-src_ck-sysdeps-freebsd.c 2 Feb 2009 18:00:37 -0000 @@ -1,5 +1,5 @@ ---- src/ck-sysdeps-freebsd.c.orig 2008-01-23 09:30:44.000000000 -0500 -+++ src/ck-sysdeps-freebsd.c 2008-02-06 22:50:57.000000000 -0500 +--- src/ck-sysdeps-freebsd.c.orig 2008-04-03 20:36:21.000000000 -0400 ++++ src/ck-sysdeps-freebsd.c 2009-01-30 17:03:00.000000000 -0500 @@ -27,6 +27,7 @@ #include #include @@ -24,7 +24,7 @@ *stat = NULL; } -@@ -318,38 +317,40 @@ gboolean +@@ -327,38 +326,38 @@ gboolean ck_get_max_num_consoles (guint *num) { int max_consoles; @@ -41,19 +41,16 @@ - if (res == 0) { - goto done; - } -- -- while ((t = getttyent ()) != NULL) { -- if (t->ty_status & TTY_ON && strncmp (t->ty_name, "ttyv", 4) == 0) + g.gl_offs = 0; -+ glob ("/dev/ttyv*", GLOB_DOOFFS, NULL, &g); ++ glob ("/dev/ttyv*", GLOB_DOOFFS | GLOB_NOSORT, NULL, &g); + for (i = 0; i < g.gl_pathc && g.gl_pathv[i] != NULL; i++) { -+ int fd; ++ struct stat sb; + char *cdev; -+ + +- while ((t = getttyent ()) != NULL) { +- if (t->ty_status & TTY_ON && strncmp (t->ty_name, "ttyv", 4) == 0) + cdev = g.gl_pathv[i]; -+ fd = open (cdev, O_RDONLY | O_NOCTTY); -+ if (fd > -1) { -+ close (fd); ++ if (stat (cdev, &sb) > -1 && S_ISCHR (sb.st_mode)) { max_consoles++; + } else { + break; @@ -83,7 +80,7 @@ } char * -@@ -360,7 +361,12 @@ ck_get_console_device_for_num (guint num +@@ -369,7 +368,12 @@ ck_get_console_device_for_num (guint num /* The device number is always one less than the VT number. */ num--; @@ -97,7 +94,7 @@ return device; } -@@ -370,6 +376,7 @@ ck_get_console_num_from_device (const ch +@@ -379,6 +383,7 @@ ck_get_console_num_from_device (const ch guint *num) { guint n; @@ -105,7 +102,7 @@ gboolean ret; n = 0; -@@ -379,7 +386,11 @@ ck_get_console_num_from_device (const ch +@@ -388,7 +393,11 @@ ck_get_console_num_from_device (const ch return FALSE; } @@ -118,7 +115,7 @@ /* The VT number is always one more than the device number. */ n++; ret = TRUE; -@@ -399,6 +410,7 @@ ck_get_active_console_num (int consol +@@ -408,6 +417,7 @@ ck_get_active_console_num (int consol gboolean ret; int res; int active; @@ -126,7 +123,7 @@ g_assert (console_fd != -1); -@@ -411,7 +423,12 @@ ck_get_active_console_num (int consol +@@ -420,7 +430,12 @@ ck_get_active_console_num (int consol goto out; } --Boundary-00=_RhzhJs1nVb18nkr--