Accepting request 494798 from home:zlliu:branches:Base:System
fixed bsc#1038655 OBS-URL: https://build.opensuse.org/request/show/494798 OBS-URL: https://build.opensuse.org/package/show/Base:System/ledmon?expand=0&rev=20
This commit is contained in:
parent
5cc188bece
commit
dd2612f509
@ -0,0 +1,75 @@
|
||||
From f0e0aac35deb8052f93256488e933409bdbfdc21 Mon Sep 17 00:00:00 2001
|
||||
From: Zhilong Liu <zlliu@suse.com>
|
||||
Date: Fri, 12 May 2017 16:13:04 +0800
|
||||
Subject: [PATCH] Don't rely on searching for "/block" in sysfs path for
|
||||
detecting partitions
|
||||
|
||||
It is simpler and more reliable to check for a "partition" file in the device's
|
||||
directory (supported since kernel 2.6.28). The previous approach would fail for
|
||||
nvme devices because their device path looks like this:
|
||||
/sys/devices/pci0000:00/0000:00:0c.0/nvme/nvme0/nvme0n1
|
||||
|
||||
Fixes: b30173ec8c05 ("* fix off-normal-failure block dev status loop * remove
|
||||
unused raid->slave_list member * support md raid on block device partitions")
|
||||
|
||||
Signed-off-by: Zhilong Liu <zlliu@suse.com>
|
||||
---
|
||||
src/slave.c | 27 ++++++++++++++-------------
|
||||
1 file changed, 14 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/src/slave.c b/src/slave.c
|
||||
index 9843ffd..436ed4a 100644
|
||||
--- a/src/slave.c
|
||||
+++ b/src/slave.c
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
+#include <stdio.h>
|
||||
+#include <sys/stat.h>
|
||||
|
||||
#if _HAVE_DMALLOC_H
|
||||
#include <dmalloc.h>
|
||||
@@ -100,27 +102,26 @@ static struct block_device *_get_block(const char *path, void *block_list)
|
||||
{
|
||||
char temp[PATH_MAX];
|
||||
char link[PATH_MAX];
|
||||
- char *ptr;
|
||||
- struct block_device *device = NULL;
|
||||
|
||||
str_cpy(temp, path, PATH_MAX);
|
||||
str_cat(temp, "/block", PATH_MAX);
|
||||
|
||||
- if (realpath(temp, link)) {
|
||||
- ptr = strrchr(link, '/');
|
||||
- if (ptr && link < ptr - strlen("/block")) {
|
||||
- /* translate partition to master block dev */
|
||||
- if(strncmp(
|
||||
- ptr - strlen("/block"),
|
||||
- "/block",
|
||||
- strlen("/block"))) {
|
||||
+ if (!realpath(temp, link))
|
||||
+ return NULL;
|
||||
|
||||
+ /* translate partition to master block dev */
|
||||
+ if (snprintf(temp, PATH_MAX, "%s/partition", link) > 0) {
|
||||
+ struct stat sb;
|
||||
+ char *ptr;
|
||||
+
|
||||
+ if (stat(temp, &sb) == 0 && S_ISREG(sb.st_mode)) {
|
||||
+ ptr = strrchr(link, '/');
|
||||
+ if (ptr)
|
||||
*ptr = '\0';
|
||||
- }
|
||||
- device = list_first_that(block_list, _compare, link);
|
||||
}
|
||||
}
|
||||
- return device;
|
||||
+
|
||||
+ return list_first_that(block_list, _compare, link);
|
||||
}
|
||||
|
||||
/**
|
||||
--
|
||||
2.6.6
|
||||
|
@ -1,3 +1,11 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri May 12 08:33:13 UTC 2017 - zlliu@suse.com
|
||||
|
||||
- 0001-Don-t-rely-on-searching-for-block-in-sysfs-path-for-.patch
|
||||
Fixed bsc#1038655.
|
||||
upstream link of this patch:
|
||||
https://sourceforge.net/p/ledmon/code/ci/868a01
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Mar 15 09:06:04 UTC 2017 - zlliu@suse.com
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package ledmon
|
||||
#
|
||||
# Copyright (c) 2017 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -25,6 +25,7 @@ Group: Hardware/Other
|
||||
Url: http://sourceforge.net/projects/ledmon/
|
||||
Source0: http://sourceforge.net/projects/ledmon/files/ledmon-%{version}/%{name}-%{version}.tar.gz
|
||||
Patch0: Makefile-error-dependency.patch
|
||||
Patch1: 0001-Don-t-rely-on-searching-for-block-in-sysfs-path-for-.patch
|
||||
BuildRequires: libsgutils-devel
|
||||
Provides: sgpio:/sbin/ledmon
|
||||
Provides: sgpio:/{%{_bindir}}/ledctl
|
||||
@ -38,6 +39,7 @@ solutions.
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0
|
||||
%patch1 -p1
|
||||
|
||||
%build
|
||||
make %{?_smp_mflags} CXFLAGS="%{optflags} -lsgutils2"
|
||||
|
Loading…
Reference in New Issue
Block a user