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

  Write the start-up steps in windows nt

Write the start-up steps in Windows NT. Provide estimate for the capital investment needed in computer forensics for a 2,000,000 population.

  How dlxos processes using round-robin preemptive scheduler

Describe in detail how DLXOS schedules processes using the round-robin preemptive scheduler and the preliminary design of your WinNT scheduler.

  Question about data communications

A 4480 octet datagram is to be transmitted and requires to be fragmented because it will pass through an Ethernet with a maximum payload of 1500 octets.

  Discuss five computer forensics tools

Use Library and internet resources to analyze five computer forensics tools. For each tool, list the vendor and its functions.

  Ext4 file systems on linux vs. ntfs file systems

List what characters are absolutely not allowed for ext4 file systems on Linux vs. NTFS file systems on Windows in a plain text document.

  Compare android and the linux operating systems

Compare and contrast Android and the Linux operating systems. Compare and contrast the Android and Windows operating systems

  Expansion of network services

Assume you have been hired through your local library to help them setup a LAN to connect their three library sites.

  Compute number of disk tracks traversed by using fcfs-sstf

Compute number of disk tracks traversed by using FCFS, SSTF, SCAN, and LOOK algorithms for series of disk track service request given below.

  The user enters the email address, home address and password

Upon completion of payment, the system arranges delivery of the ordered books. An external shipping agent is responsible for the delivery of the ordered books. If an order involves new books, the system sends a shipping request to notify the shipp..

  As computers have evolved the complexity of operating

write 400-600 words that respond to the following questions with your thoughts ideas and comments. this will be the

  What are the four conditions that create deadlock

What are the four conditions that create deadlock? Explain how spinlocks are used for protecting a critical section in Linux?

  Write the send and receive primitives for stated processes

Write the send and receive primitives for stated processes and processes can communicate with each other by name along with message. You need to Identify what type of IPC is this?

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