commit
b39bccc79d
@ -0,0 +1 @@
|
||||
SOURCES/sbd-6bb085f5704dd4c3841c79504f2aed2228e6d76a.tar.gz
|
@ -0,0 +1 @@
|
||||
50c4fbd14ecf01d05a1bcf014aaa3ab128930d03 SOURCES/sbd-6bb085f5704dd4c3841c79504f2aed2228e6d76a.tar.gz
|
@ -0,0 +1,572 @@
|
||||
From 230586043d9efd3a431b64427b0760b3ffbd6b58 Mon Sep 17 00:00:00 2001
|
||||
From: Klaus Wenninger <klaus.wenninger@aon.at>
|
||||
Date: Wed, 13 Jul 2022 14:46:38 +0200
|
||||
Subject: [PATCH] Fix: Be a bit more descriptive on issues opening
|
||||
watchdog-devices
|
||||
|
||||
Both when running as daemon and with 'test/query-watchdog'
|
||||
---
|
||||
src/sbd-common.c | 495 +++++++++++++++++++++++++++++++++----------------------
|
||||
1 file changed, 302 insertions(+), 193 deletions(-)
|
||||
|
||||
diff --git a/src/sbd-common.c b/src/sbd-common.c
|
||||
index b14575f..f3f226a 100644
|
||||
--- a/src/sbd-common.c
|
||||
+++ b/src/sbd-common.c
|
||||
@@ -118,6 +118,62 @@ usage(void)
|
||||
, cmdname);
|
||||
}
|
||||
|
||||
+#define MAX_WATCHDOGS 64
|
||||
+#define SYS_CLASS_WATCHDOG "/sys/class/watchdog"
|
||||
+#define SYS_CHAR_DEV_DIR "/sys/dev/char"
|
||||
+#define WATCHDOG_NODEDIR "/dev/"
|
||||
+
|
||||
+static bool
|
||||
+is_watchdog(dev_t device)
|
||||
+{
|
||||
+ static int num_watchdog_devs = 0;
|
||||
+ static dev_t watchdog_devs[MAX_WATCHDOGS];
|
||||
+ struct dirent *entry;
|
||||
+ int i;
|
||||
+
|
||||
+ /* populate on first call */
|
||||
+ if (num_watchdog_devs == 0) {
|
||||
+ DIR *dp;
|
||||
+
|
||||
+ watchdog_devs[0] = makedev(10,130);
|
||||
+ num_watchdog_devs = 1;
|
||||
+
|
||||
+ /* get additional devices from /sys/class/watchdog */
|
||||
+ dp = opendir(SYS_CLASS_WATCHDOG);
|
||||
+ if (dp) {
|
||||
+ while ((entry = readdir(dp))) {
|
||||
+ if (entry->d_type == DT_LNK) {
|
||||
+ FILE *file;
|
||||
+ char entry_name[NAME_MAX+sizeof(SYS_CLASS_WATCHDOG)+5];
|
||||
+
|
||||
+ snprintf(entry_name, sizeof(entry_name),
|
||||
+ SYS_CLASS_WATCHDOG "/%s/dev", entry->d_name);
|
||||
+ file = fopen(entry_name, "r");
|
||||
+ if (file) {
|
||||
+ int major, minor;
|
||||
+
|
||||
+ if (fscanf(file, "%d:%d", &major, &minor) == 2) {
|
||||
+ watchdog_devs[num_watchdog_devs++] = makedev(major, minor);
|
||||
+ }
|
||||
+ fclose(file);
|
||||
+ if (num_watchdog_devs == MAX_WATCHDOGS) {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ closedir(dp);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for (i=0; i < num_watchdog_devs; i++) {
|
||||
+ if (device == watchdog_devs[i]) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
static int
|
||||
watchdog_init_interval_fd(int wdfd, int timeout)
|
||||
{
|
||||
@@ -173,20 +229,27 @@ watchdog_tickle(void)
|
||||
static int
|
||||
watchdog_init_fd(char *wddev, int timeout)
|
||||
{
|
||||
- int wdfd;
|
||||
+ int wdfd;
|
||||
+
|
||||
+ wdfd = open(wddev, O_WRONLY);
|
||||
+ if (wdfd >= 0) {
|
||||
+ if (((timeout >= 0) && (watchdog_init_interval_fd(wdfd, timeout) < 0)) ||
|
||||
+ (watchdog_tickle_fd(wdfd, wddev) < 0)) {
|
||||
+ close(wdfd);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } else {
|
||||
+ struct stat statbuf;
|
||||
|
||||
- wdfd = open(wddev, O_WRONLY);
|
||||
- if (wdfd >= 0) {
|
||||
- if (((timeout >= 0) && (watchdog_init_interval_fd(wdfd, timeout) < 0))
|
||||
- || (watchdog_tickle_fd(wdfd, wddev) < 0)) {
|
||||
- close(wdfd);
|
||||
- return -1;
|
||||
- }
|
||||
- } else {
|
||||
- cl_perror("Cannot open watchdog device '%s'", wddev);
|
||||
- return -1;
|
||||
- }
|
||||
- return wdfd;
|
||||
+ if(!stat(wddev, &statbuf) && S_ISCHR(statbuf.st_mode) &&
|
||||
+ is_watchdog(statbuf.st_rdev)) {
|
||||
+ cl_perror("Cannot open watchdog device '%s'", wddev);
|
||||
+ } else {
|
||||
+ cl_perror("Seems as if '%s' isn't a valid watchdog-device", wddev);
|
||||
+ }
|
||||
+ return -1;
|
||||
+ }
|
||||
+ return wdfd;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -250,17 +313,13 @@ watchdog_close(bool disarm)
|
||||
watchdogfd = -1;
|
||||
}
|
||||
|
||||
-#define MAX_WATCHDOGS 64
|
||||
-#define SYS_CLASS_WATCHDOG "/sys/class/watchdog"
|
||||
-#define SYS_CHAR_DEV_DIR "/sys/dev/char"
|
||||
-#define WATCHDOG_NODEDIR "/dev/"
|
||||
-#define WATCHDOG_NODEDIR_LEN 5
|
||||
-
|
||||
struct watchdog_list_item {
|
||||
dev_t dev;
|
||||
char *dev_node;
|
||||
char *dev_ident;
|
||||
char *dev_driver;
|
||||
+ pid_t busy_pid;
|
||||
+ char *busy_name;
|
||||
struct watchdog_list_item *next;
|
||||
};
|
||||
|
||||
@@ -276,184 +335,223 @@ static int watchdog_list_items = 0;
|
||||
static void
|
||||
watchdog_populate_list(void)
|
||||
{
|
||||
- dev_t watchdogs[MAX_WATCHDOGS + 1] =
|
||||
- {makedev(10,130), 0};
|
||||
- int num_watchdogs = 1;
|
||||
- struct dirent *entry;
|
||||
- char entry_name[280];
|
||||
- DIR *dp;
|
||||
- char buf[280] = "";
|
||||
- struct link_list_item *link_list = NULL;
|
||||
-
|
||||
- if (watchdog_list != NULL) {
|
||||
- return;
|
||||
- }
|
||||
+ struct dirent *entry;
|
||||
+ char entry_name[sizeof(WATCHDOG_NODEDIR)+NAME_MAX];
|
||||
+ DIR *dp;
|
||||
+ char buf[NAME_MAX+sizeof(WATCHDOG_NODEDIR)] = "";
|
||||
+ struct link_list_item *link_list = NULL;
|
||||
|
||||
- /* get additional devices from /sys/class/watchdog */
|
||||
- dp = opendir(SYS_CLASS_WATCHDOG);
|
||||
- if (dp) {
|
||||
- while ((entry = readdir(dp))) {
|
||||
- if (entry->d_type == DT_LNK) {
|
||||
- FILE *file;
|
||||
-
|
||||
- snprintf(entry_name, sizeof(entry_name),
|
||||
- SYS_CLASS_WATCHDOG "/%s/dev", entry->d_name);
|
||||
- file = fopen(entry_name, "r");
|
||||
- if (file) {
|
||||
- int major, minor;
|
||||
-
|
||||
- if (fscanf(file, "%d:%d", &major, &minor) == 2) {
|
||||
- watchdogs[num_watchdogs++] = makedev(major, minor);
|
||||
- }
|
||||
- fclose(file);
|
||||
- if (num_watchdogs == MAX_WATCHDOGS) {
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- closedir(dp);
|
||||
- }
|
||||
+ if (watchdog_list != NULL) {
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
- /* search for watchdog nodes in /dev */
|
||||
- dp = opendir(WATCHDOG_NODEDIR);
|
||||
- if (dp) {
|
||||
- /* first go for links and memorize them */
|
||||
- while ((entry = readdir(dp))) {
|
||||
- if (entry->d_type == DT_LNK) {
|
||||
- int len;
|
||||
-
|
||||
- snprintf(entry_name, sizeof(entry_name),
|
||||
- WATCHDOG_NODEDIR "%s", entry->d_name);
|
||||
-
|
||||
- /* !realpath(entry_name, buf) unfortunately does a stat on
|
||||
- * target so we can't really use it to check if links stay
|
||||
- * within /dev without triggering e.g. AVC-logs (with
|
||||
- * SELinux policy that just allows stat within /dev).
|
||||
- * Without canonicalization that doesn't actually touch the
|
||||
- * filesystem easily available introduce some limitations
|
||||
- * for simplicity:
|
||||
- * - just simple path without '..'
|
||||
- * - just one level of symlinks (avoid e.g. loop-checking)
|
||||
- */
|
||||
- len = readlink(entry_name, buf, sizeof(buf) - 1);
|
||||
- if ((len < 1) ||
|
||||
- (len > sizeof(buf) - WATCHDOG_NODEDIR_LEN - 1)) {
|
||||
- continue;
|
||||
- }
|
||||
- buf[len] = '\0';
|
||||
- if (buf[0] != '/') {
|
||||
- memmove(&buf[WATCHDOG_NODEDIR_LEN], buf, len+1);
|
||||
- memcpy(buf, WATCHDOG_NODEDIR, WATCHDOG_NODEDIR_LEN);
|
||||
- len += WATCHDOG_NODEDIR_LEN;
|
||||
- }
|
||||
- if (strstr(buf, "/../") ||
|
||||
- strncmp(WATCHDOG_NODEDIR, buf, WATCHDOG_NODEDIR_LEN)) {
|
||||
- continue;
|
||||
- } else {
|
||||
- /* just memorize to avoid statting the target - SELinux */
|
||||
- struct link_list_item *lli =
|
||||
- calloc(1, sizeof(struct link_list_item));
|
||||
-
|
||||
- lli->dev_node = strdup(buf);
|
||||
- lli->link_name = strdup(entry_name);
|
||||
- lli->next = link_list;
|
||||
- link_list = lli;
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
+ /* search for watchdog nodes in /dev */
|
||||
+ dp = opendir(WATCHDOG_NODEDIR);
|
||||
+ if (dp) {
|
||||
+ /* first go for links and memorize them */
|
||||
+ while ((entry = readdir(dp))) {
|
||||
+ if (entry->d_type == DT_LNK) {
|
||||
+ int len;
|
||||
+
|
||||
+ snprintf(entry_name, sizeof(entry_name),
|
||||
+ WATCHDOG_NODEDIR "%s", entry->d_name);
|
||||
+
|
||||
+ /* realpath(entry_name, buf) unfortunately does a stat on
|
||||
+ * target so we can't really use it to check if links stay
|
||||
+ * within /dev without triggering e.g. AVC-logs (with
|
||||
+ * SELinux policy that just allows stat within /dev).
|
||||
+ * Without canonicalization that doesn't actually touch the
|
||||
+ * filesystem easily available introduce some limitations
|
||||
+ * for simplicity:
|
||||
+ * - just simple path without '..'
|
||||
+ * - just one level of symlinks (avoid e.g. loop-checking)
|
||||
+ */
|
||||
+ len = readlink(entry_name, buf, sizeof(buf) - 1);
|
||||
+ if ((len < 1) ||
|
||||
+ (len > sizeof(buf) - sizeof(WATCHDOG_NODEDIR) -1 - 1)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ buf[len] = '\0';
|
||||
+ if (buf[0] != '/') {
|
||||
+ memmove(&buf[sizeof(WATCHDOG_NODEDIR)-1], buf, len+1);
|
||||
+ memcpy(buf, WATCHDOG_NODEDIR, sizeof(WATCHDOG_NODEDIR)-1);
|
||||
+ len += sizeof(WATCHDOG_NODEDIR)-1;
|
||||
+ }
|
||||
+ if (strstr(buf, "/../") ||
|
||||
+ strncmp(WATCHDOG_NODEDIR, buf, sizeof(WATCHDOG_NODEDIR)-1)) {
|
||||
+ continue;
|
||||
+ } else {
|
||||
+ /* just memorize to avoid statting the target - SELinux */
|
||||
+ struct link_list_item *lli =
|
||||
+ calloc(1, sizeof(struct link_list_item));
|
||||
+
|
||||
+ lli->dev_node = strdup(buf);
|
||||
+ lli->link_name = strdup(entry_name);
|
||||
+ lli->next = link_list;
|
||||
+ link_list = lli;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- rewinddir(dp);
|
||||
-
|
||||
- while ((entry = readdir(dp))) {
|
||||
- if (entry->d_type == DT_CHR) {
|
||||
- struct stat statbuf;
|
||||
-
|
||||
- snprintf(entry_name, sizeof(entry_name),
|
||||
- WATCHDOG_NODEDIR "%s", entry->d_name);
|
||||
- if(!stat(entry_name, &statbuf) && S_ISCHR(statbuf.st_mode)) {
|
||||
- int i;
|
||||
-
|
||||
- for (i=0; i<num_watchdogs; i++) {
|
||||
- if (statbuf.st_rdev == watchdogs[i]) {
|
||||
- int wdfd = watchdog_init_fd(entry_name, -1);
|
||||
- struct watchdog_list_item *wdg =
|
||||
- calloc(1, sizeof(struct watchdog_list_item));
|
||||
- int len;
|
||||
- struct link_list_item *tmp_list = NULL;
|
||||
-
|
||||
- wdg->dev = watchdogs[i];
|
||||
- wdg->dev_node = strdup(entry_name);
|
||||
- wdg->next = watchdog_list;
|
||||
- watchdog_list = wdg;
|
||||
- watchdog_list_items++;
|
||||
-
|
||||
- if (wdfd >= 0) {
|
||||
- struct watchdog_info ident;
|
||||
-
|
||||
- ident.identity[0] = '\0';
|
||||
- ioctl(wdfd, WDIOC_GETSUPPORT, &ident);
|
||||
- watchdog_close_fd(wdfd, entry_name, true);
|
||||
- if (ident.identity[0]) {
|
||||
- wdg->dev_ident = strdup((char *) ident.identity);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- snprintf(entry_name, sizeof(entry_name),
|
||||
- SYS_CHAR_DEV_DIR "/%d:%d/device/driver",
|
||||
- major(watchdogs[i]), minor(watchdogs[i]));
|
||||
- len = readlink(entry_name, buf, sizeof(buf) - 1);
|
||||
- if (len > 0) {
|
||||
- buf[len] = '\0';
|
||||
- wdg->dev_driver = strdup(basename(buf));
|
||||
- } else if ((wdg->dev_ident) &&
|
||||
- (strcmp(wdg->dev_ident,
|
||||
- "Software Watchdog") == 0)) {
|
||||
- wdg->dev_driver = strdup("softdog");
|
||||
- }
|
||||
-
|
||||
- /* create dupes if we have memorized links
|
||||
- * to this node
|
||||
- */
|
||||
- for (tmp_list = link_list; tmp_list;
|
||||
- tmp_list = tmp_list->next) {
|
||||
- if (!strcmp(tmp_list->dev_node,
|
||||
- wdg->dev_node)) {
|
||||
- struct watchdog_list_item *dupe_wdg =
|
||||
- calloc(1, sizeof(struct watchdog_list_item));
|
||||
-
|
||||
- /* as long as we never purge watchdog_list
|
||||
- * there is no need to dupe strings
|
||||
- */
|
||||
- *dupe_wdg = *wdg;
|
||||
- dupe_wdg->dev_node = strdup(tmp_list->link_name);
|
||||
- dupe_wdg->next = watchdog_list;
|
||||
- watchdog_list = dupe_wdg;
|
||||
- watchdog_list_items++;
|
||||
- }
|
||||
- /* for performance reasons we could remove
|
||||
- * the link_list entry
|
||||
- */
|
||||
- }
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
+ rewinddir(dp);
|
||||
+
|
||||
+ while ((entry = readdir(dp))) {
|
||||
+ if (entry->d_type == DT_CHR) {
|
||||
+ struct stat statbuf;
|
||||
+
|
||||
+ snprintf(entry_name, sizeof(entry_name),
|
||||
+ WATCHDOG_NODEDIR "%s", entry->d_name);
|
||||
+ if(!stat(entry_name, &statbuf) && S_ISCHR(statbuf.st_mode) &&
|
||||
+ is_watchdog(statbuf.st_rdev)) {
|
||||
+
|
||||
+ int wdfd = watchdog_init_fd(entry_name, -1);
|
||||
+ struct watchdog_list_item *wdg =
|
||||
+ calloc(1, sizeof(struct watchdog_list_item));
|
||||
+ int len;
|
||||
+ struct link_list_item *tmp_list = NULL;
|
||||
+
|
||||
+ wdg->dev = statbuf.st_rdev;
|
||||
+ wdg->dev_node = strdup(entry_name);
|
||||
+ wdg->next = watchdog_list;
|
||||
+ watchdog_list = wdg;
|
||||
+ watchdog_list_items++;
|
||||
+
|
||||
+ if (wdfd >= 0) {
|
||||
+ struct watchdog_info ident;
|
||||
+
|
||||
+ ident.identity[0] = '\0';
|
||||
+ ioctl(wdfd, WDIOC_GETSUPPORT, &ident);
|
||||
+ watchdog_close_fd(wdfd, entry_name, true);
|
||||
+ if (ident.identity[0]) {
|
||||
+ wdg->dev_ident = strdup((char *) ident.identity);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ snprintf(entry_name, sizeof(entry_name),
|
||||
+ SYS_CHAR_DEV_DIR "/%d:%d/device/driver",
|
||||
+ major(wdg->dev), minor(wdg->dev));
|
||||
+ len = readlink(entry_name, buf, sizeof(buf) - 1);
|
||||
+ if (len > 0) {
|
||||
+ buf[len] = '\0';
|
||||
+ wdg->dev_driver = strdup(basename(buf));
|
||||
+ } else if ((wdg->dev_ident) &&
|
||||
+ (strcmp(wdg->dev_ident,
|
||||
+ "Software Watchdog") == 0)) {
|
||||
+ wdg->dev_driver = strdup("softdog");
|
||||
+ }
|
||||
+
|
||||
+ /* create dupes if we have memorized links
|
||||
+ * to this node
|
||||
+ */
|
||||
+ for (tmp_list = link_list; tmp_list;
|
||||
+ tmp_list = tmp_list->next) {
|
||||
+ if (!strcmp(tmp_list->dev_node,
|
||||
+ wdg->dev_node)) {
|
||||
+ struct watchdog_list_item *dupe_wdg =
|
||||
+ calloc(1, sizeof(struct watchdog_list_item));
|
||||
+
|
||||
+ /* as long as we never purge watchdog_list
|
||||
+ * there is no need to dupe strings
|
||||
+ */
|
||||
+ *dupe_wdg = *wdg;
|
||||
+ dupe_wdg->dev_node = strdup(tmp_list->link_name);
|
||||
+ dupe_wdg->next = watchdog_list;
|
||||
+ watchdog_list = dupe_wdg;
|
||||
+ watchdog_list_items++;
|
||||
+ }
|
||||
+ /* for performance reasons we could remove
|
||||
+ * the link_list entry
|
||||
+ */
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- closedir(dp);
|
||||
- }
|
||||
+ closedir(dp);
|
||||
+ }
|
||||
|
||||
- /* cleanup link list */
|
||||
- while (link_list) {
|
||||
- struct link_list_item *tmp_list = link_list;
|
||||
+ /* cleanup link list */
|
||||
+ while (link_list) {
|
||||
+ struct link_list_item *tmp_list = link_list;
|
||||
|
||||
- link_list = link_list->next;
|
||||
- free(tmp_list->dev_node);
|
||||
- free(tmp_list->link_name);
|
||||
- free(tmp_list);
|
||||
- }
|
||||
+ link_list = link_list->next;
|
||||
+ free(tmp_list->dev_node);
|
||||
+ free(tmp_list->link_name);
|
||||
+ free(tmp_list);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+watchdog_checkbusy()
|
||||
+{
|
||||
+ DIR *dproc;
|
||||
+ struct dirent *entry;
|
||||
+
|
||||
+ dproc = opendir("/proc");
|
||||
+ if (!dproc) {
|
||||
+ /* no proc directory to search through */
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ while ((entry = readdir(dproc)) != NULL) {
|
||||
+ pid_t local_pid;
|
||||
+ char *leftover;
|
||||
+ DIR *dpid;
|
||||
+ char procpath[NAME_MAX+10] = { 0 };
|
||||
+
|
||||
+ if (entry->d_name[0] == '.') {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ local_pid = strtol(entry->d_name, &leftover, 10);
|
||||
+ if (leftover[0] != '\0')
|
||||
+ continue;
|
||||
+
|
||||
+ snprintf(procpath, sizeof(procpath), "/proc/%s/fd", entry->d_name);
|
||||
+ dpid = opendir(procpath);
|
||||
+ if (!dpid) {
|
||||
+ /* silently continue - might be just a race */
|
||||
+ continue;
|
||||
+ }
|
||||
+ while ((entry = readdir(dpid)) != NULL) {
|
||||
+ struct watchdog_list_item *wdg;
|
||||
+ char entry_name[sizeof(procpath)+NAME_MAX+1] = { 0 };
|
||||
+ char buf[NAME_MAX+1] = { 0 };
|
||||
+ int len;
|
||||
+
|
||||
+ if (entry->d_type != DT_LNK) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ snprintf(entry_name, sizeof(entry_name),
|
||||
+ "%s/%s", procpath, entry->d_name);
|
||||
+ len = readlink(entry_name, buf, sizeof(buf) - 1);
|
||||
+ if (len < 1) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ buf[len] = '\0';
|
||||
+ for (wdg = watchdog_list; wdg != NULL; wdg = wdg->next) {
|
||||
+ if (!strcmp(buf, wdg->dev_node)) {
|
||||
+ char name[16];
|
||||
+ FILE *file;
|
||||
+
|
||||
+ wdg->busy_pid = local_pid;
|
||||
+ snprintf(procpath, sizeof(procpath), "/proc/%d/status", local_pid);
|
||||
+ file = fopen(procpath, "r");
|
||||
+ if (file) {
|
||||
+ if (fscanf(file, "Name:\t%15[a-zA-Z0-9 _-]", name) == 1) {
|
||||
+ wdg->busy_name = strdup(name);
|
||||
+ }
|
||||
+ fclose(file);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ closedir(dpid);
|
||||
+ }
|
||||
+
|
||||
+ closedir(dproc);
|
||||
+
|
||||
+ return;
|
||||
}
|
||||
|
||||
int watchdog_info(void)
|
||||
@@ -462,13 +560,23 @@ int watchdog_info(void)
|
||||
int wdg_cnt = 0;
|
||||
|
||||
watchdog_populate_list();
|
||||
+ watchdog_checkbusy();
|
||||
printf("\nDiscovered %d watchdog devices:\n", watchdog_list_items);
|
||||
for (wdg = watchdog_list; wdg != NULL; wdg = wdg->next) {
|
||||
wdg_cnt++;
|
||||
- printf("\n[%d] %s\nIdentity: %s\nDriver: %s\n",
|
||||
+ if (wdg->busy_pid) {
|
||||
+ printf("\n[%d] %s\nIdentity: Busy: PID %d (%s)\nDriver: %s\n",
|
||||
wdg_cnt, wdg->dev_node,
|
||||
- wdg->dev_ident?wdg->dev_ident:"Error: Check if hogged by e.g. sbd-daemon!",
|
||||
+ wdg->busy_pid,
|
||||
+ wdg->busy_name?wdg->busy_name:"<unknown>",
|
||||
wdg->dev_driver?wdg->dev_driver:"<unknown>");
|
||||
+ } else {
|
||||
+ printf("\n[%d] %s\nIdentity: %s\nDriver: %s\n",
|
||||
+ wdg_cnt, wdg->dev_node,
|
||||
+ wdg->dev_ident?wdg->dev_ident:
|
||||
+ "Error: device hogged via alias major/minor?",
|
||||
+ wdg->dev_driver?wdg->dev_driver:"<unknown>");
|
||||
+ }
|
||||
if ((wdg->dev_driver) && (strcmp(wdg->dev_driver, "softdog") == 0)) {
|
||||
printf("CAUTION: Not recommended for use with sbd.\n");
|
||||
}
|
||||
@@ -512,6 +620,7 @@ int watchdog_test(void)
|
||||
watchdogdev, (int) timeout_watchdog);
|
||||
if ((watchdog_init() < 0) || (watchdog_init_interval() < 0)) {
|
||||
printf("Failed to initialize watchdog!!!\n");
|
||||
+ watchdog_info();
|
||||
return -1;
|
||||
}
|
||||
printf("\n");
|
||||
--
|
||||
1.8.3.1
|
||||
|
@ -0,0 +1,306 @@
|
||||
#
|
||||
# spec file for package sbd
|
||||
#
|
||||
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2013 Lars Marowsky-Bree
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
# upon. The license for this file, and modifications and additions to the
|
||||
# file, is the same license as for the pristine package itself (unless the
|
||||
# license for the pristine package is not an Open Source License, in which
|
||||
# case the license is the MIT License). An "Open Source License" is a
|
||||
# license that conforms to the Open Source Definition (Version 1.9)
|
||||
# published by the Open Source Initiative.
|
||||
|
||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||
#
|
||||
%global longcommit 6bb085f5704dd4c3841c79504f2aed2228e6d76a
|
||||
%global shortcommit %(echo %{longcommit}|cut -c1-8)
|
||||
%global modified %(echo %{longcommit}-|cut -f2 -d-)
|
||||
%global github_owner Clusterlabs
|
||||
%global buildnum 3
|
||||
|
||||
%ifarch s390x s390
|
||||
# minimum timeout on LPAR diag288 watchdog is 15s
|
||||
%global watchdog_timeout_default 15
|
||||
%else
|
||||
%global watchdog_timeout_default 5
|
||||
%endif
|
||||
|
||||
# Be careful with sync_resource_startup_default
|
||||
# being enabled. This configuration has
|
||||
# to be in sync with configuration in pacemaker
|
||||
# where it is called sbd_sync - assure by e.g.
|
||||
# mutual rpm dependencies.
|
||||
%bcond_without sync_resource_startup_default
|
||||
# Syncing enabled per default will lead to
|
||||
# syncing enabled on upgrade without adaption
|
||||
# of the config.
|
||||
# Setting can still be overruled via sysconfig.
|
||||
# The setting in the config-template packaged
|
||||
# will follow the default if below is is left
|
||||
# empty. But it is possible to have the setting
|
||||
# in the config-template deviate from the default
|
||||
# by setting below to an explicit 'yes' or 'no'.
|
||||
%global sync_resource_startup_sysconfig ""
|
||||
|
||||
Name: sbd
|
||||
Summary: Storage-based death
|
||||
License: GPLv2+
|
||||
Version: 1.5.1
|
||||
Release: %{buildnum}%{?dist}
|
||||
Url: https://github.com/%{github_owner}/%{name}
|
||||
Source0: https://github.com/%{github_owner}/%{name}/archive/%{longcommit}/%{name}-%{longcommit}.tar.gz
|
||||
Patch0: 0001-Fix-Be-a-bit-more-descriptive-on-issues-opening-watc.patch
|
||||
BuildRequires: autoconf
|
||||
BuildRequires: automake
|
||||
BuildRequires: libuuid-devel
|
||||
BuildRequires: glib2-devel
|
||||
BuildRequires: libaio-devel
|
||||
BuildRequires: corosync-devel
|
||||
BuildRequires: pacemaker-libs-devel
|
||||
BuildRequires: libtool
|
||||
BuildRequires: libuuid-devel
|
||||
BuildRequires: libxml2-devel
|
||||
BuildRequires: pkgconfig
|
||||
BuildRequires: make
|
||||
BuildRequires: systemd
|
||||
Conflicts: fence-agents-sbd < 4.5.0
|
||||
Conflicts: pacemaker-libs < 2.1.0-5
|
||||
|
||||
%if 0%{?rhel}
|
||||
ExclusiveArch: i686 x86_64 s390x aarch64 ppc64le
|
||||
%endif
|
||||
|
||||
%if %{defined systemd_requires}
|
||||
%systemd_requires
|
||||
%endif
|
||||
|
||||
%description
|
||||
|
||||
This package contains the storage-based death functionality.
|
||||
|
||||
Available rpmbuild rebuild options:
|
||||
--with(out) : sync_resource_startup_default
|
||||
|
||||
%package tests
|
||||
Summary: Storage-based death environment for regression tests
|
||||
License: GPLv2+
|
||||
|
||||
%description tests
|
||||
This package provides an environment + testscripts for
|
||||
regression-testing sbd.
|
||||
|
||||
###########################################################
|
||||
|
||||
%prep
|
||||
%autosetup -n %{name}-%{longcommit} -p1
|
||||
|
||||
###########################################################
|
||||
|
||||
%build
|
||||
./autogen.sh
|
||||
export CFLAGS="$RPM_OPT_FLAGS -Wall -Werror"
|
||||
%configure --with-watchdog-timeout-default=%{watchdog_timeout_default} \
|
||||
--with-sync-resource-startup-default=%{?with_sync_resource_startup_default:yes}%{!?with_sync_resource_startup_default:no} \
|
||||
--with-sync-resource-startup-sysconfig=%{sync_resource_startup_sysconfig} \
|
||||
--runstatedir=%{_rundir}
|
||||
make %{?_smp_mflags}
|
||||
|
||||
###########################################################
|
||||
|
||||
%install
|
||||
|
||||
make DESTDIR=$RPM_BUILD_ROOT LIBDIR=%{_libdir} install
|
||||
rm -rf ${RPM_BUILD_ROOT}%{_libdir}/stonith
|
||||
|
||||
install -D -m 0755 tests/regressions.sh $RPM_BUILD_ROOT/usr/share/sbd/regressions.sh
|
||||
%if %{defined _unitdir}
|
||||
install -D -m 0644 src/sbd.service $RPM_BUILD_ROOT/%{_unitdir}/sbd.service
|
||||
install -D -m 0644 src/sbd_remote.service $RPM_BUILD_ROOT/%{_unitdir}/sbd_remote.service
|
||||
%endif
|
||||
|
||||
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig
|
||||
install -m 644 src/sbd.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/sbd
|
||||
|
||||
# Don't package static libs
|
||||
find %{buildroot} -name '*.a' -type f -print0 | xargs -0 rm -f
|
||||
find %{buildroot} -name '*.la' -type f -print0 | xargs -0 rm -f
|
||||
|
||||
###########################################################
|
||||
|
||||
%if %{defined _unitdir}
|
||||
%post
|
||||
%systemd_post sbd.service
|
||||
%systemd_post sbd_remote.service
|
||||
if [ $1 -ne 1 ] ; then
|
||||
if systemctl --quiet is-enabled sbd.service 2>/dev/null
|
||||
then
|
||||
systemctl --quiet reenable sbd.service 2>/dev/null || :
|
||||
fi
|
||||
if systemctl --quiet is-enabled sbd_remote.service 2>/dev/null
|
||||
then
|
||||
systemctl --quiet reenable sbd_remote.service 2>/dev/null || :
|
||||
fi
|
||||
fi
|
||||
|
||||
%preun
|
||||
%systemd_preun sbd.service
|
||||
%systemd_preun sbd_remote.service
|
||||
|
||||
%postun
|
||||
%systemd_postun sbd.service
|
||||
%systemd_postun sbd_remote.service
|
||||
%endif
|
||||
|
||||
%files
|
||||
###########################################################
|
||||
%defattr(-,root,root)
|
||||
%config(noreplace) %{_sysconfdir}/sysconfig/sbd
|
||||
%{_sbindir}/sbd
|
||||
%{_datadir}/sbd
|
||||
%{_datadir}/pkgconfig/sbd.pc
|
||||
%exclude %{_datadir}/sbd/regressions.sh
|
||||
%doc %{_mandir}/man8/sbd*
|
||||
%if %{defined _unitdir}
|
||||
%{_unitdir}/sbd.service
|
||||
%{_unitdir}/sbd_remote.service
|
||||
%endif
|
||||
%doc COPYING
|
||||
|
||||
%files tests
|
||||
###########################################################
|
||||
%defattr(-,root,root)
|
||||
%dir %{_datadir}/sbd
|
||||
%{_datadir}/sbd/regressions.sh
|
||||
%{_libdir}/libsbdtestbed*
|
||||
|
||||
%changelog
|
||||
* Mon Jul 18 2022 Klaus Wenninger <kwenning@redhat.com> - 1.5.1-3
|
||||
- Be a bit more descriptive on issues opening watchdog-devices
|
||||
|
||||
Resolves: rhbz#2108122
|
||||
|
||||
* Mon Dec 6 2021 Klaus Wenninger <kwenning@redhat.com> - 1.5.1-2
|
||||
- obviously autoconf is defining runstatedir - but with a
|
||||
wrong default - directly hand it over to configure
|
||||
and skip --with-runstatedir implemented in configure.ac
|
||||
for older versions of autoconf
|
||||
|
||||
Resolves: rhbz#2011707
|
||||
|
||||
* Wed Dec 1 2021 Klaus Wenninger <kwenning@redhat.com> - 1.5.1-1
|
||||
- rebase to upstream v1.5.1
|
||||
|
||||
Resolves: rhbz#2013261
|
||||
|
||||
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 1.5.0-2.1
|
||||
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
|
||||
Related: rhbz#1991688
|
||||
|
||||
* Fri Jul 9 2021 Klaus Wenninger <kwenning@redhat.com> - 1.5.0-2
|
||||
- properly conflict with pacemaker not providing sync-default we need
|
||||
Resolves: rhbz#1979961
|
||||
Resolves: rhbz#1979573
|
||||
|
||||
* Tue Jul 6 2021 Klaus Wenninger <kwenning@redhat.com> - 1.5.0-1
|
||||
- sync with fedora sbd-1.5.0-1
|
||||
Resolves: rhbz#1979961
|
||||
Resolves: rhbz#1979573
|
||||
|
||||
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 1.4.2-3.2
|
||||
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
|
||||
|
||||
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.2-3.1
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||
|
||||
* Mon Dec 7 2020 Klaus Wenninger <kwenning@redhat.com> - 1.4.2-3
|
||||
- this time really remove dist.depcheck from gating
|
||||
|
||||
* Mon Dec 7 2020 Klaus Wenninger <kwenning@redhat.com> - 1.4.2-2
|
||||
- remove deprecated dist.depcheck from gating
|
||||
- add tier0 to push_stable to have rawhide gated as well
|
||||
|
||||
* Mon Dec 7 2020 Klaus Wenninger <kwenning@redhat.com> - 1.4.2-1
|
||||
- Rebase to upstream v1.4.2
|
||||
- Conflict with pacemaker that doesn't have pacemakerd-api
|
||||
- Set default to not do startup/shutdown-syncing via pacemakerd-api
|
||||
but enable in template-config
|
||||
|
||||
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.1-7.1
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
|
||||
|
||||
* Thu May 14 2020 Klaus Wenninger <kwenning@redhat.com> - 1.4.1-7
|
||||
- Rebuild against libqb2.0 (f33-build-side-23348)
|
||||
|
||||
* Wed Mar 11 2020 Klaus Wenninger <kwenning@redhat.com> - 1.4.1-6
|
||||
- Rebuild because tagging the build failed
|
||||
|
||||
* Thu Mar 5 2020 Klaus Wenninger <kwenning@redhat.com> - 1.4.1-5
|
||||
- Rebase to upstream v1.4.1
|
||||
- Make coverity happy with parameter passing in regressions.sh
|
||||
- Add auto generated environment section to man-page
|
||||
- Overhaul setting scheduler policy/priority
|
||||
- Enable Fedora CI Gating
|
||||
|
||||
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||
|
||||
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||
|
||||
* Fri Feb 1 2019 Klaus Wenninger <kwenning@redhat.com> - 1.4.0-1
|
||||
- Rebase to upstream v1.4.0
|
||||
- Fail earlier on invalid servants (solves GCC9 build issue as well)
|
||||
|
||||
* Wed Nov 21 2018 Klaus Wenninger <kwenning@redhat.com> - 1.3.1-1.git4927571
|
||||
- Rebased to commit 4927571f8e9b00db8242654b1329dfbd71dcfe99
|
||||
- Removed disabling of shared-disk-support
|
||||
Resolves rhbz#1606301
|
||||
|
||||
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.1-4.3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||
|
||||
* Sun Mar 18 2018 Iryna Shcherbina <ishcherb@redhat.com> - 1.2.1-4.2
|
||||
- Update Python 2 dependency declarations to new packaging standards
|
||||
(See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)
|
||||
|
||||
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.1-4.1
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
|
||||
|
||||
* Tue Jan 30 2018 Merlin Mathesius <mmathesi@redhat.com> - 1.2.1-4
|
||||
- Patch to use correct C inline function semantics to fix FTBFS (BZ#1424417)
|
||||
Cleanup spec file conditionals
|
||||
|
||||
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.1-3.4
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
|
||||
|
||||
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.1-3.3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
|
||||
|
||||
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.1-3.2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
|
||||
|
||||
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.2.1-3.1
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
|
||||
|
||||
* Tue Jan 19 2016 Jan Pokorný <jpokorny+rpm-sbd@redhat.com> - 1.2.1-3
|
||||
- Rebuilt for libpe_status soname bump arising from Pacemaker 1.1.14
|
||||
|
||||
* Thu Jul 02 2015 Ralf Corsépius <corsepiu@fedoraproject.org> - 1.2.1-2
|
||||
- Add dist-tag (RHBZ #1237187).
|
||||
|
||||
* Fri Jun 19 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.1-1.1
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
|
||||
|
||||
* Thu Oct 30 2014 <andrew@beekhof.net> - 1.2.1-1
|
||||
- Correctly enable /proc/pid validation for sbd_lock_running()
|
||||
- Improved integration with the el7 environment
|
||||
|
||||
* Fri Aug 29 2014 <andrew@beekhof.net> - 1.2.1-0.2.8f912945.git
|
||||
- Remove some additional SUSE-isms
|
||||
|
||||
* Fri Aug 29 2014 <andrew@beekhof.net> - 1.2.1-0.1.8f912945.git
|
||||
- Prepare for package review
|
||||
Resolves: rhbz#1134245
|
Loading…
Reference in new issue