-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix LVM setup for LVM with one character long names
- Loading branch information
Showing
7 changed files
with
147 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
------------------------------------------------------------------- | ||
Mon Aug 31 17:18:14 CEST 2020 - [email protected] | ||
|
||
- fix LVM setup for volume groups and logical volumes with one | ||
character long names (gh#openSUSE/snapper#465) | ||
|
||
------------------------------------------------------------------- | ||
Fri Aug 28 11:06:23 CEST 2020 - [email protected] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) [2011-2014] Novell, Inc. | ||
* Copyright (c) 2020 SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2 of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact Novell, Inc. | ||
* | ||
* To contact Novell about this file by physical or electronic mail, you may | ||
* find current contact information at www.novell.com. | ||
*/ | ||
|
||
|
||
#include <boost/algorithm/string.hpp> | ||
|
||
#include "snapper/LvmUtils.h" | ||
#include "snapper/Regex.h" | ||
#include "snapper/AppUtil.h" | ||
|
||
|
||
namespace snapper | ||
{ | ||
|
||
namespace LvmUtils | ||
{ | ||
|
||
pair<string, string> | ||
split_device_name(const string& name) | ||
{ | ||
Regex rx("^/dev/mapper/(.*[^-])-([^-].*)$"); | ||
if (!rx.match(name)) | ||
throw std::runtime_error("faild to split device name into volume group and " | ||
"logical volume name"); | ||
|
||
string vg_name = boost::replace_all_copy(rx.cap(1), "--", "-"); | ||
string lv_name = boost::replace_all_copy(rx.cap(2), "--", "-"); | ||
|
||
return make_pair(vg_name, lv_name); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) [2011-2014] Novell, Inc. | ||
* Copyright (c) 2020 SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2 of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact Novell, Inc. | ||
* | ||
* To contact Novell about this file by physical or electronic mail, you may | ||
* find current contact information at www.novell.com. | ||
*/ | ||
|
||
|
||
#ifndef SNAPPER_LVM_UTILS_H | ||
#define SNAPPER_LVM_UTILS_H | ||
|
||
|
||
#include <utility> | ||
#include <string> | ||
|
||
|
||
namespace snapper | ||
{ | ||
using std::string; | ||
using std::pair; | ||
|
||
|
||
namespace LvmUtils | ||
{ | ||
|
||
std::pair<string, string> split_device_name(const string& name); | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
#define BOOST_TEST_DYN_LINK | ||
#define BOOST_TEST_MODULE basename1 | ||
|
||
#include <boost/test/unit_test.hpp> | ||
|
||
#include <snapper/LvmUtils.h> | ||
|
||
using namespace snapper; | ||
|
||
|
||
BOOST_AUTO_TEST_CASE(split_device_name) | ||
{ | ||
std::pair<string, string> n1 = LvmUtils::split_device_name("/dev/mapper/system-root"); | ||
BOOST_CHECK_EQUAL(n1.first, "system"); | ||
BOOST_CHECK_EQUAL(n1.second, "root"); | ||
|
||
std::pair<string, string> n2 = LvmUtils::split_device_name("/dev/mapper/vg--system-lv--root"); | ||
BOOST_CHECK_EQUAL(n2.first, "vg-system"); | ||
BOOST_CHECK_EQUAL(n2.second, "lv-root"); | ||
|
||
std::pair<string, string> n3 = LvmUtils::split_device_name("/dev/mapper/s-r"); | ||
BOOST_CHECK_EQUAL(n3.first, "s"); | ||
BOOST_CHECK_EQUAL(n3.second, "r"); | ||
} |