Create a C program

Create a C program that behaves like ls -al

If an argument is provided, it can be either a file name or a directory name. If the argument is a directory name, you will list all files/directories inside it. Otherwise, you only list the corresponding file.

Note that “.” or “..” are directories as well and therefore your program should work for them too.

If an argument is not provided your program will list the working directory (same as “.”).

In order to retrieve and inspect the file information, you need to carefully study the inode's manual.

Only list the regular files and directories. Skip other types such as links, etc. See inode for how to test the file type.

Your output must be exactly the same as in ls. Therefore, you can use diff as you have seen in previous test scripts to fully test your program before submission. This is of course true for directories that contain regular files and directories only. For example, your output would not list a symlink while ls does.

Make sure that you also replicate the behavior of