Example #1
0
    def parse_dir_inode_data(self, data: bytes) -> OverlayDir:
        from thrift.util import Serializer
        from thrift.protocol import TCompactProtocol

        tree_data = OverlayDir()
        protocol_factory = TCompactProtocol.TCompactProtocolFactory()
        Serializer.deserialize(protocol_factory, data, tree_data)
        return tree_data
Example #2
0
    def write_empty_dir(self, inode_number: int) -> None:
        from thrift.util import Serializer
        from thrift.protocol import TCompactProtocol

        empty_tree = OverlayDir()
        protocol_factory = TCompactProtocol.TCompactProtocolFactory()
        contents = typing.cast(
            bytes, Serializer.serialize(protocol_factory, empty_tree))

        self._write_inode(inode_number, OverlayHeader.TYPE_DIR, contents)
Example #3
0
    def parse_dir_inode_data(self, data: bytes) -> OverlayDir:
        from thrift.util import Serializer
        from thrift.protocol import TCompactProtocol

        # Initialize entries to the empty dictionary.
        # This value will be used if the serialized data does not have any value
        # for this field.
        tree_data = OverlayDir(entries={})
        protocol_factory = TCompactProtocol.TCompactProtocolFactory()
        Serializer.deserialize(protocol_factory, data, tree_data)
        return tree_data
Example #4
0
File: debug.py Project: cnmade/eden
def _load_overlay_tree(overlay_dir: str, inode_number: int) -> OverlayDir:
    from thrift.util import Serializer
    from thrift.protocol import TCompactProtocol

    dir_name = '{:02x}'.format(inode_number % 256)
    overlay_file_path = os.path.join(overlay_dir, dir_name, str(inode_number))
    with open(overlay_file_path, 'rb') as f:
        data = f.read()

    assert data[0:4] == b'OVDR'

    tree_data = OverlayDir()
    protocol_factory = TCompactProtocol.TCompactProtocolFactory()
    Serializer.deserialize(protocol_factory, data[64:], tree_data)
    return tree_data