 Hello everyone, today I am going to discuss on the topic system cause for the file system part 1. At the end of this session, students will be able to describe the concept of system cause in operating system, explain file structure related system cause. Let us see what a system call is. A system call is a request for the operating system to do something on behalf of the user's program. The system calls are functions used in the kernel itself. To the programmer, the system call appears as a normal C function call. However, since a system call executes code in the kernel. Unique system calls are used to manage the file system, control processes and to provide inter-process communication. Here we have a different system calls, first file structure related system calls, process related system calls and inter-process communication. The file structure related system calls available in the unique system will let you create open and closed files, read and write files, remove files, get information about files, check the accessibility of files, change protection of the files, change owner of the files and change group of the files and as well as it control devices. The process related system calls in Unix include fork, execute, wait and exit system calls. Using execute and executable binary file can be converted into a process. Inter-process communication is a set of programming interface that allow a programmer to coordinate activities among different program processes that can run concurrently in an operating system. Inter-process can communicate with each other using shared memory concept. Let us begin a file structure related calls open. Here open system call is used to create a file or device. The prototype of this open system call is integer, open, file name, option flags and more. Here, file name is a pointer to the character stream that names the file. Option flags represent the type of the channel and more defines the files access permissions if the file is being created. This function returns the file descriptor if successful or in case of an error it will return minus 1. File structure related system calls have allowable option flags which are define O, RD only, open the file for reading only, define O, WR only, open the file for writing only, define O, RD, WR open the file for both reading and writing. Now we will see a small program using open system call. Here the file name is open.c. In the open.c file we are included 3 header files strio.h, fcindial.h and unistri.h. These files are required for creating file system. Here open system call is using for file system. This open system call is used for 2 file descriptor that is called integer fd1 and fd2. fd1 is a file descriptor assigned for txt1.txt, fd2 is file descriptor assigned for txt.txt. Here open system call contains txt1.txt, this side exists then it is only in read only mode. If does not exist then it is open in the create mode by assigning a mode as 0777. In the next again open system call file name is txt2.txt, if it exists it will open in read only mode, if does not exist it will create a file by assigning a mode of 0777. So here we are using the while loop for generating this loop for generating the file descriptor for these 2 file system that is fd1, txt1.txt and fd2 for txt2.txt. Now we will run this program by typing gcc-o open.c, it will create a file descriptor 3 and 3132 which is highlighted by red mark 3132 by executing the command dot slash open. Again we type the ls command it will show the 3132 here it is in the directory again we go to the directory as 3132 again type ls it will show you are all the file names with the fd here mark as fd we go to the cd fd then press ls we show the 01234 for standard input 1 is for standard output 2 is for standard error and these are all the files which are written in the file descriptor by kernel that is txt2.txt and txt1.txt. Now we will see a file structure related calls read and write what the read does read does all the input and write does all the output whenever we create a file the kernel checks whether the file is exist or not if it exist it will open the file in the read only mode and if does not exist it will create the file and assign the file modes after reading the file the user wants to write something into the file or user wants to modify something into the file so the write system call we are using for that what the write system call does it does all the output means whatever the user writes into the file it all gets saved to the hard disk or to the kernel hard disk. So the prototypes for these two read and write system calls are read of type integer it includes file descriptor buffer pointer transfer size where file descriptor is written by the kernel system buffer pointer is the place where the data are stored transfer size is the number of bytes which are transferred for the reading similarly write operation of type integer which includes file descriptor return by the kernel buffer pointer the place where the data store and transfer size number of bytes transferred from the file after saving to the hard disk for that we are using write system call. After studying all these things we have a question pause the video for some time see the question straight to and false a system call is a routine build into the kernel and perform a basic function yes the answer is true because in the beginning we have already discussed that system call is the name implies by the kernel to do something in the operating system. So that is why it is a built-in routine which is into the kernel and performs a basic function for the user for the group and for the owner. So that is why the answer is true again we go for file and record locking. So file locking and record locking these two things are for processing the file as well as processing the record done by the kernel in the file locking capability to prevent other processes from reading or writing any part of an entire file. So no other processes can enter into the file for reading and writing for that kernel locks the file so that the user can read at most one file at a time and in the record locking system it is capability of prevent other processes from reading or writing a particular record into the file when the user writes a particular record into the file in that case no other process interfere for reading and writing particular records for that record locking is done by the kernel system itself. Now we go for adjusting the position of the file during input operation by using lc command. So the syntax for lc system call is position equal to lc file descriptor fd offset at reference where fd is the file descriptor identifying the file offset byte offset reference indicates offset should be beginning from the current position of the read write offset and from end of the file. So when we use lc command for searching a particular things when file descriptor should be known by the kernel then kernel sends the offset for the file system and then indicates where the offset should be beginning from the current position of the read write offset or from the end of the file. Here a small program based on lc which shows the adjusting position of the file input output. Here we included two header files strayout.h fcntl.h for opening the file and writing the file. So here we have declared local variable file descriptor position of type long. Here we are using open file name data file dot that which is in the read only mode means if the file exist it will open in the read only mode and immediately kernel will assign the file descriptor to fd. If the fd equal to minus 1 then it will returns lc error. If the file exist and it will open in the read only mode then the file sets the position by using lc command having file descriptor 0l and 2 that is the bytes offset and as well as the transfer size. If position not equal to minus 1 then it will give can't open data file dot data and if the position finds then it will define the length of the data file in the form of bytes and assigns the position of that file. Then we go for the close file system call which is a file structure related. The structure for close system call is close file descriptor file descriptor for the open file. The same file descriptor is here using for closing a file. Then file creation so here we are using system call create for the file creation in the unix file system. For that the syntax is fd is equal to create creat path names comma mode where path names, modes and fd means the same as they were operated in the open system call that is path name is described in the form of relative path name or absolute path name and modes are described in the form of symbolic mode or numeric mode. Suppose user wants to create some special files in the kernel or in the unix file system the kernel provides a special file creation of special files that is mk node mk node system call is used to create a special file in the kernel system which includes named a pipes, device files and directories. The syntax for mk node is path name of type relative or absolute type and permissions and device name or device files. For all these contents we refer these books. Thank you.