コード例 #1
0
def print_mounts(prog_or_ns, src=None, dst=None, fstype=None):
    """
    .. c:function:: print_mounts(struct mnt_namespace *ns, char *src, char *dst, char *fstype)

    Print the mount table of a given namespace. The arguments are the same as
    :func:`for_each_mount()`. The output format is similar to ``/proc/mounts``
    but prints the value of each ``struct mount *``.
    """
    for mnt in for_each_mount(prog_or_ns, src, dst, fstype):
        mnt_src = escape_ascii_string(mount_src(mnt), escape_backslash=True)
        mnt_dst = escape_ascii_string(mount_dst(mnt), escape_backslash=True)
        mnt_fstype = escape_ascii_string(mount_fstype(mnt),
                                         escape_backslash=True)
        print(
            f"{mnt_src} {mnt_dst} {mnt_fstype} ({mnt.type_.type_name()})0x{mnt.value_():x}"
        )
コード例 #2
0
ファイル: block.py プロジェクト: shiloong/drgn
def print_disks(prog: Program) -> None:
    """Print all of the disks in the system."""
    for disk in for_each_disk(prog):
        major = disk.major.value_()
        minor = disk.first_minor.value_()
        name = escape_ascii_string(disk_name(disk), escape_backslash=True)
        print(f"{major}:{minor} {name} ({disk.type_.type_name()})0x{disk.value_():x}")
コード例 #3
0
ファイル: block.py プロジェクト: osandov/drgn
def print_partitions(prog: Program) -> None:
    """Print all of the partitions in the system."""
    for part in for_each_partition(prog):
        devt = part_devt(part).value_()
        name = escape_ascii_string(part_name(part), escape_backslash=True)
        print(
            f"{MAJOR(devt)}:{MINOR(devt)} {name} ({part.type_.type_name()})0x{part.value_():x}"
        )
コード例 #4
0
ファイル: fs.py プロジェクト: osandov/drgn
def print_mounts(
    prog_or_ns: Union[Program, Object],
    src: Optional[Path] = None,
    dst: Optional[Path] = None,
    fstype: Optional[Union[str, bytes]] = None,
) -> None:
    """
    Print the mount table of a given namespace. The arguments are the same as
    :func:`for_each_mount()`. The output format is similar to ``/proc/mounts``
    but prints the value of each ``struct mount *``.
    """
    for mnt in for_each_mount(prog_or_ns, src, dst, fstype):
        mnt_src = escape_ascii_string(mount_src(mnt), escape_backslash=True)
        mnt_dst = escape_ascii_string(mount_dst(mnt), escape_backslash=True)
        mnt_fstype = escape_ascii_string(mount_fstype(mnt),
                                         escape_backslash=True)
        print(
            f"{mnt_src} {mnt_dst} {mnt_fstype} ({mnt.type_.type_name()})0x{mnt.value_():x}"
        )
コード例 #5
0
def print_files(task):
    """
    .. c:function:: print_files(struct task_struct *task)

    Print the open files of a given task.
    """
    for fd, file in for_each_file(task):
        path = d_path(file.f_path)
        if path is None:
            path = file.f_inode.i_sb.s_type.name.string_()
        path = escape_ascii_string(path, escape_backslash=True)
        print(f"{fd} {path} ({file.type_.type_name()})0x{file.value_():x}")
コード例 #6
0
ファイル: fs.py プロジェクト: osandov/drgn
def print_files(task: Object) -> None:
    """
    Print the open files of a given task.

    :param task: ``struct task_struct *``
    """
    for fd, file in for_each_file(task):
        path = d_path(file.f_path)
        escaped_path = escape_ascii_string(path, escape_backslash=True)
        print(
            f"{fd} {escaped_path} ({file.type_.type_name()})0x{file.value_():x}"
        )
コード例 #7
0
def print_slab_caches(prog: Program) -> None:
    """Print the name and ``struct kmem_cache *`` value of all slab caches."""
    for s in for_each_slab_cache(prog):
        name = escape_ascii_string(s.name.string_(), escape_backslash=True)
        print(f"{name} ({s.type_.type_name()})0x{s.value_():x}")