Skip to content

Commit

Permalink
Merge pull request #5 from mitre/ufs-dev
Browse files Browse the repository at this point in the history
Switch ufs to loopback and limit volume index recursion.
  • Loading branch information
agibbons27 authored Jun 26, 2024
2 parents 25fe41a + 9e6987c commit d16913a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
15 changes: 14 additions & 1 deletion imagemounter_mitre/filesystems.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ class ExtFileSystem(MountFileSystem):
_mount_opts = 'noexec,noload'


class UfsFileSystem(MountFileSystem):
class UfsFileSystem(LoopbackFileSystemMixin, MountFileSystem):

type = 'ufs'
aliases = ['4.2bsd', 'ufs2', 'ufs 2']
# TODO: support for other ufstypes
Expand All @@ -354,6 +355,18 @@ def detect(cls, source, description):
res.update({cls: -20, VolumeSystemFileSystem: 20})
return res

def mount(self):
try:
self._make_mountpoint()
self._find_loopback()
_util.check_call_(['mount', '-t', 'ufs', '-o', f'ufstype=ufs2,offset={self.volume.parent.offset}',
self.loopback, self.mountpoint], stdout=subprocess.PIPE)
return
except Exception:
self._free_loopback()
self._clear_mountpoint()
raise


class NtfsFileSystem(MountFileSystem):
type = 'ntfs'
Expand Down
17 changes: 11 additions & 6 deletions imagemounter_mitre/volume_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,17 @@ def detect(self, volume_system, vstype='detect'):
if len(values) > 5:
description = values[5]

volume = volume_system._make_subvolume(
index=self._format_index(volume_system, int(index[:-1])),
offset=int(start) * volume_system.disk.block_size,
size=int(length) * volume_system.disk.block_size
)
volume.info['fsdescription'] = description
index = self._format_index(volume_system, int(index[:-1]))
volume = None
if index.count('.') < 2:
volume = volume_system._make_subvolume(
index=index,
offset=int(start) * volume_system.disk.block_size,
size=int(length) * volume_system.disk.block_size
)
volume.info['fsdescription'] = description
else:
continue
except Exception:
logger.exception("Error while parsing mmls output")
continue
Expand Down

0 comments on commit d16913a

Please sign in to comment.