-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code review: 283010043: Added LVM support #89
- Loading branch information
1 parent
64dcc2e
commit 0783a44
Showing
83 changed files
with
1,554 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
python-dfvfs (20160201-1) unstable; urgency=low | ||
dfvfs (20160203-1) unstable; urgency=low | ||
|
||
* Auto-generated | ||
|
||
-- Log2Timeline <[email protected]> Mon, 01 Feb 2016 20:34:54 +0100 | ||
-- Log2Timeline <[email protected]> Wed, 03 Feb 2016 21:47:21 +0100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,12 @@ Maintainer: dfVFS development team <[email protected]> | |
Build-Depends: debhelper (>= 7), python-all (>= 2.7~), python-setuptools, python3-all (>= 3.2~), python3-setuptools | ||
Standards-Version: 3.9.5 | ||
X-Python-Version: >= 2.7 | ||
X-Python3-Version: >= 3.2 | ||
X-Python-Version: >= 3.2 | ||
Homepage: https://github.com/log2timeline/dfvfs/ | ||
|
||
Package: python-dfvfs | ||
Architecture: all | ||
Depends: libprotobuf7|libprotobuf8, libbde-python, libewf-python, libfsntfs-python, libqcow-python, libsigscan-python, libsmdev-python, libsmraw-python, libvhdi-python, libvmdk-python, libvshadow-python, python-construct, python-pycrypto, python-protobuf, python-six, pytsk3, ${python:Depends}, ${misc:Depends} | ||
Depends: libprotobuf7|libprotobuf8, libbde-python, libewf-python, libfsntfs-python, libqcow-python, libsigscan-python, libsmdev-python, libsmraw-python, libvhdi-python, libvmdk-python, libvshadow-python, libvslvm-python, python-construct, python-pycrypto, python-protobuf, python-six, pytsk3-python, ${python:Depends}, ${misc:Depends} | ||
Description: Digital Forensics Virtual File System (dfVFS). | ||
dfVFS, or Digital Forensics Virtual File System, provides read-only access to | ||
file-system objects from various storage media types and file formats. The goal | ||
|
@@ -20,11 +20,11 @@ Description: Digital Forensics Virtual File System (dfVFS). | |
|
||
Package: python3-dfvfs | ||
Architecture: all | ||
Depends: libprotobuf7|libprotobuf8, libbde-python3, libewf-python3, libfsntfs-python3, libqcow-python3, libsigscan-python3, libsmdev-python3, libsmraw-python3, libvhdi-python3, libvmdk-python3, libvshadow-python3, python3-contruct, python3-pycrypto, python3-protobuf, python3-six, pytsk3, ${python:Depends}, ${misc:Depends} | ||
Depends: libprotobuf7|libprotobuf8, libbde-python3, libewf-python3, libfsntfs-python3, libqcow-python3, libsigscan-python3, libsmdev-python3, libsmraw-python3, libvhdi-python3, libvmdk-python3, libvshadow-python3, libvslvm-python3, python3-construct, python3-pycrypto, python3-protobuf, python3-six, pytsk3-python3, ${python3:Depends}, ${misc:Depends} | ||
Description: Digital Forensics Virtual File System (dfVFS). | ||
dfVFS, or Digital Forensics Virtual File System, provides read-only access to | ||
file-system objects from various storage media types and file formats. The goal | ||
of dfVFS is to provide a generic interface for accessing file-system objects, | ||
for which it uses several back-ends that provide the actual implementation of | ||
the various storage media types, volume systems and file systems. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
__version__ = '20160201' | ||
__version__ = '20160203' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
"""The Logical Volume Manager (LVM) format analyzer helper implementation.""" | ||
|
||
from dfvfs.analyzer import analyzer | ||
from dfvfs.analyzer import analyzer_helper | ||
from dfvfs.analyzer import specification | ||
from dfvfs.lib import definitions | ||
|
||
|
||
class LVMAnalyzerHelper(analyzer_helper.AnalyzerHelper): | ||
"""Class that implements the LVM analyzer helper.""" | ||
|
||
FORMAT_CATEGORIES = frozenset([ | ||
definitions.FORMAT_CATEGORY_VOLUME_SYSTEM]) | ||
|
||
TYPE_INDICATOR = definitions.TYPE_INDICATOR_LVM | ||
|
||
def GetFormatSpecification(self): | ||
"""Retrieves the format specification.""" | ||
format_specification = specification.FormatSpecification( | ||
self.type_indicator) | ||
|
||
# LVM signature. | ||
format_specification.AddNewSignature(b'LABELONE', offset=0) | ||
format_specification.AddNewSignature(b'LABELONE', offset=512) | ||
format_specification.AddNewSignature(b'LABELONE', offset=1024) | ||
format_specification.AddNewSignature(b'LABELONE', offset=1536) | ||
|
||
return format_specification | ||
|
||
|
||
# Register the analyzer helpers with the analyzer. | ||
analyzer.Analyzer.RegisterHelper(LVMAnalyzerHelper()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# -*- coding: utf-8 -*- | ||
"""The Logical Volume Manager (LVM) file-like object implementation.""" | ||
|
||
import os | ||
|
||
from dfvfs.file_io import file_io | ||
from dfvfs.lib import errors | ||
from dfvfs.lib import lvm | ||
from dfvfs.resolver import resolver | ||
|
||
|
||
class LVMFile(file_io.FileIO): | ||
"""Class that implements a file-like object using pyvslvm.""" | ||
|
||
def __init__(self, resolver_context): | ||
"""Initializes the file-like object. | ||
Args: | ||
resolver_context: the resolver context (instance of Context). | ||
""" | ||
super(LVMFile, self).__init__(resolver_context) | ||
self._file_system = None | ||
self._vslvm_logical_volume = None | ||
|
||
def _Close(self): | ||
"""Closes the file-like object. | ||
Raises: | ||
IOError: if the close failed. | ||
""" | ||
self._vslvm_logical_volume = None | ||
|
||
self._file_system.Close() | ||
self._file_system = None | ||
|
||
def _Open(self, path_spec=None, mode='rb'): | ||
"""Opens the file-like object defined by path specification. | ||
Args: | ||
path_spec: optional path specification (instance of PathSpec). | ||
mode: optional file access mode. The default is 'rb' read-only binary. | ||
Raises: | ||
AccessError: if the access to open the file was denied. | ||
IOError: if the file-like object could not be opened. | ||
PathSpecError: if the path specification is incorrect. | ||
ValueError: if the path specification is invalid. | ||
""" | ||
if not path_spec: | ||
raise ValueError(u'Missing path specfication.') | ||
|
||
volume_index = lvm.LVMPathSpecGetVolumeIndex(path_spec) | ||
if volume_index is None: | ||
raise errors.PathSpecError( | ||
u'Unable to retrieve volume index from path specification.') | ||
|
||
self._file_system = resolver.Resolver.OpenFileSystem( | ||
path_spec, resolver_context=self._resolver_context) | ||
vslvm_volume_group = self._file_system.GetLVMVolumeGroup() | ||
|
||
if (volume_index < 0 or | ||
volume_index >= vslvm_volume_group.number_of_logical_volumes): | ||
raise errors.PathSpecError(( | ||
u'Unable to retrieve LVM logical volume index: {0:d} from path ' | ||
u'specification.').format(volume_index)) | ||
|
||
self._vslvm_logical_volume = vslvm_volume_group.get_logical_volume( | ||
volume_index) | ||
|
||
# Note: that the following functions do not follow the style guide | ||
# because they are part of the file-like object interface. | ||
|
||
def read(self, size=None): | ||
"""Reads a byte string from the file-like object at the current offset. | ||
The function will read a byte string of the specified size or | ||
all of the remaining data if no size was specified. | ||
Args: | ||
size: Optional integer value containing the number of bytes to read. | ||
Default is all remaining data (None). | ||
Returns: | ||
A byte string containing the data read. | ||
Raises: | ||
IOError: if the read failed. | ||
""" | ||
if not self._is_open: | ||
raise IOError(u'Not opened.') | ||
|
||
return self._vslvm_logical_volume.read(size) | ||
|
||
def seek(self, offset, whence=os.SEEK_SET): | ||
"""Seeks an offset within the file-like object. | ||
Args: | ||
offset: The offset to seek. | ||
whence: Optional value that indicates whether offset is an absolute | ||
or relative position within the file. | ||
Raises: | ||
IOError: if the seek failed. | ||
""" | ||
if not self._is_open: | ||
raise IOError(u'Not opened.') | ||
|
||
self._vslvm_logical_volume.seek(offset, whence) | ||
|
||
def get_offset(self): | ||
"""Returns the current offset into the file-like object. | ||
Raises: | ||
IOError: if the file-like object has not been opened. | ||
""" | ||
if not self._is_open: | ||
raise IOError(u'Not opened.') | ||
|
||
return self._vslvm_logical_volume.get_offset() | ||
|
||
def get_size(self): | ||
"""Returns the size of the file-like object. | ||
Raises: | ||
IOError: if the file-like object has not been opened. | ||
""" | ||
if not self._is_open: | ||
raise IOError(u'Not opened.') | ||
|
||
return self._vslvm_logical_volume.size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.