public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Werner Fink <werner@suse.de>
To: util-linux@vger.kernel.org
Cc: Werner Fink <werner@suse.de>, Ruediger Meier <sweet_f_a@gmx.de>
Subject: [PATCH 2/4] Enable sulogin to find a suitable console device even if the first line in /proc/consoles does not have any major and minor number.
Date: Thu,  8 May 2014 12:09:23 +0200	[thread overview]
Message-ID: <1399543765-31106-2-git-send-email-werner@suse.de> (raw)
In-Reply-To: <1399543765-31106-1-git-send-email-werner@suse.de>

Enable sulogin to find a suitable console device even if the first line
in /proc/consoles does not have any major and minor number.

Signed-off-by: Werner Fink <werner@suse.de>
---
 login-utils/sulogin-consoles.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git login-utils/sulogin-consoles.c login-utils/sulogin-consoles.c
index 6ceea6b..817a882 100644
--- login-utils/sulogin-consoles.c
+++ login-utils/sulogin-consoles.c
@@ -324,7 +324,7 @@ static int detect_consoles_from_proc(struct list_head *consoles)
 	char fbuf[16 + 1];
 	DIR *dir = NULL;
 	FILE *fc = NULL;
-	int maj, min, rc = 1;
+	int maj, min, rc = 1, matches;
 
 	DBG(dbgprint("trying /proc"));
 
@@ -337,10 +337,12 @@ static int detect_consoles_from_proc(struct list_head *consoles)
 	if (!dir)
 		goto done;
 
-	while (fscanf(fc, "%*s %*s (%16[^)]) %d:%d", fbuf, &maj, &min) == 3) {
+	while ((matches = fscanf(fc, "%*s %*s (%16[^)]) %d:%d", fbuf, &maj, &min)) >= 1) {
 		char *name;
 		dev_t comparedev;
 
+		if (matches != 3)
+			continue;
 		if (!strchr(fbuf, 'E'))
 			continue;
 		comparedev = makedev(maj, min);
-- 
1.7.9.2


  reply	other threads:[~2014-05-08 10:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-08 10:09 [PATCH 1/4] Avoid that agetty nor sulogin are fooled by a running plymouth Werner Fink
2014-05-08 10:09 ` Werner Fink [this message]
2014-05-08 10:09 ` [PATCH 3/4] Better support of the special system consoles on S390 Werner Fink
2014-05-08 10:09 ` [PATCH 4/4] Beside virtual consoles support xvc and hvc device lines as well Werner Fink
2014-05-13  8:56 ` [PATCH 1/4] Avoid that agetty nor sulogin are fooled by a running plymouth Karel Zak
2014-05-13 10:42   ` Dr. Werner Fink
2014-05-13 12:10     ` Ruediger Meier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399543765-31106-2-git-send-email-werner@suse.de \
    --to=werner@suse.de \
    --cc=sweet_f_a@gmx.de \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox