Blame SOURCES/0001-Fix-Be-a-bit-more-descriptive-on-issues-opening-watc.patch

81304d
From 230586043d9efd3a431b64427b0760b3ffbd6b58 Mon Sep 17 00:00:00 2001
81304d
From: Klaus Wenninger <klaus.wenninger@aon.at>
81304d
Date: Wed, 13 Jul 2022 14:46:38 +0200
81304d
Subject: [PATCH] Fix: Be a bit more descriptive on issues opening
81304d
 watchdog-devices
81304d
81304d
Both when running as daemon and with 'test/query-watchdog'
81304d
---
81304d
 src/sbd-common.c | 495 +++++++++++++++++++++++++++++++++----------------------
81304d
 1 file changed, 302 insertions(+), 193 deletions(-)
81304d
81304d
diff --git a/src/sbd-common.c b/src/sbd-common.c
81304d
index b14575f..f3f226a 100644
81304d
--- a/src/sbd-common.c
81304d
+++ b/src/sbd-common.c
81304d
@@ -118,6 +118,62 @@ usage(void)
81304d
                 , cmdname);
81304d
 }
81304d
 
81304d
+#define MAX_WATCHDOGS 64
81304d
+#define SYS_CLASS_WATCHDOG "/sys/class/watchdog"
81304d
+#define SYS_CHAR_DEV_DIR "/sys/dev/char"
81304d
+#define WATCHDOG_NODEDIR "/dev/"
81304d
+
81304d
+static bool
81304d
+is_watchdog(dev_t device)
81304d
+{
81304d
+    static int num_watchdog_devs = 0;
81304d
+    static dev_t watchdog_devs[MAX_WATCHDOGS];
81304d
+    struct dirent *entry;
81304d
+    int i;
81304d
+
81304d
+    /* populate on first call */
81304d
+    if (num_watchdog_devs == 0) {
81304d
+        DIR *dp;
81304d
+
81304d
+        watchdog_devs[0] = makedev(10,130);
81304d
+        num_watchdog_devs = 1;
81304d
+
81304d
+        /* get additional devices from /sys/class/watchdog */
81304d
+        dp = opendir(SYS_CLASS_WATCHDOG);
81304d
+        if (dp) {
81304d
+            while ((entry = readdir(dp))) {
81304d
+                if (entry->d_type == DT_LNK) {
81304d
+                    FILE *file;
81304d
+                    char entry_name[NAME_MAX+sizeof(SYS_CLASS_WATCHDOG)+5];
81304d
+
81304d
+                    snprintf(entry_name, sizeof(entry_name),
81304d
+                        SYS_CLASS_WATCHDOG "/%s/dev", entry->d_name);
81304d
+                    file = fopen(entry_name, "r");
81304d
+                    if (file) {
81304d
+                        int major, minor;
81304d
+
81304d
+                        if (fscanf(file, "%d:%d", &major, &minor) == 2) {
81304d
+                            watchdog_devs[num_watchdog_devs++] = makedev(major, minor);
81304d
+                        }
81304d
+                        fclose(file);
81304d
+                        if (num_watchdog_devs == MAX_WATCHDOGS) {
81304d
+                            break;
81304d
+                        }
81304d
+                    }
81304d
+                }
81304d
+            }
81304d
+            closedir(dp);
81304d
+        }
81304d
+    }
81304d
+
81304d
+    for (i=0; i < num_watchdog_devs; i++) {
81304d
+        if (device == watchdog_devs[i]) {
81304d
+            return true;
81304d
+        }
81304d
+    }
81304d
+    return false;
81304d
+}
81304d
+
81304d
 static int
81304d
 watchdog_init_interval_fd(int wdfd, int timeout)
81304d
 {
81304d
@@ -173,20 +229,27 @@ watchdog_tickle(void)
81304d
 static int
81304d
 watchdog_init_fd(char *wddev, int timeout)
81304d
 {
81304d
-	int wdfd;
81304d
+    int wdfd;
81304d
+
81304d
+    wdfd = open(wddev, O_WRONLY);
81304d
+    if (wdfd >= 0) {
81304d
+        if (((timeout >= 0) && (watchdog_init_interval_fd(wdfd, timeout) < 0)) ||
81304d
+            (watchdog_tickle_fd(wdfd, wddev) < 0)) {
81304d
+            close(wdfd);
81304d
+            return -1;
81304d
+        }
81304d
+    } else {
81304d
+        struct stat statbuf;
81304d
 
81304d
-	wdfd = open(wddev, O_WRONLY);
81304d
-	if (wdfd >= 0) {
81304d
-		if (((timeout >= 0) && (watchdog_init_interval_fd(wdfd, timeout) < 0))
81304d
-					|| (watchdog_tickle_fd(wdfd, wddev) < 0)) {
81304d
-			close(wdfd);
81304d
-			return -1;
81304d
-		}
81304d
-	} else {
81304d
-		cl_perror("Cannot open watchdog device '%s'", wddev);
81304d
-		return -1;
81304d
-	}
81304d
-	return wdfd;
81304d
+        if(!stat(wddev, &statbuf) && S_ISCHR(statbuf.st_mode) &&
81304d
+           is_watchdog(statbuf.st_rdev)) {
81304d
+            cl_perror("Cannot open watchdog device '%s'", wddev);
81304d
+        } else {
81304d
+            cl_perror("Seems as if '%s' isn't a valid watchdog-device", wddev);
81304d
+        }
81304d
+        return -1;
81304d
+    }
81304d
+    return wdfd;
81304d
 }
81304d
 
81304d
 int
81304d
@@ -250,17 +313,13 @@ watchdog_close(bool disarm)
81304d
     watchdogfd = -1;
81304d
 }
81304d
 
81304d
-#define MAX_WATCHDOGS 64
81304d
-#define SYS_CLASS_WATCHDOG "/sys/class/watchdog"
81304d
-#define SYS_CHAR_DEV_DIR "/sys/dev/char"
81304d
-#define WATCHDOG_NODEDIR "/dev/"
81304d
-#define WATCHDOG_NODEDIR_LEN 5
81304d
-
81304d
 struct watchdog_list_item {
81304d
 	dev_t dev;
81304d
 	char *dev_node;
81304d
 	char *dev_ident;
81304d
 	char *dev_driver;
81304d
+	pid_t busy_pid;
81304d
+	char *busy_name;
81304d
 	struct watchdog_list_item *next;
81304d
 };
81304d
 
81304d
@@ -276,184 +335,223 @@ static int watchdog_list_items = 0;
81304d
 static void
81304d
 watchdog_populate_list(void)
