Skip to main content

Section 5.3 Files and Directories

Start by reading the Files and Directories chapter, section 39.1. This section discusses the two key abstractions of files and directories.

Practice 5.3.1.

Read sections 39.2 and 39.3, about the interface for creating files.

Practice 5.3.2.

A file descriptor is a:
  • integer
  • string
  • complex object
  • a pointer
  • none of the above
Read sections 39.4, 39.5 about reading from and writing to files.

Practice 5.3.3.

Practice 5.3.4.

Which of the following calls to lseek will position us at the end of the file, so that any subsequent write simply appends to the end?
  • lseek(fd, 0, SEEK_END)
  • lseek(fd, SEEK_END)
  • lseek(fd, 0, SEEK_CUR)
  • lseek(fd, -1, SEEK_SET)

Practice 5.3.5.

    True or False: If a file is opened via two different file descriptors, both descriptors use the same offset into the file.
  • True.

  • False.

Read section 39.6 about the fork and dup calls and how they affect file descriptors.
Skim sections 39.7-39.10.
Read sections 39.11-39.13 about working with directories.

Practice 5.3.6.

    True or False: In order to read a directory we use the same calls as those used for reading files.
  • True.

  • False.

Read sections 39.14, 39.15, about "hard links" and "symbolic links".
Skim through the remaining sections.
You have attempted of activities on this page.