## ls

#### OS/161 Reference Manual

### Name

ls - list files or directory contents

### Synopsis

`/bin/ls` [`-adlRs`] [path...]

### Description

`ls` lists the filesystem objects specified on the command line. If they are directories, the contents of the directories are listed (unless the `-d` option is used).

If the `-a` option is given, filenames beginning with dot (.) will be listed. Ordinarily, they are skipped.

If the `-d` option is given, directory contents will not be listed; the directories themselves will be.

If the `-l` option is given, a long format listing showing the file size, type, and link count will be displayed instead of just the filenames.

If the `-R` option is given, subdirectories encountered will be listed recursively.

If the `-s` option is given, the number of filesystem blocks used by each object will be displayed in addition to other information.

If no paths are specified, the current directory is assumed.

### Requirements

`ls` uses the following syscalls:

- open
- write
- fstat
- getdirentry
- close
- _exit

As fstat and getdirentry are generally not part of the basic system calls assignment, `ls` will usually still not function after the basic system calls assignment is complete. These calls are typically part of a later assignment, usually the file system assignment. You may also need to implement the getdirentry functionality at the file system level. Consult your course materials for specific information.