Skip to content

Commit

Permalink
Add force flag for mounting datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
Qubad786 committed Jun 6, 2024
1 parent e0aeeee commit dbba16c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions libzfs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4246,29 +4246,29 @@ 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

IF HAVE_ZFS_ENCRYPTION:
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:
if not ignore_errors:
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
Expand Down

0 comments on commit dbba16c

Please sign in to comment.