Unit3 - Subjective Questions

CSE325 • Practice Questions with Detailed Answers

1

Define the open() system call in Linux. Explain its syntax and common flags used.

2

Explain the read() system call with its prototype and return values.

3

Describe the write() system call. How does it differ from library functions like printf or fprintf?

4

What is the purpose of the close() system call? What happens if a process fails to close a file?

5

Explain the lseek() system call. Discuss the significance of the whence parameter.

6

Write a C program using system calls to copy the contents of one file to another. The file names should be provided as command-line arguments.

7

What are File Descriptors? Which file descriptors are opened by default for a process?

8

Explain the concept of File Holes (Sparse Files) and how lseek is used to create them.

9

Differentiate between O_APPEND and using lseek to the end of a file before writing. Why is O_APPEND preferred in concurrent environments?

10

What is the role of the mode argument in the open system call? Give an example of setting permissions to rw-r--r--.

11

Write a C program snippet to read the last 10 bytes of a file using lseek and read.

12

Explain the error handling mechanism for file system calls. How is errno used?

13

Explain the relationship between the File Descriptor Table, the File Table, and the Inode Table.

14

How can a program create a file that ensures it fails if the file already exists? Which flag combination is used?

15

What does the O_TRUNC flag do when used with the open system call?

16

Write a C program that writes the string "Hello OS" to the Standard Output (screen) using the write() system call instead of printf.

17

Explain the behavior of read() when the requested number of bytes (count) is larger than the actual bytes remaining in the file.

18

What is the maximum number of files a process can open? How can this limit be checked or changed?

19

Compare Buffered I/O vs Unbuffered I/O in the context of file system calls.

20

Describe the logic to determine the size of a file using lseek.