Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Introduction In this assignment, you will practice using system calls to access the filesystem, navigate the directory structure, and parse file stats. Learning Outcomes Describe
Introduction
In this assignment, you will practice using system calls to access the filesystem, navigate the directory structure, and parse file stats.
Learning Outcomes
Describe the API for different operations related to files Module MLO
Describe the API for different operations related to directories Module MLO
How to define and use structures in CModule MLO
Specifications
NAME
tree recursively list files and directories
SYNOPSIS
tree OPTIONDIRECTORY
DESCRIPTION
Recursively list all files found in DIRECTORYs. If no DIRECTORY is provided, the current directory is used.
By default, output is sorted alphabetically.
LISTING OPTIONS
a Print hidden files. By default, tree does not print hidden files beginning with a dot character.
The filesystem constructs and are never printed even with the a option.
d Print only directories, no files.
FILE OPTIONS
p Print permissions according to the mode string format specified for ls according to POSIX.
u Print the username, or UID # if no username is available, of the file.
g Print the group name, or GID # if no group name is available, of the file.
s Print the size of each file in bytes.
SORTING OPTIONS default: alphabetic sorting
r Sort the output in reverse alphabetic order.
t Sort the output by last modification time instead of alphabetically.
U Do not sort. List files according to directory order.
h Print this message
AUTHOR
You, again!
NOTES
Source code must compile without errors againt the c standard on os to receive ANY credit. Example:
gcc stdc
Source code must compile without errors for FULL credit, with the following flags:
gcc stdcWall Wextra Wpedantic Werror
Detailed instructions
In this assignment, you will write a small library that parses files and directory structures to list files and directory contents recursively in a tree format, where each subdirectory is indented from the last. You will implement basic sorting and print the file permissions, username, group, and file size.
Example output
$tree pugs usrsharemanen
drwxrxrx root root usrsharemanen
drwxrxrx root root man
rwrr root root closegz
rwrr root root getdomainnamegz
rwrr root root getrlimitgz
rwrr root root madvisegz
rwrr root root mountgz
rwrr root root sysinfogz
rwrr root root umaskgz
drwxrxrx root root man
rwrr root root encryptgz
rwrr root root fclosegz
rwrr root root fflushgz
rwrr root root lockfgz
rwrr root root randgz
rwrr root root strtokgz
rwrr root root touppergz
rwrr root root updwtmpgz
drwxrxrx root root man
rwrr root root stgz
drwxrxrx root root man
rwrr root root utmpgz
drwxrxrx root root man
rwrr root root environgz
rwrr root root hiergz
rwrr root root suffixesgz
Guidance
In this assignment, you will be working with two source files, one of which will produce a library shared object and the other which acts as a testbench to model a third party using your library.
What is a shared library? It's just a collection of symbol definitions functions objects that are packaged into a shared object so file format. If your program is linked against a shared library, any symbols that you use, which are part of that library, will have undefined values when your program starts. A program called the loader comes along during the initialization process before main is called and it loads the shared library into memory, and the linker updates the table of symbols to point to the appropriate locations in that library. This is actually how all of the functions and symbols you use from the standard C library work. If your program calls printf, the libc.so file is loaded into your program's virtual memory space, and the printf symbol is resolved at runtime by the linker.
Shared libraries are really useful. For one, since they contain mostly readonly information function instructions, constants shared libraries can be well, shared. There is one copy of the shared library in memory, and every program that is using it simply has it mapped into each of their private virtual memory address spaces. From the perspective of the program, it's the only one using that library. From the perspective of the kernel, it just save a bunch of memory! It also means your program is a lot smaller, since the instructions and data for common things are actually stored already in the system, separate f
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started