1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:57:35 +00:00

Utilities: Add the listdir utility

This utility uses the Core::DirIterator facility which in turn uses the
get_dir_entries syscall. Therefore, this utility lets us to view the
actual values for inode numbers, and entry type value for directory
entries.
This commit is contained in:
Liav A 2024-01-05 12:30:26 +02:00 committed by Andrew Kaster
parent 603516e8c0
commit fc0dbd2334
2 changed files with 109 additions and 0 deletions

View file

@ -0,0 +1,43 @@
## Name
lsdir - list directory entries
## Synopsis
```**sh
# lsdir [options...] [path...]
```
## Description
This utility will list all directory entries of a given path (or list of paths)
and print their inode number and file type (in either POSIX DT_* format or human readable).
The utility uses `LibCore` `DirIterator` object and restrict its functionality
to the `get_dir_entries` syscall only, to get the raw values of each directory
entry.
## Options
* `-P`, `--posix-names`: Show POSIX names for file types
* `-t`, `--total-entries-count`: Print count of listed entries when traversing a directory
## Arguments
* `path`: Directory to list
## Examples
```sh
# List directory entries of working directory
$ lsdir
# List directory entries of /proc directory
$ lsdir /proc
# List directory entries of /proc directory with POSIX names for file types
$ lsdir -P /proc
# List directory entries of /proc directory and print in the end the count of traversed entries
$ lsdir -t /proc
```
## See also
* [`ls`(1)](help://man/1/ls)