81304d
 {
81304d
-	dev_t watchdogs[MAX_WATCHDOGS + 1] =
81304d
-		{makedev(10,130), 0};
81304d
-	int num_watchdogs = 1;
81304d
-	struct dirent *entry;
81304d
-	char entry_name[280];
81304d
-	DIR *dp;
81304d
-	char buf[280] = "";
81304d
-	struct link_list_item *link_list = NULL;
81304d
-
81304d
-	if (watchdog_list != NULL) {
81304d
-		return;
81304d
-	}
81304d
+    struct dirent *entry;
81304d
+    char entry_name[sizeof(WATCHDOG_NODEDIR)+NAME_MAX];
81304d
+    DIR *dp;
81304d
+    char buf[NAME_MAX+sizeof(WATCHDOG_NODEDIR)] = "";
81304d
+    struct link_list_item *link_list = NULL;
81304d
 
81304d
-	/* get additional devices from /sys/class/watchdog */
81304d
-	dp = opendir(SYS_CLASS_WATCHDOG);
81304d
-	if (dp) {
81304d
-		while ((entry = readdir(dp))) {
81304d
-			if (entry->d_type == DT_LNK) {
81304d
-				FILE *file;
81304d
-
81304d
-				snprintf(entry_name, sizeof(entry_name),
81304d
-						 SYS_CLASS_WATCHDOG "/%s/dev", entry->d_name);
81304d
-				file = fopen(entry_name, "r");
81304d
-				if (file) {
81304d
-					int major, minor;
81304d
-
81304d
-					if (fscanf(file, "%d:%d", &major, &minor) == 2) {
81304d
-						watchdogs[num_watchdogs++] = makedev(major, minor);
81304d
-					}
81304d
-					fclose(file);
81304d
-					if (num_watchdogs == MAX_WATCHDOGS) {
81304d
-						break;
81304d
-					}
81304d
-				}
81304d
-			}
81304d
-		}
81304d
-		closedir(dp);
81304d
-	}
81304d
+    if (watchdog_list != NULL) {
81304d
+        return;
81304d
+    }
81304d
 
81304d
-	/* search for watchdog nodes in /dev */
81304d
-	dp = opendir(WATCHDOG_NODEDIR);
81304d
-	if (dp) {
81304d
-		/* first go for links and memorize them */
81304d
-		while ((entry = readdir(dp))) {
81304d
-			if (entry->d_type == DT_LNK) {
81304d
-				int len;
81304d
-
81304d
-				snprintf(entry_name, sizeof(entry_name),
81304d
-				         WATCHDOG_NODEDIR "%s", entry->d_name);
81304d
-
81304d
-				/* !realpath(entry_name, buf) unfortunately does a stat on
81304d
-				 * target so we can't really use it to check if links stay
81304d
-				 * within /dev without triggering e.g. AVC-logs (with
81304d
-				 * SELinux policy that just allows stat within /dev).
81304d
-				 * Without canonicalization that doesn't actually touch the
81304d
-				 * filesystem easily available introduce some limitations
81304d
-				 * for simplicity:
81304d
-				 * - just simple path without '..'
81304d
-				 * - just one level of symlinks (avoid e.g. loop-checking)
81304d
-				 */
81304d
-				len = readlink(entry_name, buf, sizeof(buf) - 1);
81304d
-				if ((len < 1) ||
81304d
-				    (len > sizeof(buf) - WATCHDOG_NODEDIR_LEN - 1)) {
81304d
-					continue;
81304d
-				}
81304d
-				buf[len] = '\0';
81304d
-				if (buf[0] != '/') {
81304d
-					memmove(&buf[WATCHDOG_NODEDIR_LEN], buf, len+1);
81304d
-					memcpy(buf, WATCHDOG_NODEDIR, WATCHDOG_NODEDIR_LEN);
81304d
-					len += WATCHDOG_NODEDIR_LEN;
81304d
-				}
81304d
-				if (strstr(buf, "/../") ||
81304d
-				    strncmp(WATCHDOG_NODEDIR, buf, WATCHDOG_NODEDIR_LEN)) {
81304d
-					continue;
81304d
-				} else {
81304d
-					/* just memorize to avoid statting the target - SELinux */
81304d
-					struct link_list_item *lli =
81304d
-						calloc(1, sizeof(struct link_list_item));
81304d
-
81304d
-					lli->dev_node = strdup(buf);
81304d
-					lli->link_name = strdup(entry_name);
81304d
-					lli->next = link_list;
81304d
-					link_list = lli;
81304d
-				}
81304d
-			}
81304d
-		}
81304d
+    /* search for watchdog nodes in /dev */
81304d
+    dp = opendir(WATCHDOG_NODEDIR);
81304d
+    if (dp) {
81304d
+        /* first go for links and memorize them */
81304d
+        while ((entry = readdir(dp))) {
81304d
+            if (entry->d_type == DT_LNK) {
81304d
+                int len;
81304d
+
81304d
+                snprintf(entry_name, sizeof(entry_name),
81304d
+                         WATCHDOG_NODEDIR "%s", entry->d_name);
81304d
+
81304d
+                /* realpath(entry_name, buf) unfortunately does a stat on
81304d
+                 * target so we can't really use it to check if links stay
81304d
+                 * within /dev without triggering e.g. AVC-logs (with
81304d
+                 * SELinux policy that just allows stat within /dev).
81304d
+                 * Without canonicalization that doesn't actually touch the
81304d
+                 * filesystem easily available introduce some limitations
81304d
+                 * for simplicity:
81304d
+                 * - just simple path without '..'
81304d
+                 * - just one level of symlinks (avoid e.g. loop-checking)
81304d
+                 */
81304d
+                len = readlink(entry_name, buf, sizeof(buf) - 1);
81304d
+                if ((len < 1) ||
81304d
+                    (len > sizeof(buf) - sizeof(WATCHDOG_NODEDIR) -1 - 1)) {
81304d
+                    continue;
81304d
+                }
81304d
+                buf[len] = '\0';
81304d
+                if (buf[0] != '/') {
81304d
+                    memmove(&buf[sizeof(WATCHDOG_NODEDIR)-1], buf, len+1);
81304d
+                    memcpy(buf, WATCHDOG_NODEDIR, sizeof(WATCHDOG_NODEDIR)-1);
81304d
+                    len += sizeof(WATCHDOG_NODEDIR)-1;
81304d
+                }
81304d
+                if (strstr(buf, "/../") ||
81304d
+                    strncmp(WATCHDOG_NODEDIR, buf, sizeof(WATCHDOG_NODEDIR)-1)) {
81304d
+                    continue;
81304d
+                } else {
81304d
+                    /* just memorize to avoid statting the target - SELinux */
81304d
+                    struct link_list_item *lli =
81304d
+                        calloc(1, sizeof(struct link_list_item));
81304d
+
81304d
+                    lli->dev_node = strdup(buf);
81304d
+                    lli->link_name = strdup(entry_name);
81304d
+                    lli->next = link_list;
81304d
+                    link_list = lli;
81304d
+                }
81304d
+            }
81304d
+        }
81304d
 
81304d
-		rewinddir(dp);
81304d
-
81304d
-		while ((entry = readdir(dp))) {
81304d
-			if (entry->d_type == DT_CHR) {
81304d
-				struct stat statbuf;
81304d
-
81304d
-				snprintf(entry_name, sizeof(entry_name),
81304d
-				         WATCHDOG_NODEDIR "%s", entry->d_name);
81304d
-				if(!stat(entry_name, &statbuf) && S_ISCHR(statbuf.st_mode)) {
81304d
-					int i;
81304d
-
81304d
-					for (i=0; i
81304d
-						if (statbuf.st_rdev == watchdogs[i]) {
81304d
-							int wdfd = watchdog_init_fd(entry_name, -1);
81304d
-							struct watchdog_list_item *wdg =
81304d
-								calloc(1, sizeof(struct watchdog_list_item));
81304d
-							int len;
81304d
-							struct link_list_item *tmp_list = NULL;
81304d
-
81304d
-							wdg->dev = watchdogs[i];
81304d
-							wdg->dev_node = strdup(entry_name);
81304d
-							wdg->next = watchdog_list;
81304d
-							watchdog_list = wdg;
81304d
-							watchdog_list_items++;
81304d
-
81304d
-							if (wdfd >= 0) {
81304d
-								struct watchdog_info ident;
81304d
-
81304d
-								ident.identity[0] = '\0';
81304d
-								ioctl(wdfd, WDIOC_GETSUPPORT, &ident);
81304d
-								watchdog_close_fd(wdfd, entry_name, true);
81304d
-								if (ident.identity[0]) {
81304d
-									wdg->dev_ident = strdup((char *) ident.identity);
81304d
-								}
81304d
-							}
81304d
-
81304d
-							snprintf(entry_name, sizeof(entry_name),
81304d
-							         SYS_CHAR_DEV_DIR "/%d:%d/device/driver",
81304d
-							         major(watchdogs[i]), minor(watchdogs[i]));
81304d
-							len = readlink(entry_name, buf, sizeof(buf) - 1);
81304d
-							if (len > 0) {
81304d
-								buf[len] = '\0';
81304d
-								wdg->dev_driver = strdup(basename(buf));
81304d
-							} else if ((wdg->dev_ident) &&
81304d
-							           (strcmp(wdg->dev_ident,
81304d
-							                   "Software Watchdog") == 0)) {
81304d
-								wdg->dev_driver = strdup("softdog");
81304d
-							}
81304d
-
81304d
-							/* create dupes if we have memorized links
81304d
-							 * to this node
81304d
-							 */
81304d
-							for (tmp_list = link_list; tmp_list;
81304d
-							     tmp_list = tmp_list->next) {
81304d
-								if (!strcmp(tmp_list->dev_node,
81304d
-								            wdg->dev_node)) {
81304d
-									struct watchdog_list_item *dupe_wdg =
81304d
-										calloc(1, sizeof(struct watchdog_list_item));
81304d
-
81304d
-									/* as long as we never purge watchdog_list
81304d
-									 * there is no need to dupe strings
81304d
-									 */
81304d
-									*dupe_wdg = *wdg;
81304d
-									dupe_wdg->dev_node = strdup(tmp_list->link_name);
81304d
-									dupe_wdg->next = watchdog_list;
81304d
-									watchdog_list = dupe_wdg;
81304d
-									watchdog_list_items++;
81304d
-								}
81304d
-								/* for performance reasons we could remove
81304d
-								 * the link_list entry
81304d
-								 */
81304d
-							}
81304d
-							break;
81304d
-						}
81304d
-					}
81304d
-				}
81304d
-			}
81304d
-		}
81304d
+        rewinddir(dp);
81304d
+
81304d
+        while ((entry = readdir(dp))) {
81304d
+            if (entry->d_type == DT_CHR) {
81304d
+                struct stat statbuf;
81304d
+
81304d
+                snprintf(entry_name, sizeof(entry_name),
81304d
+                            WATCHDOG_NODEDIR "%s", entry->d_name);
81304d
+                if(!stat(entry_name, &statbuf) && S_ISCHR(statbuf.st_mode) &&
81304d
+                   is_watchdog(statbuf.st_rdev)) {
81304d
+
81304d
+                    int wdfd = watchdog_init_fd(entry_name, -1);
81304d
+                    struct watchdog_list_item *wdg =
81304d
+                        calloc(1, sizeof(struct watchdog_list_item));
81304d
+                    int len;
81304d
+                    struct link_list_item *tmp_list = NULL;
81304d
+
81304d
+                    wdg->dev = statbuf.st_rdev;
81304d
+                    wdg->dev_node = strdup(entry_name);
81304d
+                    wdg->next = watchdog_list;
81304d
+                    watchdog_list = wdg;
81304d
+                    watchdog_list_items++;
81304d
+
81304d
+                    if (wdfd >= 0) {
81304d
+                        struct watchdog_info ident;
81304d
+
81304d
+                        ident.identity[0] = '\0';
81304d
+                        ioctl(wdfd, WDIOC_GETSUPPORT, &ident);
81304d
+                        watchdog_close_fd(wdfd, entry_name, true);
81304d
+                        if (ident.identity[0]) {
81304d
+                            wdg->dev_ident = strdup((char *) ident.identity);
81304d
+                        }
81304d
+                    }
81304d
+
81304d
+                    snprintf(entry_name, sizeof(entry_name),
81304d
+                                SYS_CHAR_DEV_DIR "/%d:%d/device/driver",
81304d
+                                major(wdg->dev), minor(wdg->dev));
81304d
+                    len = readlink(entry_name, buf, sizeof(buf) - 1);
81304d
+                    if (len > 0) {
81304d
+                        buf[len] = '\0';
81304d
+                        wdg->dev_driver = strdup(basename(buf));
81304d
+                    } else if ((wdg->dev_ident) &&
81304d
+                               (strcmp(wdg->dev_ident,
81304d
+                                       "Software Watchdog") == 0)) {
81304d
+                        wdg->dev_driver = strdup("softdog");
81304d
+                    }
81304d
+
81304d
+                    /* create dupes if we have memorized links
81304d
+                     * to this node
81304d
+                     */
81304d
+                    for (tmp_list = link_list; tmp_list;
81304d
+                            tmp_list = tmp_list->next) {
81304d
+                        if (!strcmp(tmp_list->dev_node,
81304d
+                                    wdg->dev_node)) {
81304d
+                            struct watchdog_list_item *dupe_wdg =
81304d
+                                calloc(1, sizeof(struct watchdog_list_item));
81304d
+
81304d
+                            /* as long as we never purge watchdog_list
81304d
+                             * there is no need to dupe strings
81304d
+                             */
81304d
+                            *dupe_wdg = *wdg;
81304d
+                            dupe_wdg->dev_node = strdup(tmp_list->link_name);
81304d
+                            dupe_wdg->next = watchdog_list;
81304d
+                            watchdog_list = dupe_wdg;
81304d
+                            watchdog_list_items++;
81304d
+                        }
81304d
+                        /* for performance reasons we could remove
81304d
+                         * the link_list entry
81304d
+                         */
81304d
+                    }
81304d
+                }
81304d
+            }
81304d
+        }
81304d
 
81304d
-		closedir(dp);
81304d
-	}
81304d
+        closedir(dp);
81304d
+    }
81304d
 
81304d
-	/* cleanup link list */
81304d
-	while (link_list) {
81304d
-		struct link_list_item *tmp_list = link_list;
81304d
+    /* cleanup link list */
81304d
+    while (link_list) {
81304d
+        struct link_list_item *tmp_list = link_list;
81304d
 
81304d
-		link_list = link_list->next;
81304d
-		free(tmp_list->dev_node);
81304d
-		free(tmp_list->link_name);
81304d
-		free(tmp_list);
81304d
-	}
81304d
+        link_list = link_list->next;
81304d
+        free(tmp_list->dev_node);
81304d
+        free(tmp_list->link_name);
81304d
+        free(tmp_list);
81304d
+    }
81304d
+}
81304d
+
81304d
+static void
81304d
+watchdog_checkbusy()
81304d
+{
81304d
+    DIR *dproc;
81304d
+    struct dirent *entry;
81304d
+
81304d
+    dproc = opendir("/proc");
81304d
+    if (!dproc) {
81304d
+        /* no proc directory to search through */
81304d
+        return;
81304d
+    }
81304d
+
81304d
+    while ((entry = readdir(dproc)) != NULL) {
81304d
+        pid_t local_pid;
81304d
+        char *leftover;
81304d
+        DIR *dpid;
81304d
+        char procpath[NAME_MAX+10] = { 0 };
81304d
+
81304d
+        if (entry->d_name[0] == '.') {
81304d
+            continue;
81304d
+        }
81304d
+
81304d
+        local_pid = strtol(entry->d_name, &leftover, 10);
81304d
+        if (leftover[0] != '\0')
81304d
+            continue;
81304d
+
81304d
+        snprintf(procpath, sizeof(procpath), "/proc/%s/fd", entry->d_name);
81304d
+        dpid = opendir(procpath);
81304d
+        if (!dpid) {
81304d
+            /* silently continue - might be just a race */
81304d
+            continue;
81304d
+        }
81304d
+        while ((entry = readdir(dpid)) != NULL) {
81304d
+            struct watchdog_list_item *wdg;
81304d
+            char entry_name[sizeof(procpath)+NAME_MAX+1] = { 0 };
81304d
+            char buf[NAME_MAX+1] = { 0 };
81304d
+            int len;
81304d
+
81304d
+            if (entry->d_type != DT_LNK) {
81304d
+                continue;
81304d
+            }
81304d
+            snprintf(entry_name, sizeof(entry_name),
81304d
+                     "%s/%s", procpath, entry->d_name);
81304d
+            len = readlink(entry_name, buf, sizeof(buf) - 1);
81304d
+            if (len < 1) {
81304d
+                continue;
81304d
+            }
81304d
+            buf[len] = '\0';
81304d
+            for (wdg = watchdog_list; wdg != NULL; wdg = wdg->next) {
81304d
+                if (!strcmp(buf, wdg->dev_node)) {
81304d
+                    char name[16];
81304d
+                    FILE *file;
81304d
+
81304d
+                    wdg->busy_pid = local_pid;
81304d
+                    snprintf(procpath, sizeof(procpath), "/proc/%d/status", local_pid);
81304d
+                    file = fopen(procpath, "r");
81304d
+                    if (file) {
81304d
+                        if (fscanf(file, "Name:\t%15[a-zA-Z0-9 _-]", name) == 1) {
81304d
+                            wdg->busy_name = strdup(name);
81304d
+                        }
81304d
+                        fclose(file);
81304d
+                    }
81304d
+                }
81304d
+            }
81304d
+        }
81304d
+        closedir(dpid);
81304d
+    }
81304d
+
81304d
+    closedir(dproc);
81304d
+
81304d
+    return;
81304d
 }
