Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Operating System Expert

Unix System Calls and Library Functions

The goal of this homework is to become familiar with the environment in hoare while practising system calls. 

Do Exercise 5.8:Traversing Directories (p. 179) in your text by Robbins/Robbins. You only need to do the Example 5.38, or

breadth-first traversal.

The programming task requires you to create a utility to traverse a specified directory in breadth-first order. Breadth-first search

explores all the nodes at a given level before descending lower in the tree. Breadth-first search is implemented with a queue.

As the program encounters each directory node at a particular level, it enqueues the pathname for later examination. You can

use the following pseudocode which makes use of queue ADT. You will have to provide the code for queue ADT operations

yourself.

breadthfirst ( root )

{

enqueue ( root );

while ( ! empty ( queue ) )

{

next = dequeue ( queue );

for each node directly below next

{

visit ( node );

if ( isa_directory ( node ) )

enqueue ( node );

}

}

}

The indentation of the filenames shows the level in the file system tree. Use the output format specified in Example 5.37, with

a default indentation of 4 spaces for each level in the directory. You should be able to change the indentation spaces by using

an option on command line followed by a number. The executable should be called bt. The program will be invoked by:

bt [-h] [-L -d -g -i -p -s -t -u -In | -l] [dirname]

The options are to be interpreted as follows:

h Print a help message and exit.

L Follow symbolic links, if any. Default will be to not follow symbolic links.

t Print information on file type.

p Print permission bits as rwxrwxrwx.

i Print the number of links to file in inode table.

I n Indent by n spaces.

Unix System Calls 2

u Print the UID associated with the file.

g Print the GID associated with the file.

s Print the size of file in bytes. If the size is larger than 1K, indicate the size in KB with a suffix K; if the size is larger than

1M, indicate the size in MB with a suffix M; if the size is larger than 1G, indicate the size in GB with a suffix G.

d Show the time of last modification.

l This option will be used to print information on the file as if the options tpiugs are all specified.

If the user does not specify dirname, run the command using current directory and print the tree accordingly. The output will

appear as follows:

$ ls -I 4 -l proj

proj drwx------ 10 sanjiv faculty 4K Nov 25, 2003

bi_scan drwx------ 3 sanjiv faculty 4K Jul 06, 2004

include drwx------ 3 sanjiv faculty 4K Nov 25, 2003

CVS drwx------ 2 sanjiv faculty 4K Nov 25, 2003

Makefile -rw------- 1 sanjiv faculty 712 Nov 25, 2003

Makefile.Linux -rw------- 1 sanjiv faculty 1K Nov 25, 2003

CVS drwx------ 2 sanjiv faculty 4K Nov 25, 2003

cluster.h -rw------- 1 sanjiv faculty 5K Nov 25, 2003

config.h -rw-r--r-- 1 sanjiv faculty 5K Jan 22, 2004

Entries -rw------- 1 sanjiv faculty 336 Nov 25, 2003

Repository -rw------- 1 sanjiv faculty 24 Nov 25, 2003

Root -rw------- 1 sanjiv faculty 15 Nov 25, 2003

Entries -rw------- 1 sanjiv faculty 650 Nov 25, 2003

Repository -rw------- 1 sanjiv faculty 24 Nov 25, 2003

Root -rw------- 1 sanjiv faculty 15 Nov 25, 2003

With the use of perror, I’ll like some meaningful error messages. The format for error messages should be:

bt: Error: Detailed error message

where bt is actually the name of the executable (argv[0]) and should be appropriately modified if the name of executable is

changed without recompilation.

What to handin

Create your programs in a directory called username.1 where username is your user name on hoare. Once you are done with

everything, remove the executables and object files, and issue the following commands:

% cd

% ˜sanjiv/bin/handin cs4760 1

Do not forget Makefile (with suffix or pattern rules), RCS and README for the assignment. If you do not use RCS, you will

lose 10 points. I want to see the log of how the program files are modified. Therefore, you should use keyword substitution

within RCS inside your source files. 

Operating System, Computer Science

  • Category:- Operating System
  • Reference No.:- M9740815
  • Price:- $60

Priced at Now at $60, Verified Solution

Have any Question?


Related Questions in Operating System

State the required answer precisely and then provide proper

State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. Briefly describe the following concepts and indicate how they are related in the context ...

Research types of operating systems that are currently

Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Explain why you think the choice you made ...

Question students working at individual pcs in a computer

Question : Students working at individual PC's in a computer laboratory send their files to be printed by a server that spools the files on its hard disk. Under what conditions may a deadlock occur if the disk space for ...

Question state the required answer precisely and then

Question : State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. What is the purpose of the command interpreter? Why is it usually separate fr ...

Catalog course descriptionin this course students carry out

Catalog Course Description In this course students carry out independent research in a significant technical area of information, network, and computer security. The student is to investigate a technical area, research i ...

Foundation of information technologyresearch types of

Foundation of Information Technology Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Expl ...

Taskyour job in this assignment is to create two virtual

Task Your job in this assignment is to create two Virtual machines each running a different but the latest distribution of Linux e.g. Ubuntu Server and CentOS. Each of these VM's is to offer services to a user base. The ...

Assignment -building a multi-threaded web server using c

Assignment - Building a multi-threaded web server using C and p threads, following the model from the lecture. Your program will have one thread acting as a dispatcher thread, listening fornetwork connections with reques ...

Question 1answer the following questions 10 marks a

Question 1 Answer the following questions: 10 marks a. Consider the following page reference string: 3, 1, 4, 1, 2, 3, 5, 3, 2, 1, 2,5, 4, 3, 5, 2, 4,2, 5,3 Using the above page reference string display the contents of t ...

Question you are a security administrator responsible for

Question: You are a security administrator responsible for providing secure configuration requirements for new laptop deployments. After reading Module 2 of Certified Secure Computer User v2exercises, apply the configura ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As