You are on page 1of 11

BARIRA AKBAR

BSE IVA
Operating System
LAB 10
SUBMITTED TO
Mr. Muhammad Shahzad
DEPARTMENT OF SOFTWARE
ENGINEERING
FATIMA JINNAH WOMEN UNIVERSITY
Department of software engineering

LAB 10

Task 1:
Create a file named “oslab.txt” present in directory named “os” located in home directory.

Task 2 a:
Open a file for reading named “oslab.txt” present in directory named “os” located in
home directory.
TASK 2b:

Open a new file for reading and writing, whose location is provided user.
Task 3a:

Read at most 100 bytes into buffer from standard input.


TASK 3b:

Read bytes into temporary buffer buf from file whose location and name is entered by the  user
as an argument at the time of execution.
Task 4:
Write “read” and “write” commands for the following conditions

Read data from standard input and write it on standard output.

Read data from the file, given as an argument by the user and write it on standard output. Start
reading from the end of file.
Read data from standard input and write it on the file given as an argument by the user.
Read and write data from the files named “lab3.c” and “lab4.c” respectively. The files
are present in the directory “lab”, located in the home directory.
Task 5:
Write complete code to copy the contents of an input file to an output file using system calls
where the input and output files names are entered by the user.
Task 6:

What is the purpose of link and unlink system call.

Link System Call: Unlink System Call:

Link () adds a new connection also called The command-line utility unlink is used to
hard link) to an already existing file. remove a single file.
This new name will be used in the same way The unlink command has the following
as the old one for any operation; all names syntax: filename should be unlinked.
belong to the same file (and hence have the Whereas, filename is name of file to be
same permissions and ownership), and it's deleted. If the order is effective, it produces
hard to say which was the first. If the file no output and returns nothing.
name was the last hard connection to the file,
the file is removed as soon as no application
opens it.

THE END

You might also like