81304d
 
81304d
 int watchdog_info(void)
81304d
@@ -462,13 +560,23 @@ int watchdog_info(void)
81304d
 	int wdg_cnt = 0;
81304d
 
81304d
 	watchdog_populate_list();
81304d
+	watchdog_checkbusy();
81304d
 	printf("\nDiscovered %d watchdog devices:\n", watchdog_list_items);
81304d
 	for (wdg = watchdog_list; wdg != NULL; wdg = wdg->next) {
81304d
 		wdg_cnt++;
81304d
-		printf("\n[%d] %s\nIdentity: %s\nDriver: %s\n",
81304d
+		if (wdg->busy_pid) {
81304d
+			printf("\n[%d] %s\nIdentity: Busy: PID %d (%s)\nDriver: %s\n",
81304d
 				wdg_cnt, wdg->dev_node,
81304d
-				wdg->dev_ident?wdg->dev_ident:"Error: Check if hogged by e.g. sbd-daemon!",
81304d
+				wdg->busy_pid,
81304d
+				wdg->busy_name?wdg->busy_name:"<unknown>",
81304d
 				wdg->dev_driver?wdg->dev_driver:"<unknown>");
81304d
+		} else {
81304d
+			printf("\n[%d] %s\nIdentity: %s\nDriver: %s\n",
81304d
+				wdg_cnt, wdg->dev_node,
81304d
+				wdg->dev_ident?wdg->dev_ident:
81304d
+					"Error: device hogged via alias major/minor?",
81304d
+				wdg->dev_driver?wdg->dev_driver:"<unknown>");
81304d
+		}
81304d
 		if ((wdg->dev_driver) && (strcmp(wdg->dev_driver, "softdog") == 0)) {
81304d
 			printf("CAUTION: Not recommended for use with sbd.\n"); 
81304d
 		}
81304d
@@ -512,6 +620,7 @@ int watchdog_test(void)
81304d
 		watchdogdev, (int) timeout_watchdog);
81304d
 	if ((watchdog_init() < 0) || (watchdog_init_interval() < 0)) {
81304d
 		printf("Failed to initialize watchdog!!!\n");
81304d
+		watchdog_info();
81304d
 		return -1;
81304d
 	}
81304d
 	printf("\n");
81304d
-- 
81304d
1.8.3.1
81304d