dissect.target.tools.fsutils

Module Contents

Functions

prepare_ls_colors

Parse the LS_COLORS environment variable so we can use it later.

fmt_ls_colors

Helper method to colorize strings according to LS_COLORS.

human_size

Helper function to return the human readable string representation of bytes.

stat_modestr

Helper method for generating a mode string from a numerical mode value.

print_extensive_file_stat_listing

Print the file status as a single line.

ls_scandir

List a directory for the given path.

print_ls

Print ls output

print_stat

Print file status.

print_xattr

Mimics getfattr -d {file} behaviour.

Attributes

dissect.target.tools.fsutils.STAT_TEMPLATE = Multiline-String
Show Value
"""  File: {path} {symlink}
  Size: {size}       Blocks: {blocks}    IO Block: {blksize}     {filetype}
Device: {device}     Inode: {inode}      Links: {nlink}
Access: ({modeord}/{modestr})  Uid: ( {uid} )   Gid: ( {gid} )
Access: {atime}
Modify: {mtime}
Change: {ctime}
 Birth: {btime}"""
dissect.target.tools.fsutils.FALLBACK_LS_COLORS = 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=0...
dissect.target.tools.fsutils.prepare_ls_colors() dict[str, str]

Parse the LS_COLORS environment variable so we can use it later.

dissect.target.tools.fsutils.LS_COLORS
dissect.target.tools.fsutils.fmt_ls_colors(ft: str, name: str) str

Helper method to colorize strings according to LS_COLORS.

dissect.target.tools.fsutils.human_size(bytes: int, units: list[str] = ['', 'K', 'M', 'G', 'T', 'P', 'E']) str

Helper function to return the human readable string representation of bytes.

dissect.target.tools.fsutils.stat_modestr(st: dissect.target.helpers.fsutil.stat_result) str

Helper method for generating a mode string from a numerical mode value.

dissect.target.tools.fsutils.print_extensive_file_stat_listing(stdout: TextIO, name: str, entry: dissect.target.filesystem.FilesystemEntry | None = None, timestamp: datetime.datetime | None = None, human_readable: bool = False) None

Print the file status as a single line.

dissect.target.tools.fsutils.ls_scandir(path: dissect.target.helpers.fsutil.TargetPath, color: bool = False) list[tuple[dissect.target.helpers.fsutil.TargetPath, str]]

List a directory for the given path.

dissect.target.tools.fsutils.print_ls(path: dissect.target.helpers.fsutil.TargetPath, depth: int, stdout: TextIO, long_listing: bool = False, human_readable: bool = False, recursive: bool = False, use_ctime: bool = False, use_atime: bool = False, color: bool = True) None

Print ls output

dissect.target.tools.fsutils.print_stat(path: dissect.target.helpers.fsutil.TargetPath, stdout: TextIO, dereference: bool = False) None

Print file status.

dissect.target.tools.fsutils.print_xattr(basename: str, xattr: list, stdout: TextIO) None

Mimics getfattr -d {file} behaviour.