From dbba16cf1e7e4144e05f790583aa4ab955e5150f Mon Sep 17 00:00:00 2001 From: "M. Rehan" Date: Wed, 5 Jun 2024 20:34:14 +0500 Subject: [PATCH] Add force flag for mounting datasets --- libzfs.pyx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libzfs.pyx b/libzfs.pyx index f015f54..c05864a 100644 --- a/libzfs.pyx +++ b/libzfs.pyx @@ -4246,13 +4246,13 @@ cdef class ZFSDataset(ZFSResource): self.root.write_history('zfs mount', self.name) IF HAVE_ZFS_ENCRYPTION: - def mount_recursive(self, ignore_errors=False, skip_unloaded_keys=True): - return self._mount_recursive(ignore_errors, skip_unloaded_keys) + def mount_recursive(self, ignore_errors=False, skip_unloaded_keys=True, force_mount=False): + return self._mount_recursive(ignore_errors, skip_unloaded_keys, force_mount) ELSE: - def mount_recursive(self, ignore_errors=False): - return self._mount_recursive(ignore_errors, False) + def mount_recursive(self, ignore_errors=False, force_mount=False): + return self._mount_recursive(ignore_errors, False, force_mount) - def _mount_recursive(self, ignore_errors, skip_unloaded_keys): + def _mount_recursive(self, ignore_errors, skip_unloaded_keys, force_mount): if self.type != DatasetType.FILESYSTEM: return @@ -4260,7 +4260,7 @@ cdef class ZFSDataset(ZFSResource): if self.encrypted and not self.key_loaded and skip_unloaded_keys: return - if self.properties['canmount'].value == 'on': + if self.properties['canmount'].value == 'on' or force_mount: try: self.mount() except: @@ -4268,7 +4268,7 @@ cdef class ZFSDataset(ZFSResource): raise for i in self.children: - i._mount_recursive(ignore_errors, skip_unloaded_keys) + i._mount_recursive(ignore_errors, skip_unloaded_keys, force_mount) def umount(self, force=False): cdef int flags = 0