File Input Output Utility Programs

Assignment Help Operating System
Reference no: EM132159787

Lab - File I/O Utility Programs

In this assignment you will create your own versions of:

# ls -l

# find <filename> <starting directory>

# grep <string> <filename>

Each of these programs will exercise different system and standard I/O functions but more importantly they will all work on different aspects of a file system and the differences in different types of files.

# ls -l

The "ls" command will require you to use directory functions to list out what the filenames are in the directory. Functions required to make a "ls" command work are included in the <dirent.h> header file ( man dirent ). You will need to open a directory and iterate through the directory until you hit the end and display the filenames in that current directory.

An example of what you get when you iterate through a directory is a structure like below:

struct dirent {

ino_t d_ino; /* file number of entry */

uint16_t d_reclen; /* length of this record */

uint8_t d_type; /* file type, see below */

uint8_t d_namlen; /* length of string in d_name */

char d_name[255 + 1]; /* name must be no longer than this */ };

NOTE: you have the inode and name of file here....

Now, the requirement for this piece of the lab requires an example of "ls -l" where you display most of the inode information on the file inclusive of:

UID of owner (this will be a number) GID of group (this will be a number) Time of last data modification File Size Blocks allocated for file

Permissions (this is in the mode or protection mode bits, so some bit fiddling is required)

To find this data you will need to use one of the "stat" functions (man 2 stat).. You will get a structure similar to:

struct stat {

dev_t st_dev; /* device inode resides on */

ino_t st_ino; /* inode's number */

mode_t st_mode; /* inode protection mode */

nlink_t st_nlink; /* number or hard links to the file */

uid_t st_uid; /* user-id of owner */

gid_t st_gid; /* group-id of owner */

dev_t st_rdev; /* device type, for special file inode */

struct timespec st_atimespec; /* time of last access */

struct timespec st_mtimespec; /* time of last data modification */

struct timespec st_ctimespec; /* time of last file status change */

off_t st_size; /* file size, in bytes */

quad_t st_blocks; /* blocks allocated for file */

u_long st_blksize; /* optimal file sys I/O ops blocksize */

u_long st_flags; /* user defined flags for file */

u_long st_gen; /* file generation number */ };

# find <filename> <starting directory>

The find command will use the directory (dirent) function calls, but will require you to start at a directory and then determine if a file is a directory or a file and if it is a directory you will need to walk down that directory as well. You will need a method/algorithm to note the new directories and build a logical graph or thread out every directory to find if the filename is in that directory and display the "absolute" path to that file.

NOTE: you will only need to find exact string matches with NO wildcards or regular expression (regex) matches (that is too much for this one ;-)

# grep <string> <filename>

The grep command will take an exact string and an exact filename as the 2 arguments and you will need to search through the filename for the given string and display the "line" and "line number" the string resides in.

Attachment:- Assignment File.rar

Reference no: EM132159787

Questions Cloud

People of color impact racial relations and interactions : How will the increase of multi-racial people and people of color impact racial relations and interactions?
Was it the result of satisficing or intuition : Identify and analyze alternative courses of action-Leaders should seek input from multiple sources to interpret and analyze the problem.
What are the various ethical issues : Non-probability sampling is a sampling technique that researchers can use to effectively collect data. The data is collected from individuals.
Identify minimum of three appropriate work group activities : Identify a minimum of three appropriate work group activities and provide an overview of what is involved in each activity.
File Input Output Utility Programs : Lab - File I/O Utility Programs - n this assignment you will create your own versions of: # ls -l # find and # grep
Wha disorder affect expression and understanding of language : According to Gleason (2016), specialized areas in the cerebral cortex in our brains are responsible for language, and language is the result of a dynamic.
What is assumed about the nature of truth : Discuss the differences between Protagoras's relativism and Socrates's dialectic method in terms of what is assumed about the nature of Truth.
Strong relationship with primary care physician : Why is it important for patients to have a strong relationship with a primary care physician?
Peers by elaborating on how language : In your opinion, Respond to your peers by elaborating on how language, religion, social structure, and education would factor into this interaction.

Reviews

len2159787

11/4/2018 10:16:28 PM

Grading - 20 points will be given for the script file and design document (for all combined). 20 points will be given for C code being written clean, good comments, no crashing, accepting strings from the command line (and null string), etc. Each program will be worth 20 points, broken down into the following criteria: 10 points for functionality and 10 points for command line argument use and usage statement (meaning what do you prompt for with grep and find if the user does not pass the correct parameters, meaning too few, too many or bogus characters) Submission - Please submit your assignment as a single zipped file using tar/zip..etc.. with all of your source, design and script testing file.

Write a Review

Operating System Questions & Answers

  Implementation of algorithms for process management

The Shortest Job Next (SJN) algorithm queues processes in a way that the ones that use the shortest CPU cycle will be selected for running rst.

  Develop a user mode command interpreter

Develop a user mode command interpreter which support list-short.

  Memory allocation in operating system

Analysis and implementation of algorithms for memory allocation in operating system, Explain First- t and best- t methods are used in memory allocation in operating systems.

  Stand alone child process

Forking the child process

  Write a multi-threaded program

Write a multi-threaded program to solve producer and consumer problem

  Marginal and average cost curves

n a competitive market place (pure competition) is it possible to continually sell your product at a price above the average cost of production.

  Simulating operating systems scheduling

Simulate the long-term scheduler, the short-term scheduler and the I/O scheduler of the computer using the First-Come-First-Serve algorithm.

  Issues with trusted platform module

Research paper discussing the issues with Trusted Platform Module (TPM)

  Threads

Explain a complication that concurrent processing adds to an operating system.

  Design and programming

Use the semaphore methods to control the concurrency of the solution

  Virtual machines

Virtual machines supported by a host operating system

  Discuss an application that benefits barrier synchronization

Discuss an application that would benefit from the use of barrier synchronization

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd