Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 3 MCQs File system management

CSE325 — Operating Systems Laboratory 50 questions. Pick an option to check it.

Read the notes Subjective questions

0 of 50 answered 0 right 0 wrong , 50 left

  1. Question 1 of 50

    Which header file is primarily required to use the open system call in a C program on a UNIX-like system?

  2. Question 2 of 50

    What is the return type of the open() system call?

  3. Question 3 of 50

    If the open() system call fails, what value does it return?

  4. Question 4 of 50

    Which header file defines the read, write, close, and lseek system calls?

  5. Question 5 of 50

    What is the integer value of the file descriptor representing Standard Input (stdin)?

  6. Question 6 of 50

    Which flag is used with open() to open a file for reading only?

  7. Question 7 of 50

    Which flag must be included in open() to create the file if it does not exist?

  8. Question 8 of 50

    What does the read() system call return upon successfully reading data?

  9. Question 9 of 50

    What is the return value of read() when the end of the file (EOF) is reached?

  10. Question 10 of 50

    Consider the syntax: ssize_t write(int fd, const void *buf, size_t count);. What does buf represent?

  11. Question 11 of 50

    Which open flag ensures that data is always written to the end of the file?

  12. Question 12 of 50

    What is the primary purpose of the lseek system call?

  13. Question 13 of 50

    In the call lseek(fd, offset, whence), what does SEEK_SET indicate for the whence parameter?

  14. Question 14 of 50

    Which lseek mode allows setting the offset relative to the current file position?

  15. Question 15 of 50

    What is the return type of lseek()?

  16. Question 16 of 50

    How can you use lseek to find the total size of a file?

  17. Question 17 of 50

    What happens if lseek is called on a file descriptor referring to a pipe or socket?

  18. Question 18 of 50

    What is the correct prototype for the close system call?

  19. Question 19 of 50

    Why is it important to use close() on file descriptors when they are no longer needed?

  20. Question 20 of 50

    When open() is called with O_TRUNC and the file already exists, what happens?

  21. Question 21 of 50

    The third argument of open(), typically called mode, is mandatory only when:

  22. Question 22 of 50

    Which system call corresponds to the Standard C Library function fprintf?

  23. Question 23 of 50

    What is the value of fd if fd = open("file.txt", O_RDONLY) is the first file opened by a process (excluding standard streams)?

  24. Question 24 of 50

    Which data type is ssize_t (returned by read and write)?

  25. Question 25 of 50

    What happens if you invoke write(fd, buf, count) where fd was opened with O_RDONLY?

  26. Question 26 of 50

    Using lseek, how would you create a "hole" in a file?

  27. Question 27 of 50

    In the argument list for write(int fd, const void *buf, size_t count), what does count signify?

  28. Question 28 of 50

    Which header contains the permission bit macros like S_IRUSR, S_IWUSR used in open()?

  29. Question 29 of 50

    What does lseek(fd, -10, SEEK_CUR) do?

  30. Question 30 of 50

    If open is used with O_EXCL and O_CREAT, what happens if the file already exists?

  31. Question 31 of 50

    What is the file descriptor for Standard Output (stdout)?

  32. Question 32 of 50

    Which system call is used to duplicate a file descriptor?

  33. Question 33 of 50

    What happens to the file offset after a successful read() operation?

  34. Question 34 of 50

    Which of the following is NOT a valid mode for open()?

  35. Question 35 of 50

    What is the return value of close(fd) if fd is not a valid open file descriptor?

  36. Question 36 of 50

    Which type matches the count argument in read and write?

  37. Question 37 of 50

    Which macro sets the file permission to rw-r--r-- (User read/write, Group read, Others read) in octal?

  38. Question 38 of 50

    If read(fd, buf, 100) returns 50, what does this imply?

  39. Question 39 of 50

    What is the equivalent of lseek(fd, 0, SEEK_SET) using standard C library functions?

  40. Question 40 of 50

    Can open() typically open a directory for reading?

  41. Question 41 of 50

    What happens if you attempt to lseek to a negative resulting absolute offset?

  42. Question 42 of 50

    The global variable used to identify the specific error code after a system call fails is:

  43. Question 43 of 50

    Which function is often used to print a human-readable error message describing the last error encountered?

  44. Question 44 of 50

    If a process calls fork(), what happens to open file descriptors?

  45. Question 45 of 50

    What is the maximum number of bytes read can theoretically request?

  46. Question 46 of 50

    Which of these pairs represents the correct types for the arguments of lseek?

  47. Question 47 of 50

    If fd is closed, and you call close(fd) again, what happens?

  48. Question 48 of 50

    How does open distinguish between text and binary files in UNIX/Linux?

  49. Question 49 of 50

    What is the effect of O_SYNC flag in open?

  50. Question 50 of 50

    Which buffer pointer type is used in the read prototype ssize_t read(int fd, void *buf, size_t count)?

That's unit 3

Answer a few questions and your score shows up here.