:py:mod:`dissect.cramfs.cramfs` =============================== .. py:module:: dissect.cramfs.cramfs Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: dissect.cramfs.cramfs.CramFS dissect.cramfs.cramfs.INode dissect.cramfs.cramfs.BlockStream .. py:class:: CramFS(fh: BinaryIO) CramFS filesystem implementation. :param fh: A file-like object of the volume containing the filesystem. .. py:attribute:: fh .. py:attribute:: sb .. py:attribute:: root .. py:method:: inode(offset: int) -> INode .. py:method:: get(path: str | int, node: INode | None = None) -> INode Return an inode for the given path or offset. :param path: The path or offset of the inode. :param node: An optional inode object to relatively resolve the path from. .. py:class:: INode(fs: CramFS, offset: int) .. py:attribute:: fs .. py:attribute:: offset .. py:method:: __repr__() -> str .. py:property:: inode :type: dissect.cramfs.c_cramfs.c_cramfs.cramfs_inode Return the inode header. .. py:property:: mode :type: int Return the file mode. .. py:property:: uid :type: int Return the user ID. .. py:property:: major :type: int Return the major device ID for block and character devices. .. py:property:: minor :type: int Return the minor device ID for block and character devices. .. py:property:: size :type: int Return the file size. .. py:property:: gid :type: int Return the group ID. .. py:property:: data_offset :type: int Offset to the start of the data block or ``INode``. - For files: this is the offset to the first data block. - For directories: this is the offset to the first ``INode``. - For symlinks: this is the offset the data block holding the target name. .. py:property:: name :type: str Return the name of this inode. .. py:property:: link :type: str Return the symlink target. .. py:property:: blocks :type: list[tuple[int, int]] Return a list containing pairs of starting offsets and byte lengths for each block of this inode. .. py:method:: is_dir() -> bool Return whether this inode is a directory. .. py:method:: is_file() -> bool Return whether this inode is a file. .. py:method:: is_symlink() -> bool Return whether this inode is a symlink. .. py:method:: is_block_device() -> bool Return whether this inode is a block device. .. py:method:: is_character_device() -> bool Return whether this inode is a character device. .. py:method:: is_device() -> bool Return whether this inode is a device file. .. py:method:: is_fifo() -> bool Return whether this inode is a FIFO (named pipe). .. py:method:: is_socket() -> bool Return whether this inode is a socket. .. py:method:: is_ipc() -> bool Return whether this inode is an IPC object (FIFO or socket). .. py:method:: listdir() -> dict[str, INode] Return a directory listing. .. py:attribute:: dirlist .. py:method:: iterdir() -> collections.abc.Iterator[INode] Iterate directory contents. .. py:method:: open() -> BlockStream | dissect.util.stream.RangeStream Return a file-like object for reading. .. py:class:: BlockStream(inode: INode) Bases: :py:obj:`dissect.util.stream.AlignedStream` Basic buffered stream that provides aligned reads. Must be subclassed for various stream implementations. Subclasses can implement: - :meth:`~AlignedStream._read` - :meth:`~AlignedStream._seek` The offset and length for ``_read`` are guaranteed to be aligned for streams of a known size. If your stream has an unknown size (i.e. ``size == None``), reads of length ``-1`` (i.e. read until EOF) will be passed through to your implementation of ``_read``. The only time that overriding ``_seek`` would make sense is if there's no known size of your stream, but still want to provide ``SEEK_END`` functionality. Most subclasses of ``AlignedStream`` take one or more file-like objects as source. Operations on these subclasses, like reading, will modify the source file-like object as a side effect. :param size: The size of the stream. This is used in read and seek operations. ``None`` if unknown. :param align: The alignment size. Read operations are aligned on this boundary. Also determines buffer size. .. automethod:: _read .. automethod:: _seek .. py:attribute:: inode .. py:attribute:: blocks .. py:attribute:: num_blocks