Initialize for dmraid

This commit is contained in:
zyppe 2024-02-07 22:43:05 +08:00
commit 45406a86f6
18 changed files with 7092 additions and 0 deletions

1
.dmraid.metadata Normal file
View file

@ -0,0 +1 @@
e7a57791326fe85f99297951f11a88874ab81ea94da1c63f8bd8e64ad4e4815e dmraid-1.0.0.rc16.tar.bz2

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
dmraid-1.0.0.rc16.tar.bz2

View file

@ -0,0 +1,30 @@
From 3e073f5ac0b1d8d930615cd3fbb1401b56ceb848 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Thu, 26 Oct 2017 14:31:04 +0200
Subject: [PATCH] remove partitions with O_RDONLY
It's not necessary to use O_RDWR to use BLKPG_DEL_PARTITION.
It's actually harmful, because closing the device will cause
an IN_CLOSE_WRITE inotify event, which will trigger a BLKRRPART
from systemd, which will reinstate all partitions just deleted.
---
lib/device/partition.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/device/partition.c b/lib/device/partition.c
index 99e92f6a66cd..bcc8de819eb4 100644
--- a/1.0.0.rc16/lib/device/partition.c
+++ b/1.0.0.rc16/lib/device/partition.c
@@ -22,8 +22,7 @@ _remove_subset_partitions(struct lib_context *lc, struct raid_set *rs)
};
list_for_each_entry(rd, &rs->devs, devs) {
- int fd = open(rd->di->path, O_RDWR);
-
+ int fd = open(rd->di->path, O_RDONLY);
if (fd < 0)
LOG_ERR(lc, 0, "opening %s: %s\n", rd->di->path,
strerror(errno));
--
2.14.2

11
README.SUSE Normal file
View file

@ -0,0 +1,11 @@
Note about some pdc card:
Model: "Promise FastTrak100 TX2"
Vendor: pci 0x105a "Promise Technology, Inc."
Device: pci 0x6268 "PDC20270 (FastTrak100 LP/TX2/TX4)"
SubVendor: pci 0x105a "Promise Technology, Inc."
SubDevice: pci 0x4d68 "FastTrak100 TX2"
This card detects only devices to 128 GB. If you are running dmraid
with this card you will only be able to use the space up to this limit.

31
ddf-erase Normal file
View file

@ -0,0 +1,31 @@
Allow dmraid to erase ddf metadata properly.
2 things go wrong:
1/ when seeking to the anchor, it seeks to far by a factor of 512
2/ when writing to the anchor, it writes 0 bytes, not 512.
Signed-off-by: NeilBrown <neilb@suse.de>
References: bnc#712671
---
lib/format/ddf/ddf1.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- 1.0.0.rc16.orig/lib/format/ddf/ddf1.c
+++ 1.0.0.rc16/lib/format/ddf/ddf1.c
@@ -536,7 +536,7 @@ try_to_find_ddf1(struct lib_context *lc,
ddf1_sboffset) || !is_ddf1(lc, di, ddf1))
goto bad;
- ddf1->anchor_offset = ddf1_sboffset;
+ ddf1->anchor_offset = ddf1_sboffset / 512;
/* Convert endianness */
ddf1->in_cpu_format = 0;
@@ -967,6 +967,7 @@ setup_rd(struct lib_context *lc, struct
ma[i].offset = ddf1->primary->primary_table_lba;
ma->offset = ddf1->anchor_offset;
+ ma->size = 512;
(ma++)->area = &ddf1->anchor;
(ma++)->area = ddf1->primary;

View file

@ -0,0 +1,100 @@
---
lib/activate/devmapper.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
--- 1.0.0.rc16.orig/lib/activate/devmapper.c
+++ 1.0.0.rc16/lib/activate/devmapper.c
@@ -207,6 +207,82 @@ run_task(struct lib_context *lc, struct
return ret;
}
+int get_edd_value(unsigned long *value, const char *path)
+{
+ FILE *file;
+ unsigned long v;
+
+ file = fopen(path, "r");
+ if (file == NULL)
+ return 0;
+
+ if (fscanf(file, "%lu", &v) == 0) {
+ fclose(file);
+ return 0;
+ }
+ fclose(file);
+
+ *value = v;
+ return 1;
+}
+
+#define EDD_PREFIX "/sys/firmware/edd/int13_dev80/"
+
+int getgeo_edd(unsigned long *cylinders,
+ unsigned long *heads,
+ unsigned long *sectors)
+{
+ int res;
+ unsigned long c, h, s;
+
+ res = get_edd_value(&c, EDD_PREFIX "legacy_max_cylinder") &&
+ get_edd_value(&h, EDD_PREFIX "legacy_max_head") &&
+ get_edd_value(&s, EDD_PREFIX "legacy_sectors_per_track");
+
+ if (!res)
+ return 0;
+
+ *cylinders = c;
+ *heads = h;
+ *sectors = s;
+
+ return 1;
+}
+
+/* Set the geometry of the device */
+int set_geometry(struct lib_context *lc, struct raid_set *rs)
+{
+ int ret;
+ struct dm_task *dmt;
+ unsigned long c, h, sec, st;
+ char cyl[10], heads[10], sectors[10], start[10];
+
+ st = 0;
+ if (!getgeo_edd(&c, &h, &sec)) {
+ /* default */
+ c = 16383;
+ h = 16;
+ sec = 63;
+ }
+
+ snprintf(cyl, 10, "%lu", c);
+ snprintf(heads, 10, "%lu", h);
+ snprintf(sectors, 10, "%lu", sec);
+ snprintf(start, 10, "%lu", st);
+
+ _init_dm();
+ ret = (dmt = dm_task_create(DM_DEVICE_SET_GEOMETRY)) &&
+ dm_task_set_name(dmt, rs->name) &&
+ dm_task_set_geometry(dmt, cyl, heads, sectors, start);
+
+ if (ret)
+ ret = dm_task_run(dmt);
+
+ _exit_dm(dmt);
+
+ return ret;
+}
+
/* Create a mapped device. */
int
dm_create(struct lib_context *lc, struct raid_set *rs, char *table, char *name)
@@ -216,6 +292,10 @@ dm_create(struct lib_context *lc, struct
/* Create <dev_name> */
ret = run_task(lc, rs, table, DM_DEVICE_CREATE, name);
+ /* Set geometry */
+ if (ret)
+ set_geometry(lc, rs);
+
/*
* In case device creation failed, check if target
* isn't registered with the device-mapper core

File diff suppressed because it is too large Load diff

15
dmraid-activation.service Normal file
View file

@ -0,0 +1,15 @@
[Unit]
Description=Activation of DM RAID sets
DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-udev-settle.service
Before=lvm2-activation-early.service cryptsetup.target local-fs.target shutdown.target
Wants=systemd-udev-settle.service
[Service]
EnvironmentFile=-/etc/sysconfig/dmraid
ExecStart=/sbin/dmraid -ay -p $DMRAID_START_OPTIONS
Type=oneshot
[Install]
WantedBy=sysinit.target

65
dmraid-destdir.patch Normal file
View file

@ -0,0 +1,65 @@
--- 1.0.0.rc16.orig/include/Makefile.in
+++ 1.0.0.rc16/include/Makefile.in
@@ -17,8 +17,8 @@ include $(top_srcdir)/make.tmpl
install_dmraid_headers: $(HEADERS)
@echo "Installing $(HEADERS) in $(includedir)/dmraid"
- mkdir -p $(includedir)/dmraid
- $(INSTALL) $(STRIP) $(HEADERS) $(includedir)/dmraid
+ mkdir -p $(DESTDIR)$(includedir)/dmraid
+ $(INSTALL) $(STRIP) $(HEADERS) $(DESTDIR)$(includedir)/dmraid
install: install_dmraid_headers
--- 1.0.0.rc16.orig/lib/Makefile.in
+++ 1.0.0.rc16/lib/Makefile.in
@@ -78,16 +78,16 @@ $(LIB_EVENTS_SHARED):
install_dmraid_libs: $(INSTALL_TARGETS)
@echo "Installing $(INSTALL_TARGETS) in $(libdir)"; \
- mkdir -p $(libdir); \
+ mkdir -p $(DESTDIR)$(libdir); \
for f in $(INSTALL_TARGETS); \
do \
n=$$(basename $${f}) ; \
if [[ "$$n" =~ .so$$ && ! "$$n" =~ libdmraid-events-.* ]]; then \
$(INSTALL) -m 555 $(STRIP) \
- $$f $(libdir)/$${n}.@DMRAID_LIB_VERSION@; \
- $(LN_S) -f $${n}.@DMRAID_LIB_VERSION@ $(libdir)/$${n}; \
+ $$f $(DESTDIR)$(libdir)/$${n}.@DMRAID_LIB_VERSION@; \
+ $(LN_S) -f $${n}.@DMRAID_LIB_VERSION@ $(DESTDIR)$(libdir)/$${n}; \
else \
- $(INSTALL) -m 555 $(STRIP) $$f $(libdir)/$${n}; \
+ $(INSTALL) -m 555 $(STRIP) $$f $(DESTDIR)$(libdir)/$${n}; \
fi \
done
--- 1.0.0.rc16.orig/tools/Makefile.in
+++ 1.0.0.rc16/tools/Makefile.in
@@ -80,8 +80,8 @@ dmevent_tool: $(top_srcdir)/lib/libdmrai
install_dmraid_tools: $(TARGETS)
@echo "Installing $(TARGETS) in $(sbindir)"; \
- mkdir -p $(sbindir); \
- $(INSTALL) $(STRIP) $(TARGETS) $(sbindir)
+ mkdir -p $(DESTDIR)$(sbindir); \
+ $(INSTALL) $(STRIP) $(TARGETS) $(DESTDIR)$(sbindir)
install: install_dmraid_tools
--- 1.0.0.rc16.orig/man/Makefile.in
+++ 1.0.0.rc16/man/Makefile.in
@@ -17,11 +17,11 @@ include $(top_srcdir)/make.tmpl
install_dmraid_man:
@echo "Installing $(MAN8) in $(MAN8DIR)"; \
- mkdir -p $(MAN8DIR); \
+ mkdir -p $(DESTDIR)$(MAN8DIR); \
for f in $(MAN8); \
do \
$(RM) $(MAN8DIR)/$$f; \
- @INSTALL@ -D -m 444 $$f $(MAN8DIR)/$$f; \
+ @INSTALL@ -D -m 444 $$f $(DESTDIR)$(MAN8DIR)/$$f; \
done
install: install_dmraid_man

View file

@ -0,0 +1,13 @@
Index: 1.0.0.rc16/lib/locking/locking.c
===================================================================
--- 1.0.0.rc16.orig/lib/locking/locking.c
+++ 1.0.0.rc16/lib/locking/locking.c
@@ -12,7 +12,7 @@
#include "internal.h"
/* File locking private data. */
-static const char *lock_file = "/var/lock/dmraid/.lock";
+static const char *lock_file = "/run/lock/dmraid/.lock";
static int lf = -1;
/* flock file. */

175
dmraid.changes Normal file
View file

@ -0,0 +1,175 @@
* Thu Nov 23 2017 rbrown@suse.com
- Replace references to /var/adm/fillup-templates with new
%%_fillupdir macro (boo#1069468)
* Thu Oct 26 2017 mwilck@suse.com
- dmraid: remove partitions with O_RDONLY
* add 0001-remove-partitions-with-O_RDONLY.patch
* Sat Feb 18 2017 kukuk@suse.com
- Remove obsolete insserv call
* Thu Dec 10 2015 tiwai@suse.de
- Fix missing dependency on coreutils for initrd macros (boo#958562)
- Call missing initrd macro at postun (boo#958562)
* Mon Jul 13 2015 lwang@suse.com
- dmevent_tool fails with "undefined symbol" (bnc#935623)
Added: fix-undefined-symbol.patch
* Wed Feb 4 2015 coolo@suse.com
- remove with -f to avoid dependency on local umask
* Fri Dec 12 2014 kkaempf@suse.com
- Split off dmraid-devel subpackage
* Mon Nov 10 2014 dimstar@opensuse.org
- Own /usr/lib/tmpfiles.d: in the past, we were lucky for another
package in the build dependency chain to own this for us, but in
fact we should do it ourselves.
* Fri Jul 25 2014 jeffm@suse.com
- Rename README.SuSE to README.SUSE (bnc#889025).
* Fri Jun 13 2014 trenn@suse.de
- Use rpm macros to only trigger one initrd rebuild per install/update
* Wed May 21 2014 jsegitz@novell.com
- added necessary macros for systemd files
* Fri Sep 13 2013 crrodriguez@opensuse.org
- Fix Makefiles so they support DESTDIR
Added: dmraid-destdir.patch
- add tmpfiles.d so runtime directories are properly created
- Remove sysvinit support and replace it for native systemd support.
Added: dmraid-activation.service
Removed: boot.dmraid
* Tue Jul 23 2013 ohering@suse.de
- Remove usage of absolute paths in initrd
- Remove some checks from mkinitrd scripts, they are always true
- List all used binaries in programs tag
* Wed Nov 28 2012 rmilasan@suse.com
- Move lock file to /run/lock so it wont interfere with systemd.
* Mon Jul 9 2012 cfarrell@suse.com
- license update: GPL-2.0
See lib/register/dmreg.c and tools/dmevent_tool.c (both have GPL-2.0
license)
* Mon Jan 9 2012 aj@suse.de
- Add automake as buildrequires.
* Tue Dec 20 2011 coolo@suse.com
- add autoconf as buildrequire to avoid implicit dependency
* Wed Sep 21 2011 nfbrown@suse.com
- rebuild.fix: When a rebuild is requested that
cannot be handled, report and error instead of
crashing (bnc#716904)
- ddf-erase: Allow dmraid to erase ddf metadata
properly (bnc#712671)
* Fri May 27 2011 lnussel@suse.de
- don't hard require boot.device-mapper in boot.dmraid. dm-mod is
autoloaded when accessing /dev/mapper/control anyways.
* Mon Apr 19 2010 nfbrown@novell.com
- handle_space: cope with arrays with spaces in the name stored
in the metadata (bnc#470696)
- remove_trylock: pthreads_mutex_trylock is still very new in
glibc so safest not to use it yet (bnc#594388)
* Tue Feb 2 2010 nfbrown@novell.com
- new upstream version, including latest CVS updates.
Both libdmraid-events and dm_dso_reg_tool are not
in the main package.
- dm_dso_reg_tool has been renamed to dmevent_tool in
line with upstream change.
bnc#528796 bnc#511329
* Mon Oct 5 2009 crrodriguez@opensuse.org
- fix a few more fdleaks [bnc#543151]
* Sat Oct 3 2009 crrodriguez@opensuse.org
- fix directory handle leaks in libdmraid-events [bnc#524202]
* Mon Aug 24 2009 hvogel@novell.com
- Fix activation of isw raid sets when the disks have serialnumber
longer then 16 characters
- Add patch adding --rm_partitions cmdline option and functionality
- Fix mismatch between BIOS and dmraid's view of ISW raid 10 sets
* Sun Aug 2 2009 jansimon.moeller@opensuse.org
- The cmdline options don't work when compiling the events module
on ARM. Add patch to directly include the ldflags in the
Makefile.
* Mon Nov 24 2008 hare@suse.de
- Properly quote mkinitrd scripts (bnc#447966)
* Mon Nov 10 2008 mkoenig@suse.de
- adapt mkinitrd script to changed UUID prefix [bnc#441479]
* Tue Oct 14 2008 mkoenig@suse.de
- remove whitespace from serial id [bnc#433833]
* Thu Sep 25 2008 mkoenig@suse.de
- update to 1.0.0rc15
* jm.c: fixed name handling
* nv.c: fixed endian bug
* added support for RAID set create/remove/rebuild and
event handling
- needed for [fate#304215,fate#303950,fate#304216]
- removed patches
dmraid-1.0.0.rc13-jm_termination.patch
dmraid-1.0.0.rc14-ddf1_segfault.patch
dmraid-add_uuid.patch
dmraid_fixup_nvidia.diff
dmraid-move-type-definition.diff
dmraid-pdc_max_sectors.patch
* Wed Sep 24 2008 ro@suse.de
- change "udevsettle" to "udevadm settle"
* Tue Sep 16 2008 mkoenig@suse.de
- ignore the timestamp for LSI 1068E DDF1 metadata [bnc#426615]
* Mon Sep 15 2008 ro@suse.de
- fix typo in libdmraid Makefile
- split off libdmraid-events0 package according to
shared library packaging policy
* Sat Sep 13 2008 meissner@suse.de
- symlink, not copy the .so to the .so.0 file
- removed self-provides, some other .spec file fixes
* Wed Sep 10 2008 xwhu@novell.com
- Adding DSO for event-handling [fate#304214]
* Wed Sep 3 2008 hare@suse.de
- Call mkinitrd_setup during %%post and %%postun (bnc#413709)
* Wed Aug 20 2008 mkoenig@suse.de
- enable SELinux support [fate#303662]
* Wed Aug 13 2008 mkoenig@suse.de
- fix init script tags
* Wed Jul 23 2008 hare@suse.de
- Include mkinitrd scriptlets.
* Wed Mar 12 2008 mkoenig@suse.de
- add hack to avoid segfault with DDF1 metadata and explicit
indication of the raid set [#367686]
* Wed Sep 12 2007 mkoenig@suse.de
- add quirk for maximum detected device size of some pdc card
[#215222]
* Tue Jul 31 2007 hare@suse.de
- dmraid requires kpartx.
* Mon Jul 30 2007 hare@suse.de
- Do not activate partitions from dmraid; udev handles it.
* Tue Jul 10 2007 mkoenig@suse.de
- update to version 1.0.0.rc14
* bugfix release
* Tue Jun 19 2007 mkoenig@suse.de
- use boot.localfs to avoid expansion problem
* Tue Jun 19 2007 mkoenig@suse.de
- Add X-Start-Before: $local_fs dependency
* Thu Mar 29 2007 mkoenig@suse.de
- Add zlib-devel to BuildRequires
* Tue Feb 20 2007 mkoenig@suse.de
- provide boot script [#230708]
* Mon Dec 11 2006 mkoenig@suse.de
- fix jm name string termination problem [#223843]
patch: dmraid-1.0.0.rc13-jm_termination.patch
- fix min, max macros
patch: dmraid-1.0.0.rc13-fix_macro.patch
* Thu Nov 23 2006 mkoenig@suse.de
- fix geometry patch [#222110]
* Mon Nov 20 2006 mkoenig@suse.de
- set geometry of dm device [#222110]
* Thu Nov 9 2006 mkoenig@suse.de
- update to version 1.0.0.rc13
* Fixes for Promise FastTrak and Silicon Image Medley ATARAID
* Support for SNIA DDF1 and JBOD
* Wed Sep 13 2006 ro@suse.de
- use device-mapper-devel in BuildRequires
* Tue Aug 29 2006 hare@suse.de
- update to 1.0.0-rc11
- NVidia endianness fixes
- Add UUID to device-mapper tables
- Fixup '-cc' argument
* Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Mon Dec 5 2005 kukuk@suse.de
- Remove unused klibc-devel from neededforbuild
* Wed Jul 13 2005 cadaha@suse.de
- update to 1.0.0-rc8, fix big endian build
* Tue Sep 21 2004 cadaha@suse.de
- fix dmraid -rc output for unsupported devices
* Mon Sep 20 2004 cadaha@suse.de
- created package

163
dmraid.spec Normal file
View file

@ -0,0 +1,163 @@
#
# spec file for package dmraid
#
# Copyright (c) 2022-2023 ZhuningOS
#
#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
%define _fillupdir /var/adm/fillup-templates
%endif
Name: dmraid
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: device-mapper-devel
BuildRequires: libselinux-devel
BuildRequires: suse-module-tools
BuildRequires: systemd-rpm-macros
BuildRequires: zlib-devel
Requires: aaa_base
Requires: kpartx
Requires(post): coreutils
Requires(postun): coreutils
Url: http://people.redhat.com/~heinzm/sw/dmraid/src/
Summary: A Device-Mapper Software RAID Support Tool
License: GPL-2.0
Group: System/Base
Version: 1.0.0.rc16
Release: 3.26
Source: ftp://people.redhat.com/heinzm/sw/dmraid/src/dmraid-%{version}.tar.bz2
Source1: sysconfig.dmraid
Source3: README.SUSE
Source6: dmraid-activation.service
Patch1: dmraid-1.0.0.rc16-cvs-2010-02-02.patch
Patch2: dmraid-1.0.0.rc13-geometry.patch
Patch3: lib-install.patch
Patch4: handle_spaces
Patch5: remove_trylock
Patch6: rebuild.fix
Patch7: ddf-erase
Patch8: dmraid-move-var-lock-to-run-lock.patch
Patch9: dmraid-destdir.patch
Patch10: fix-undefined-symbol.patch
Patch11: 0001-remove-partitions-with-O_RDONLY.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
PreReq: %fillup_prereq
%{systemd_requires}
%description
This software discovers, activates, deactivates, and displays
properties of software RAID sets, such as ATARAID, and contained DOS
partitions.
dmraid uses libdevmapper and the device-mapper kernel runtime to create
devices with respective mappings for the ATARAID sets discovered.
The following ATARAID types are supported:
- Highpoint HPT37X
- Highpoint HPT45X
- Intel Software RAID
- Promise FastTrak
- Silicon Image Medley
%package devel
Summary: Development files for dmraid
Group: Development/Libraries/C and C++
Requires: %{name} = %{version}
%description devel
This software discovers, activates, deactivates, and displays
properties of software RAID sets, such as ATARAID, and contained DOS
partitions.
dmraid uses libdevmapper and the device-mapper kernel runtime to create
devices with respective mappings for the ATARAID sets discovered.
%prep
%setup -n dmraid/%{version}
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p2
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p2
cp %{SOURCE3} .
%build
#rm -f aclocal.m4
autoreconf -fi
rm -r autom4te.cache
%configure \
--libdir=/%_lib \
--sbindir=/sbin \
--with-user=`id -nu` --with-group=`id -ng` \
--enable-libselinux --enable-libsepol
make
%install
make install DESTDIR=$RPM_BUILD_ROOT
rm -f $RPM_BUILD_ROOT/%_lib/libdmraid.a
mkdir -p $RPM_BUILD_ROOT%{_fillupdir}
install -m644 %{SOURCE1} $RPM_BUILD_ROOT%{_fillupdir}/sysconfig.dmraid
install -D -m 0644 %{S:6} %{buildroot}%{_unitdir}/dmraid-activation.service
install -d %{buildroot}%{_tmpfilesdir}
echo 'd /run/lock/dmraid 0700 root root -' > %{buildroot}%{_tmpfilesdir}/dmraid.conf
# E: spurious-executable-perm (Badness: 50) /usr/include/dmraid/locking.h
chmod -x %{buildroot}%{_prefix}/include/dmraid/*h
%pre
%service_add_pre dmraid-activation.service
%preun
%service_del_preun dmraid-activation.service
%post
/sbin/ldconfig
%service_add_post dmraid-activation.service
%{?regenerate_initrd_post}
%posttrans
%{?regenerate_initrd_posttrans}
%{fillup_only}
%postun
/sbin/ldconfig
%service_del_postun dmraid-activation.service
%{?regenerate_initrd_post}
%files
%defattr(-, root, root)
/sbin/dmraid
/sbin/dmevent_tool
%{_mandir}/man8/*
%doc LICENSE LICENSE_GPL LICENSE_LGPL README README.SUSE TODO doc/*
%{_fillupdir}/sysconfig.dmraid
/%{_lib}/libdmraid-events-isw.so
/%{_lib}/libdmraid.so.1.0.0.rc16-3
%dir %{_tmpfilesdir}
%{_tmpfilesdir}/dmraid.conf
%{_unitdir}/dmraid-activation.service
%files devel
%defattr(-, root, root)
%dir %{_prefix}/include/dmraid
%{_prefix}/include/dmraid
/%{_lib}/libdmraid.so
%changelog

View file

@ -0,0 +1,28 @@
From 352b509c8f452a0d77d8adb9149130d5af624b32 Mon Sep 17 00:00:00 2001
From: Liuhua Wang <lwang@suse.com>
Date: Thu, 9 Jul 2015 10:22:46 +0800
Subject: [PATCH] fix undefined symbol
Signed-off-by: Liuhua Wang <lwang@suse.com>
References: bnc#935623
---
dmraid/1.0.0.rc16/tools/dmevent_tool.c | 2 ++
1 file changed, 2 insertions(+)
diff --git 1.0.0.rc16.orig/tools/dmevent_tool.c 1.0.0.rc16/tools/dmevent_tool.c
index 8562098..4c43b30 100644
--- 1.0.0.rc16.orig/tools/dmevent_tool.c
+++ 1.0.0.rc16/tools/dmevent_tool.c
@@ -77,6 +77,8 @@
#define SYS_DM_DEV "/dev"
#define SYS_DM_SLAVES_DIR "/slaves"
+int dmeventd_debug = 0;
+
/* Command line option counters for CLI processing. */
enum option_type { OPT_a, OPT_h, OPT_m, OPT_r, OPT_u, OPT_V, OPT_SUM, OPT_MAX };
static int optc[OPT_MAX];
--
1.8.4.5

73
handle_spaces Normal file
View file

@ -0,0 +1,73 @@
---
include/dmraid/misc.h | 1 +
lib/format/ataraid/isw.c | 7 ++++++-
lib/format/ddf/ddf1.c | 1 +
lib/misc/misc.c | 14 ++++++++++++++
4 files changed, 22 insertions(+), 1 deletion(-)
--- 1.0.0.rc16.orig/include/dmraid/misc.h
+++ 1.0.0.rc16/include/dmraid/misc.h
@@ -18,6 +18,7 @@ extern void libdmraid_exit(struct lib_co
extern void sysfs_workaround(struct lib_context *lc);
extern void mk_alpha(struct lib_context *lc, char *str, size_t len);
+extern void mk_alphanum(struct lib_context *lc, char *str, size_t len);
extern char *get_basename(struct lib_context *lc, char *str);
extern char *get_dirname(struct lib_context *lc, char *str);
extern char *remove_white_space(struct lib_context *lc, char *str, size_t len);
--- 1.0.0.rc16.orig/lib/format/ataraid/isw.c
+++ 1.0.0.rc16/lib/format/ataraid/isw.c
@@ -169,6 +169,7 @@ static size_t
_name(struct lib_context *lc, struct isw *isw, char *str, size_t len,
enum name_type nt, int num, struct isw_dev *dev, struct raid_dev *rd)
{
+ int n;
struct {
const char *fmt, *what;
} formats[] = {
@@ -189,7 +190,11 @@ _name(struct lib_context *lc, struct isw
f += (is_raid10(dev) ? 1 : 0);
}
- return snprintf(str, len, f->fmt, isw->family_num, f->what, num);
+ n = snprintf(str, len, f->fmt, isw->family_num, f->what, num);
+ /* As '->volume' could contain anything, we need to sanitise the name */
+ if (str)
+ mk_alphanum(lc, str, n);
+ return n;
}
static char *
--- 1.0.0.rc16.orig/lib/format/ddf/ddf1.c
+++ 1.0.0.rc16/lib/format/ddf/ddf1.c
@@ -689,6 +689,7 @@ name(struct lib_context *lc, struct ddf1
i = prefix + 16;
while (!isgraph(buf[--i]));
buf[i + 1] = 0;
+ mk_alphanum(lc, buf, i);
} else {
char *b;
--- 1.0.0.rc16.orig/lib/misc/misc.c
+++ 1.0.0.rc16/lib/misc/misc.c
@@ -66,6 +66,20 @@ mk_alpha(struct lib_context *lc, char *s
}
}
+/* Convert a string to only have alphanum or '-' or '_'.
+ * All others become '_'
+ */
+void
+mk_alphanum(struct lib_context *lc, char *str, size_t len)
+{
+ for (; len && *str; len--, str++) {
+ if (!isalnum(*str) &&
+ *str != '-' &&
+ *str != '_')
+ *str = '_';
+ }
+}
+
/* Remove any whitespace from a string. */
char *
remove_white_space(struct lib_context *lc, char *str, size_t size)

30
lib-install.patch Normal file
View file

@ -0,0 +1,30 @@
Fix two issues with installing shared libraries.
1/ the [[ =~ ]] operator only treats the RHS as a regular expression
if it isn't quoted. So we need to remove the quotes.
2/ The libdmraid-event-* library is not a shared library in the regular
sense. i.e. programs are not linked against it and so do not have the
library version number encoded in them.
Rather, this is a shared-object that is explicitly loaded by dmeventd
on request from dmraid. dmraid asks for "libdmraid-event-ism.so", so
that is the only name that the shared object should be stored under.
Providing a name with a trailing version number just makes it look like
something that it is not.
Signed-off-by: NeilBrown <neilb@suse.de>
---
lib/Makefile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- dmraid.orig/lib/Makefile.in
+++ dmraid/lib/Makefile.in
@@ -82,7 +82,7 @@ install_dmraid_libs: $(INSTALL_TARGETS)
for f in $(INSTALL_TARGETS); \
do \
n=$$(basename $${f}) ; \
- if [[ "$$n" =~ '.so$$' ]]; then \
+ if [[ "$$n" =~ .so$$ && ! "$$n" =~ libdmraid-events-.* ]]; then \
$(INSTALL) -m 555 $(STRIP) \
$$f $(libdir)/$${n}.@DMRAID_LIB_VERSION@; \
$(LN_S) -f $${n}.@DMRAID_LIB_VERSION@ $(libdir)/$${n}; \

27
rebuild.fix Normal file
View file

@ -0,0 +1,27 @@
Only imsm arrays can be rebuild by dmraid
Others cause a segfault.
Fix that so they print a more helpful error messages.
From: Leonardo Chiquitto <lchiquitto@suse.com>
Reviewed-by: NeilBrown <neilb@suse.de>
References: bnc#716904
---
lib/metadata/reconfig.c | 5 +++++
1 file changed, 5 insertions(+)
--- 1.0.0.rc16.orig/lib/metadata/reconfig.c
+++ 1.0.0.rc16/lib/metadata/reconfig.c
@@ -552,6 +552,11 @@ _rebuild_raidset(struct lib_context *lc,
int driveRebuild = 1;
rs = find_group(lc, sub_rs);
+ if (!rs) {
+ log_print(lc, "Rebuild: array \"%s\" cannot be rebuilt by dmraid.\n",
+ set_name);
+ return 1;
+ }
/* raid 0 cannot be rebuild - exit */
if (T_RAID0(sub_rs) && (!SETS(sub_rs))) {

35
remove_trylock Normal file
View file

@ -0,0 +1,35 @@
Remove call to pthreads_mutex_trylock
Reference bnc
594388
This appears only to be in very recent releases of glibc.
Its presence causes
/sbin/dmraid -ay -p
The dynamic shared library "libdmraid-events-isw.so" could not be loaded:
/lib/libdmraid-events-isw.so: undefined symbol: pthread_mutex_trylock
on openSUSE 11.3, it is is not used for anything except a simple
logging message.
Signed-off-by: NeilBrown <neilb@suse.de>
---
1.0.0.rc16/lib/events/libdmraid-events-isw.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
--- dmraid.orig/1.0.0.rc16/lib/events/libdmraid-events-isw.c
+++ dmraid/1.0.0.rc16/lib/events/libdmraid-events-isw.c
@@ -1433,11 +1433,7 @@ void process_event(struct dm_task *dmt,
/*
* Make sure, events are processed sequentially per RAID set.
*/
- if (pthread_mutex_trylock(&rs->event_mutex)) {
- syslog(LOG_NOTICE,
- " Another thread is handling an event. Waiting...");
- pthread_mutex_lock(&rs->event_mutex);
- }
+ pthread_mutex_lock(&rs->event_mutex);
do {
next = dm_get_next_target(dmt, next, &start, &length,

26
sysconfig.dmraid Normal file
View file

@ -0,0 +1,26 @@
## Path: System/File systems/dmraid
## Description: dmraid configuration
#
## Type: integer(0:)
## Default: 60
#
# Timeout for udev device detection. This is the upper limit which the
# boot script will wait for udev to finish hotplug event processing.
# If not all devices are detected during boot this value should be
# increased. Setting this to '0' disables waiting for udev.
#
DMRAID_DEVICE_TIMEOUT="60"
## Type: string
## Default: ""
#
# Commandline options for dmraid on start
#
DMRAID_START_OPTIONS=""
## Type: string
## Default: ""
#
# Commandline options for dmraid on stop
#
DMRAID_STOP_OPTIONS=""