Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package libstorage-ng for openSUSE:Factory checked in at 2025-07-20 15:28:41 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libstorage-ng (Old) and /work/SRC/openSUSE:Factory/.libstorage-ng.new.8875 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libstorage-ng" Sun Jul 20 15:28:41 2025 rev:304 rq:1294072 version:4.5.264 Changes: -------- --- /work/SRC/openSUSE:Factory/libstorage-ng/libstorage-ng.changes 2025-07-15 16:42:35.616874358 +0200 +++ /work/SRC/openSUSE:Factory/.libstorage-ng.new.8875/libstorage-ng.changes 2025-07-20 15:29:22.292813111 +0200 @@ -1,0 +2,8 @@ +Thu Jul 17 09:12:48 UTC 2025 - aschn...@suse.com + +- merge gh#openSUSE/libstorage-ng#1029 +- fixed sysfs name and path for numeric named MD RAIDs (bsc#1246331) +- coding style +- 4.5.264 + +-------------------------------------------------------------------- Old: ---- libstorage-ng-4.5.263.tar.xz New: ---- libstorage-ng-4.5.264.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libstorage-ng.spec ++++++ --- /var/tmp/diff_new_pack.WkSS2f/_old 2025-07-20 15:29:22.968841085 +0200 +++ /var/tmp/diff_new_pack.WkSS2f/_new 2025-07-20 15:29:22.972841251 +0200 @@ -18,7 +18,7 @@ %define libname %{name}1 Name: libstorage-ng -Version: 4.5.263 +Version: 4.5.264 Release: 0 Summary: Library for storage management License: GPL-2.0-only ++++++ libstorage-ng-4.5.263.tar.xz -> libstorage-ng-4.5.264.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.5.263/LIBVERSION new/libstorage-ng-4.5.264/LIBVERSION --- old/libstorage-ng-4.5.263/LIBVERSION 2025-07-15 12:56:52.000000000 +0200 +++ new/libstorage-ng-4.5.264/LIBVERSION 2025-07-17 11:12:48.000000000 +0200 @@ -1 +1 @@ -1.101.1 +1.101.2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.5.263/VERSION new/libstorage-ng-4.5.264/VERSION --- old/libstorage-ng-4.5.263/VERSION 2025-07-15 12:56:52.000000000 +0200 +++ new/libstorage-ng-4.5.264/VERSION 2025-07-17 11:12:48.000000000 +0200 @@ -1 +1 @@ -4.5.263 +4.5.264 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.5.263/storage/Devices/BlkDeviceImpl.h new/libstorage-ng-4.5.264/storage/Devices/BlkDeviceImpl.h --- old/libstorage-ng-4.5.263/storage/Devices/BlkDeviceImpl.h 2025-07-15 12:56:52.000000000 +0200 +++ new/libstorage-ng-4.5.264/storage/Devices/BlkDeviceImpl.h 2025-07-17 11:12:48.000000000 +0200 @@ -67,7 +67,7 @@ virtual RemoveInfo detect_remove_info() const { return RemoveInfo(true, 0); } const string& get_name() const { return name; } - void set_name(const string& name); + virtual void set_name(const string& name); const string& get_sysfs_name() const { return sysfs_name; } void set_sysfs_name(const string& sysfs_name) { Impl::sysfs_name = sysfs_name; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.5.263/storage/Devices/Md.h new/libstorage-ng-4.5.264/storage/Devices/Md.h --- old/libstorage-ng-4.5.263/storage/Devices/Md.h 2025-07-15 12:56:52.000000000 +0200 +++ new/libstorage-ng-4.5.264/storage/Devices/Md.h 2025-07-17 11:12:48.000000000 +0200 @@ -84,6 +84,8 @@ * form "/dev/md<number>" or "/dev/md/<name>". The first form is * called numeric. If name is a number it is also called numeric. * + * Tests have shown that the number must be between 0 and 1048575. + * * @see Device::create(Devicegraph*) * * @throw Exception @@ -122,12 +124,14 @@ std::vector<const BlkDevice*> get_blk_devices() const; /** - * Returns true if the name of the MD is numeric. + * Returns true iff the name of the MD is numeric. This is the case for + * e.g. /dev/md1 and also /dev/md/2. */ bool is_numeric() const; /** - * Returns the number of the MD. Throws if the MD is not numeric. + * Returns the number of the MD. Throws if the MD is not numeric or if the number + * is out of range. * * @throw Exception */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.5.263/storage/Devices/MdImpl.cc new/libstorage-ng-4.5.264/storage/Devices/MdImpl.cc --- old/libstorage-ng-4.5.263/storage/Devices/MdImpl.cc 2025-07-15 12:56:52.000000000 +0200 +++ new/libstorage-ng-4.5.264/storage/Devices/MdImpl.cc 2025-07-17 11:12:48.000000000 +0200 @@ -81,10 +81,10 @@ }); - // Matches names of the form /dev/md<number> and /dev/md/<number>. The - // latter looks like a named MD but since mdadm creates /dev/md<number> in - // that case and not /dev/md<some big number> the number must be - // considered in find_free_numeric_name(). + // Matches names of the form /dev/md<number> and /dev/md/<number>. The latter looks + // like a named MD but since mdadm creates /dev/md<number> (without leading zeros) in + // that case and not /dev/md<some big dynamic number> the number must be considered in + // find_free_numeric_name(). const regex Md::Impl::numeric_name_regex(DEV_DIR "/md/?([0-9]+)", regex::extended); @@ -94,7 +94,11 @@ // does not work, e.g. the links in /dev/md/ are broken. const regex Md::Impl::format1_name_regex(DEV_MD_DIR "/([^/ ]+)", regex::extended); - const regex Md::Impl::format2_name_regex(DEV_MD_DIR "_([^/ ]+)", regex::extended); + + + // Adding "CREATE names=yes" to mdadm.conf gets named RAIDs using /dev/md_<name>. + + const regex Md::Impl::format2_name_regex(DEV_DIR "/md_([^/ ]+)", regex::extended); Md::Impl::Impl(const string& name) @@ -103,12 +107,7 @@ if (!is_valid_name(name)) ST_THROW(Exception("invalid Md name")); - if (is_numeric()) - { - string::size_type pos = string(DEV_DIR).size() + 1; - set_sysfs_name(name.substr(pos)); - set_sysfs_path("/devices/virtual/block/" + name.substr(pos)); - } + update_sysfs_name_and_path(); } @@ -152,6 +151,38 @@ } + void + Md::Impl::set_name(const string& name) + { + if (!is_valid_name(name)) + ST_THROW(Exception("invalid Md name")); + + Partitionable::Impl::set_name(name); + + update_sysfs_name_and_path(); + } + + + void + Md::Impl::update_sysfs_name_and_path() + { + smatch match; + + if (regex_match(get_name(), match, numeric_name_regex) && match.size() == 2) + { + string tmp = match[1]; + tmp.erase(0, min(tmp.find_first_not_of('0'), tmp.size() - 1)); + set_sysfs_name("md" + tmp); + set_sysfs_path("/devices/virtual/block/md" + tmp); + } + else + { + set_sysfs_name(""); + set_sysfs_path(""); + } + } + + string Md::Impl::find_free_numeric_name(const Devicegraph* devicegraph) { @@ -783,7 +814,14 @@ if (!regex_match(get_name(), match, numeric_name_regex) || match.size() != 2) ST_THROW(Exception("not a numeric Md")); - return atoi(match[1].str().c_str()); + try + { + return stoi(match[1]); + } + catch (const std::out_of_range& e) + { + ST_THROW(Exception("Md number out of range")); + } } @@ -795,7 +833,7 @@ if (!regex_match(get_name(), match, format1_name_regex) || match.size() != 2) ST_THROW(Exception("not a named Md")); - return match[1].str(); + return match[1]; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.5.263/storage/Devices/MdImpl.h new/libstorage-ng-4.5.264/storage/Devices/MdImpl.h --- old/libstorage-ng-4.5.263/storage/Devices/MdImpl.h 2025-07-15 12:56:52.000000000 +0200 +++ new/libstorage-ng-4.5.264/storage/Devices/MdImpl.h 2025-07-17 11:12:48.000000000 +0200 @@ -69,6 +69,8 @@ virtual ResizeInfo detect_resize_info(const BlkDevice* blk_device = nullptr) const override; + virtual void set_name(const string& name) override; + MdUser* add_device(BlkDevice* blk_device); void remove_device(BlkDevice* blk_device); @@ -187,7 +189,7 @@ private: - // regex to match name of the form /dev/md<number> + // regex to match name of the form /dev/md<number> and /dev/md/<number> static const regex numeric_name_regex; // regex to match name of the form /dev/md/<name> @@ -213,6 +215,8 @@ bool in_etc_mdadm = true; + void update_sysfs_name_and_path(); + }; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.5.263/storage/EtcMdadm.h new/libstorage-ng-4.5.264/storage/EtcMdadm.h --- old/libstorage-ng-4.5.263/storage/EtcMdadm.h 2025-07-15 12:56:52.000000000 +0200 +++ new/libstorage-ng-4.5.264/storage/EtcMdadm.h 2025-07-17 11:12:48.000000000 +0200 @@ -52,8 +52,6 @@ */ struct Entry { - Entry() : device(), uuid(), metadata(), container_uuid(), container_member() {} - string device; string uuid; string metadata; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.5.263/storage/SystemInfo/ProcMdstat.cc new/libstorage-ng-4.5.264/storage/SystemInfo/ProcMdstat.cc --- old/libstorage-ng-4.5.263/storage/SystemInfo/ProcMdstat.cc 2025-07-15 12:56:52.000000000 +0200 +++ new/libstorage-ng-4.5.264/storage/SystemInfo/ProcMdstat.cc 2025-07-17 11:12:48.000000000 +0200 @@ -338,7 +338,7 @@ MdadmDetail::MdadmDetail(const string& device) - : uuid(), devname(), metadata(), level(MdLevel::UNKNOWN), device(device) + : device(device) { SystemCmd cmd({ MDADM_BIN, "--detail", device, "--export" }, SystemCmd::DoThrow); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.5.263/storage/SystemInfo/ProcMdstat.h new/libstorage-ng-4.5.264/storage/SystemInfo/ProcMdstat.h --- old/libstorage-ng-4.5.263/storage/SystemInfo/ProcMdstat.h 2025-07-15 12:56:52.000000000 +0200 +++ new/libstorage-ng-4.5.264/storage/SystemInfo/ProcMdstat.h 2025-07-17 11:12:48.000000000 +0200 @@ -126,7 +126,7 @@ string devname; string metadata; - MdLevel level; + MdLevel level = MdLevel::UNKNOWN; /** * Mapping from device name to role (a number or spare). Faulty and journal diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.5.263/testsuite/Makefile.am new/libstorage-ng-4.5.264/testsuite/Makefile.am --- old/libstorage-ng-4.5.263/testsuite/Makefile.am 2025-07-15 12:56:52.000000000 +0200 +++ new/libstorage-ng-4.5.264/testsuite/Makefile.am 2025-07-17 11:12:48.000000000 +0200 @@ -16,7 +16,7 @@ dynamic.test ensure-mounted.test environment.test find-vertex.test \ fstab.test crypttab.test output.test probe.test range.test stable.test \ relatives.test mount-opts.test etc-mdadm.test mount-by.test btrfs.test \ - md1.test md2.test md3.test md4.test md5.test encryption1.test \ + md1.test md2.test md3.test md4.test md5.test md6.test encryption1.test \ encryption2.test lvm1.test lvm-pv-usable-size.test graphviz.test \ copy-individual.test mountpoint.test bcache1.test graph.test \ restore.test set-source.test valid-names.test mount-by2.test \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.5.263/testsuite/md1.cc new/libstorage-ng-4.5.264/testsuite/md1.cc --- old/libstorage-ng-4.5.263/testsuite/md1.cc 2025-07-15 12:56:52.000000000 +0200 +++ new/libstorage-ng-4.5.264/testsuite/md1.cc 2025-07-17 11:12:48.000000000 +0200 @@ -25,15 +25,27 @@ // will create /dev/md0 Md::create(staging, "/dev/md0"); + // next free is /dev/md1 BOOST_CHECK_EQUAL(Md::find_free_numeric_name(staging), "/dev/md1"); // will likely create /dev/md127 Md::create(staging, "/dev/md/test"); + // next free is still /dev/md1 + BOOST_CHECK_EQUAL(Md::find_free_numeric_name(staging), "/dev/md1"); + + // will create /dev/md2 and link /dev/md/2 + Md::create(staging, "/dev/md/2"); + + // will create /dev/md3 and link /dev/md/03 + Md::create(staging, "/dev/md/03"); + + // next free is still /dev/md1 BOOST_CHECK_EQUAL(Md::find_free_numeric_name(staging), "/dev/md1"); // will create /dev/md1 - Md::create(staging, "/dev/md/1"); + Md::create(staging, "/dev/md1"); - BOOST_CHECK_EQUAL(Md::find_free_numeric_name(staging), "/dev/md2"); + // next free is now /dev/md4 + BOOST_CHECK_EQUAL(Md::find_free_numeric_name(staging), "/dev/md4"); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libstorage-ng-4.5.263/testsuite/md6.cc new/libstorage-ng-4.5.264/testsuite/md6.cc --- old/libstorage-ng-4.5.263/testsuite/md6.cc 1970-01-01 01:00:00.000000000 +0100 +++ new/libstorage-ng-4.5.264/testsuite/md6.cc 2025-07-17 11:12:48.000000000 +0200 @@ -0,0 +1,85 @@ + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE libstorage + +#include <boost/test/unit_test.hpp> + +#include "storage/Devices/MdImpl.h" +#include "storage/Devicegraph.h" +#include "storage/Storage.h" +#include "storage/Environment.h" + + +using namespace std; +using namespace storage; + + +BOOST_AUTO_TEST_CASE(md_values) +{ + Environment environment(true, ProbeMode::NONE, TargetMode::DIRECT); + + Storage storage(environment); + + Devicegraph* staging = storage.get_staging(); + + // will create /dev/md0 + Md* md0 = Md::create(staging, "/dev/md0"); + + BOOST_CHECK_EQUAL(md0->get_name(), "/dev/md0"); + BOOST_CHECK(md0->is_numeric()); + BOOST_CHECK_EQUAL(md0->get_number(), 0); + BOOST_CHECK_THROW(md0->get_impl().get_short_name(), Exception); + + BOOST_CHECK_EQUAL(md0->get_sysfs_name(), "md0"); + BOOST_CHECK_EQUAL(md0->get_sysfs_path(), "/devices/virtual/block/md0"); + + // will create /dev/md2 + Md* md2 = Md::create(staging, "/dev/md/2"); + + BOOST_CHECK_EQUAL(md2->get_name(), "/dev/md/2"); + BOOST_CHECK(md2->is_numeric()); + BOOST_CHECK_EQUAL(md2->get_number(), 2); + BOOST_CHECK_EQUAL(md2->get_impl().get_short_name(), "2"); + + BOOST_CHECK_EQUAL(md2->get_sysfs_name(), "md2"); + BOOST_CHECK_EQUAL(md2->get_sysfs_path(), "/devices/virtual/block/md2"); + + // will create /dev/md7 + Md* md7 = Md::create(staging, "/dev/md/007"); + + BOOST_CHECK_EQUAL(md7->get_name(), "/dev/md/007"); + BOOST_CHECK(md7->is_numeric()); + BOOST_CHECK_EQUAL(md7->get_number(), 7); + BOOST_CHECK_EQUAL(md7->get_impl().get_short_name(), "007"); + + BOOST_CHECK_EQUAL(md7->get_sysfs_name(), "md7"); + BOOST_CHECK_EQUAL(md7->get_sysfs_path(), "/devices/virtual/block/md7"); + + // will likely "rename" /dev/md7 to /dev/md127 + md7->set_name("/dev/md/bond"); + + BOOST_CHECK_EQUAL(md7->get_name(), "/dev/md/bond"); + BOOST_CHECK(!md7->is_numeric()); + BOOST_CHECK_THROW(md7->get_number(), Exception); + BOOST_CHECK_EQUAL(md7->get_impl().get_short_name(), "bond"); + + BOOST_CHECK_EQUAL(md7->get_sysfs_name(), ""); + BOOST_CHECK_EQUAL(md7->get_sysfs_path(), ""); + + // will likely create /dev/md126 + Md* md_test = Md::create(staging, "/dev/md/test"); + + BOOST_CHECK_EQUAL(md_test->get_name(), "/dev/md/test"); + BOOST_CHECK(!md_test->is_numeric()); + BOOST_CHECK_THROW(md_test->get_number(), Exception); + BOOST_CHECK_EQUAL(md_test->get_impl().get_short_name(), "test"); + + BOOST_CHECK_EQUAL(md_test->get_sysfs_name(), ""); + BOOST_CHECK_EQUAL(md_test->get_sysfs_path(), ""); + + // invalid names cause an exception + BOOST_CHECK_THROW(Md::create(staging, "/dev/foo"), Exception); + BOOST_CHECK_THROW(Md::create(staging, "/dev/md_foo"), Exception); + BOOST_CHECK_THROW(md_test->set_name("/dev/foo"), Exception); + BOOST_CHECK_THROW(md_test->set_name("/dev/md_foo"), Exception); +}