Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Erica Thompson #195

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ type `make` in the `examples/` directory.) It should print `Testing: PASS`.
## Challenge 1

Name at least three things that an operating system is responsible for handling?
- Abstracting complexities from the user
- Managing resources like processors, memory, data storage and I/O devices.
- Sharing I/O between programs using CPU.

## Challenge 2

Expand Down
Binary file added examples/commandline
Binary file not shown.
5 changes: 4 additions & 1 deletion examples/commandline.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
* Try running with various command line args:
*
* ./commandline hello world
// 3 cmdline args
* ./commandline this is a test
// 5 cmdline args
* ./commandline
*/
// 1 cmdline arg
*/

#include <stdio.h>

Expand Down
Binary file added examples/testdir
Binary file not shown.
Binary file added lsls/lsls
Binary file not shown.
23 changes: 22 additions & 1 deletion lsls/lsls.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,33 @@
int main(int argc, char **argv)
{
// Parse command line

{
int count;
for (count=0; count<argc; count++)
puts (argv[count]);
}
// Open directory

DIR *pDir = opendir (argv[1]);
struct dirent *pDirent;

if (argc < 2) {
pDir = opendir(".");
}
if (pDir == NULL){
printf("invalid directory: %s\n", argv[1]);
return 1;
}

// Repeatly read and print entries


while ((pDirent = readdir(pDir)) != NULL) {
printf ("[%s]\n", pDirent->d_name);
}

// Close directory
closedir (pDir);

return 0;
}