Computer Science, asked by RE285765, 1 year ago

Write system calls functions to the following :

- to start new process

- to get file attributes

- to give permissions to a file

Answers

Answered by AwesomeSoul47
10

Answer:

hey mate here is your answer

The operating system assigns internally to each opened file a descriptor or an identifier (usually this is a positive integer). When opening or creating a new file the system returns a file descriptor to the process that executed the call. Each application has its own file descriptors. By convention, the first three file descriptors are opened at the beginning of each process. The 0 file descriptor identifies the standard input, 1 identifies the standard output and 2 the standard output for errors. The rest of the descriptors are used by the processes when opening an ordinary, pipe or special file, or directories. There are five system calls that generate file descriptors: create, open, fcntl, dup and pipe.

3. System calls when working with files

3.1. System call OPEN

Opening or creating a file can be done using the system call open. The syntax is:

This function returns the file descriptor or in case of an error -1. The number of arguments that this function can have is two or three. The third argument is used only when creating a new file. When we want to open an existing file only two arguments are used. The function returns the smallest available file descriptor. This can be used in the following system calls: read, write, lseek and close. The effective UID or the effective GID of the process that executes the call has to have read/write rights, based on the value of the argument flags. The file pointer is places on the first byte in the file. The argument flags is formed by a bitwise OR operation made on the constants defined in the fcntl.h header.

O_RDONLY

Opens the file for reading.

O_WRONLY

Opens the file for writing.

O_RDWR

The file is opened for reading and writing.

O_APPEND

It writes successively to the end of the file.

O_CREAT

The file is created in case it didn\92t already exist.

O_EXCL

If the file exists and O_CREAT is positioned, calling open will fail.

O_NONBLOCK

Similar questions