Skip to content

Commit

Permalink
Changes for empty APFS volumes (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz authored Apr 30, 2022
1 parent afefcc6 commit 056c69d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
4 changes: 2 additions & 2 deletions config/dpkg/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dfvfs (20220419-1) unstable; urgency=low
dfvfs (20220430-1) unstable; urgency=low

* Auto-generated

-- Log2Timeline maintainers <log2timeline-maintainers@googlegroups.com> Tue, 19 Apr 2022 11:17:49 +0200
-- Log2Timeline maintainers <log2timeline-maintainers@googlegroups.com> Sat, 30 Apr 2022 06:49:30 +0200
2 changes: 1 addition & 1 deletion dfvfs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
storage media types and file formats.
"""

__version__ = '20220419'
__version__ = '20220430'
6 changes: 6 additions & 0 deletions dfvfs/helpers/volume_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,12 @@ def _ScanFileSystem(self, scan_node, base_path_specs):
if not scan_node or not scan_node.path_spec:
raise errors.ScannerError('Invalid or missing file system scan node.')

if scan_node.type_indicator == definitions.TYPE_INDICATOR_APFS:
# Note that APFS can have a volume without a root directory.
file_entry = resolver.Resolver.OpenFileEntry(scan_node.path_spec)
if not file_entry:
return

base_path_specs.append(scan_node.path_spec)

def _ScanSource(self, source_path):
Expand Down
30 changes: 16 additions & 14 deletions dfvfs/vfs/apfs_file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,29 @@ def GetFileEntryByPathSpec(self, path_spec):

if (location == self.LOCATION_ROOT or
identifier == self.ROOT_DIRECTORY_IDENTIFIER):
is_root = True
# Note that APFS can have a volume without a root directory.
fsapfs_file_entry = self._fsapfs_volume.get_root_directory()
return apfs_file_entry.APFSFileEntry(
self._resolver_context, self, path_spec,
fsapfs_file_entry=fsapfs_file_entry, is_root=True)

try:
if location is not None:
fsapfs_file_entry = self._fsapfs_volume.get_file_entry_by_path(location)
elif identifier is not None:
fsapfs_file_entry = self._fsapfs_volume.get_file_entry_by_identifier(
identifier)

except IOError as exception:
raise errors.BackEndError(exception)
else:
is_root = False
try:
if location is not None:
fsapfs_file_entry = self._fsapfs_volume.get_file_entry_by_path(
location)
elif identifier is not None:
fsapfs_file_entry = self._fsapfs_volume.get_file_entry_by_identifier(
identifier)

except IOError as exception:
raise errors.BackEndError(exception)

if fsapfs_file_entry is None:
return None

return apfs_file_entry.APFSFileEntry(
self._resolver_context, self, path_spec,
fsapfs_file_entry=fsapfs_file_entry)
fsapfs_file_entry=fsapfs_file_entry, is_root=is_root)

def GetAPFSFileEntryByPathSpec(self, path_spec):
"""Retrieves the APFS file entry for a path specification.
Expand Down Expand Up @@ -182,7 +184,7 @@ def GetRootFileEntry(self):
"""Retrieves the root file entry.
Returns:
APFSFileEntry: file entry.
APFSFileEntry: file entry or None if not available.
"""
path_spec = apfs_path_spec.APFSPathSpec(
location=self.LOCATION_ROOT, identifier=self.ROOT_DIRECTORY_IDENTIFIER,
Expand Down

0 comments on commit 056c69d

Please sign in to comment.