storage: make DirectoryThinPool helper less verbose, add sudo

Don't print scary messages when given pool cannot be found. Also, add
sudo to make it work from non-root user (tests)
这个提交包含在:
Marek Marczykowski-Górecki 2018-03-20 15:54:23 +01:00
父节点 1bc640f3e0
当前提交 825de49767
找不到此签名对应的密钥
GPG 密钥 ID: 063938BA42CFA724

查看文件

@ -932,9 +932,12 @@ class DirectoryThinPool:
fs_major = (fs_stat.st_dev & 0xff00) >> 8
fs_minor = fs_stat.st_dev & 0xff
root_table = subprocess.check_output(["dmsetup",
sudo = []
if os.getuid():
sudo = ['sudo']
root_table = subprocess.check_output(sudo + ["dmsetup",
"-j", str(fs_major), "-m", str(fs_minor),
"table"])
"table"], stderr=subprocess.DEVNULL)
_start, _sectors, target_type, target_args = \
root_table.decode().split(" ", 3)