Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-129441 / 24.10 / Add force flag for mounting datasets #273

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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