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