linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: md@Linux.IT (Marco d'Itri)
To: linux-hotplug@vger.kernel.org
Subject: RFC: verbose output for udevadm settle
Date: Wed, 09 Jul 2008 23:25:17 +0000	[thread overview]
Message-ID: <20080709232517.GA11490@bongo.bofh.it> (raw)

[-- Attachment #1: Type: text/plain, Size: 264 bytes --]

From time to time I get bugs about udevadm settle timeouts at boot time,
and usually they are quite hard to investigate for random users.
So I tought about being verbose about what is left in the queue when the
timeout is reached.
Please comment.

-- 
ciao,
Marco

[-- Attachment #2: settle_verbose_timeout --]
[-- Type: text/plain, Size: 1097 bytes --]

--- a/udevsettle.c
+++ b/udevsettle.c
@@ -31,10 +31,43 @@
 
 #include "udev.h"
 #include "udevd.h"
+#include "list.h"
 
 #define DEFAULT_TIMEOUT			180
 #define LOOP_PER_SECOND			20
 
+static void print_queue(const char *dir)
+{
+	LIST_HEAD(files);
+	struct name_entry *item;
+
+	if (add_matching_files(&files, dir, NULL) < 0)
+		return;
+
+	printf("\n\nAfter the udevsettle timeout, the events queue contains:\n\n");
+
+	list_for_each_entry(item, &files, node) {
+		char target[NAME_SIZE];
+		size_t len;
+		const char *filename = strrchr(item->name, '/');
+
+		if (filename == NULL)
+			continue;
+		filename++;
+		if (*filename == '\0')
+			continue;
+
+		len = readlink(item->name, target, sizeof(target));
+		if (len < 0)
+			continue;
+		target[len] = '\0';
+
+		printf("%s: %s\n", filename, target);
+	}
+
+	printf("\n\n");
+}
+
 int udevsettle(int argc, char *argv[], char *envp[])
 {
 	char queuename[PATH_SIZE];
@@ -97,6 +130,7 @@ int udevsettle(int argc, char *argv[], c
 		}
 		if (loop <= 0) {
 			info("timeout waiting for queue\n");
+			print_queue(queuename);
 			goto exit;
 		}
 

             reply	other threads:[~2008-07-09 23:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-09 23:25 Marco d'Itri [this message]
2008-07-10 22:56 ` RFC: verbose output for udevadm settle Kay Sievers

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=20080709232517.GA11490@bongo.bofh.it \
    --to=md@linux.it \
    --cc=linux-hotplug@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;
as well as URLs for NNTP newsgroup(s).