logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

In this project, you must write a C program that performs the system actions

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Description

 

In this project, you must write a C program that performs the system actions – copying or moving a file or a group of files to a specified path. The program acts differently depending on the usage:

 

it performs copying if used as

copy source1 [source2 ...] destination

 

it performs moving if used as

move source1 [source2 ...] destination

 

The source and destination names are full paths, and your program must be able to extract the file or directory base name when needed.

 

When your program performs moving (not copying), it copies a file to the new location then deletes the file (unlinks the old path). Physical coping of all bytes takes time; the more efficient way would be to create a new link (the new path linked to the old bytes on a disk). And I suggest you try this way first, but the OS may not let you do so for several reasons. So then go to the first plan.

 

You may need to study online resources and discuss the project with classmates. But you should not borrow a solution online or from other students. It is better to skip some functionalities than to submit a plagiarized code. Of course, you can always ask your TA and instructor for help.

 

To implement required usage, you need file multiple linking, for example,

 

gcc prog.c -o copy; ln copy move

 

After that, the file with the same executable code can be run under the two different names, and the program itself decides on coping or moving depending on the name that the user used.

 

Keep in mind that there are two types of file links – hard and soft (or symbolic).

 

Hard links (each file must have at least one): Files have names that people use and unique numbers that the OS uses. The unique number (inode + device ID) corresponds to the physical collection of bytes on a disk, and only the kernel manages such a number. File names are created by people. You can give a name then change it. The OS links your name to a physical location of the collection of bytes. Thus, a file name is linked to a unique number. You may have several file names linked to the physical location (why you may need it is another story).

 

Soft links (not a must-have): You may want to link a new file name to the existing file name (not to the physical bytes). For example, to have an alias that you can delete later and not worry about deleting the real file bytes. It is a soft link.

 

Once your program has decided on the required action (copying or moving), it must check the destination:

 

only a directory or device can be the destination for copying more than one file and

only a directory can be the destination for moving more than one file.

An invalid destination must result in the error message and program termination. For this project, you must understand and use the system call stat(). The following information adopted from https://man7.org/linux/man-pages/man7/inode.7.html will be helpful while detecting the file type.

 

The structure stat has the field stat.st_mode that contains the file type and mode. POSIX refers to the stat.st_mode bits corresponding to the mask 01700001 as the file type, the 12 bits corresponding to the mask 07777 as the file mode bits, and the least significant 9 bits (the mask 0777) as the file permission bits.

 

 

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

716 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

558 Answers

Hire Me
expert
Husnain SaeedComputer science

615 Answers

Hire Me
expert
Atharva PatilComputer science

665 Answers

Hire Me