filesystem: allow zpool to satisfy mount

This commit is contained in:
Dan Bungert 2023-06-07 10:37:15 -06:00
parent 895f6a6384
commit 0e1da11c36
2 changed files with 19 additions and 1 deletions

View File

@ -1788,7 +1788,13 @@ class FilesystemModel(object):
"unknown bootloader type {}".format(self.bootloader))
def _mount_for_path(self, path):
return self._one(type='mount', path=path)
mount = self._one(type='mount', path=path)
if mount is not None:
return mount
zpool = self._one(type='zpool', mountpoint=path)
if zpool is not None:
return zpool
return None
def is_root_mounted(self):
return self._mount_for_path('/') is not None

View File

@ -1290,3 +1290,15 @@ class TestZPool(SubiTestCase):
self.assertEqual('zfs-1', zfs.id)
self.assertEqual(zpool, zfs.pool)
self.assertEqual('/ROOT', zfs.volume)
class TestRootfs(SubiTestCase):
def test_zpool_may_provide_rootfs(self):
m = make_model()
make_zpool(model=m, mountpoint='/')
self.assertTrue(m.is_root_mounted())
def test_zpool_nonrootfs_mountpoint(self):
m = make_model()
make_zpool(model=m, mountpoint='/srv')
self.assertFalse(m.is_root_mounted())