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_string(mount_src(mnt), escape_backslash=True) mnt_dst = escape_string(mount_dst(mnt), escape_backslash=True) mnt_fstype = escape_string(mount_fstype(mnt), escape_backslash=True) print( f'{mnt_src} {mnt_dst} {mnt_fstype} ({mnt.type_.type_name()})0x{mnt.value_():x}' )
def print_disks(prog): """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_string(disk_name(disk), escape_backslash=True) print(f'{major}:{minor} {name} ({disk.type_.type_name()})0x{disk.value_():x}')
def print_partitions(prog): """Print all of the partitions in the system.""" for part in for_each_partition(prog): devt = part_devt(part).value_() name = escape_string(part_name(part), escape_backslash=True) print( f'{MAJOR(devt)}:{MINOR(devt)} {name} ({part.type_.type_name()})0x{part.value_():x}' )
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_string(path, escape_backslash=True) print(f'{fd} {path} ({file.type_.type_name()})0x{file.value_():x}')