Skip to content

Commit

Permalink
Add APFS support using apfs-fuse
Browse files Browse the repository at this point in the history
  • Loading branch information
joostrijneveld committed Feb 9, 2023
1 parent 383b30b commit e67acde
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion imagemounter/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def printable_status(self):
mount_ntfs = FileSystemTypeDependency("ntfs", "ntfs-3g", "NTFS volumes")
lvm = CommandDependency("lvm", "lvm2", "LVM volumes")
vmfs_fuse = CommandDependency("vmfs-fuse", "vmfs-tools", "VMFS volumes")
apfs_fuse = CommandDependency("apfs-fuse", why="APFS volumes")
mount_jffs2 = FileSystemTypeDependency("jffs2", "mtd-tools", "JFFS2 volumes")
mount_squashfs = FileSystemTypeDependency("squashfs", "squashfs-tools", "SquashFS volumes")
mdadm = CommandDependency("mdadm", "mdadm", "RAID volumes")
Expand All @@ -284,7 +285,7 @@ def printable_status(self):

mount_volumes = DependencySection(name="Mounting volumes",
description="install when needed",
deps=[mount_xfs, mount_ntfs, lvm, vmfs_fuse, mount_jffs2,
deps=[mount_xfs, mount_ntfs, lvm, vmfs_fuse, apfs_fuse, mount_jffs2,
mount_squashfs, mdadm, cryptsetup, bdemount, vshadowmount, photorec])

ALL_SECTIONS = [
Expand Down
15 changes: 15 additions & 0 deletions imagemounter/filesystems.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,21 @@ def mount(self):
raise


class ApfsFileSystem(LoopbackFileSystemMixin, MountFileSystem):
type = 'apfs'

@dependencies.require(dependencies.apfs_fuse)
def mount(self):
self._make_mountpoint()
self._find_loopback()
try:
_util.check_call_(['apfs-fuse', self.loopback, self.mountpoint], stdout=subprocess.PIPE)
except Exception:
self._free_loopback()
self._clear_mountpoint()
raise


class Jffs2FileSystem(MountFileSystem):
type = 'jffs2'

Expand Down

0 comments on commit e67acde

Please sign in to comment.