|
|
b6fb8c |
From fad2b3dc8c44ba1222508ee78b5f161994efe638 Mon Sep 17 00:00:00 2001
|
|
|
b6fb8c |
From: David Teigland <teigland@redhat.com>
|
|
|
b6fb8c |
Date: Tue, 9 Nov 2021 11:54:48 -0600
|
|
|
38b7b2 |
Subject: [PATCH 08/54] filter-sysfs: support old kernels without sys/dev/block
|
|
|
b6fb8c |
|
|
|
b6fb8c |
rhel5 for example doesn't have /sys/dev/block
|
|
|
b6fb8c |
---
|
|
|
b6fb8c |
lib/filters/filter-sysfs.c | 28 ++++++++++++++++++++++++++++
|
|
|
b6fb8c |
1 file changed, 28 insertions(+)
|
|
|
b6fb8c |
|
|
|
b6fb8c |
diff --git a/lib/filters/filter-sysfs.c b/lib/filters/filter-sysfs.c
|
|
|
b6fb8c |
index 672211057..d8de7940b 100644
|
|
|
b6fb8c |
--- a/lib/filters/filter-sysfs.c
|
|
|
b6fb8c |
+++ b/lib/filters/filter-sysfs.c
|
|
|
b6fb8c |
@@ -15,6 +15,8 @@
|
|
|
b6fb8c |
#include "lib/misc/lib.h"
|
|
|
b6fb8c |
#include "lib/filters/filter.h"
|
|
|
b6fb8c |
|
|
|
b6fb8c |
+static int _sys_dev_block_found;
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
#ifdef __linux__
|
|
|
b6fb8c |
|
|
|
b6fb8c |
static int _accept_p(struct cmd_context *cmd, struct dev_filter *f, struct device *dev, const char *use_filter_name)
|
|
|
b6fb8c |
@@ -23,6 +25,9 @@ static int _accept_p(struct cmd_context *cmd, struct dev_filter *f, struct devic
|
|
|
b6fb8c |
const char *sysfs_dir;
|
|
|
b6fb8c |
struct stat info;
|
|
|
b6fb8c |
|
|
|
b6fb8c |
+ if (!_sys_dev_block_found)
|
|
|
b6fb8c |
+ return 1;
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
dev->filtered_flags &= ~DEV_FILTERED_SYSFS;
|
|
|
b6fb8c |
|
|
|
b6fb8c |
/*
|
|
|
b6fb8c |
@@ -57,6 +62,26 @@ static void _destroy(struct dev_filter *f)
|
|
|
b6fb8c |
free(f);
|
|
|
b6fb8c |
}
|
|
|
b6fb8c |
|
|
|
b6fb8c |
+static void _check_sys_dev_block(void)
|
|
|
b6fb8c |
+{
|
|
|
b6fb8c |
+ char path[PATH_MAX];
|
|
|
b6fb8c |
+ const char *sysfs_dir;
|
|
|
b6fb8c |
+ struct stat info;
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+ sysfs_dir = dm_sysfs_dir();
|
|
|
b6fb8c |
+ if (sysfs_dir && *sysfs_dir) {
|
|
|
b6fb8c |
+ if (dm_snprintf(path, sizeof(path), "%sdev/block", sysfs_dir) < 0)
|
|
|
b6fb8c |
+ return;
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
+ if (lstat(path, &info)) {
|
|
|
b6fb8c |
+ log_debug("filter-sysfs disabled: /sys/dev/block not found");
|
|
|
b6fb8c |
+ _sys_dev_block_found = 0;
|
|
|
b6fb8c |
+ } else {
|
|
|
b6fb8c |
+ _sys_dev_block_found = 1;
|
|
|
b6fb8c |
+ }
|
|
|
b6fb8c |
+ }
|
|
|
b6fb8c |
+}
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
struct dev_filter *sysfs_filter_create(void)
|
|
|
b6fb8c |
{
|
|
|
b6fb8c |
const char *sysfs_dir = dm_sysfs_dir();
|
|
|
b6fb8c |
@@ -67,6 +92,9 @@ struct dev_filter *sysfs_filter_create(void)
|
|
|
b6fb8c |
return NULL;
|
|
|
b6fb8c |
}
|
|
|
b6fb8c |
|
|
|
b6fb8c |
+ /* support old kernels that don't have this */
|
|
|
b6fb8c |
+ _check_sys_dev_block();
|
|
|
b6fb8c |
+
|
|
|
b6fb8c |
if (!(f = zalloc(sizeof(*f))))
|
|
|
b6fb8c |
goto_bad;
|
|
|
b6fb8c |
|
|
|
b6fb8c |
--
|
|
|
38b7b2 |
2.34.3
|
|
|
b6fb8c |
|