Tutorial Exercises Week 11

  1. Use the command ls -ila to get the inodes of files in the current directory. Use od -c . and od -D . to examine the contents of the directory as a file - can you identify the filename and inode? What field in the structure stat contains the inode value of a file?
  2. Write a program in C to find the total size of all files in the current directory. Modify it to find the total size of all files in the current directory and in any subdirectories.
  3. What is the parent directory of "/"?
  4. The pair of devices /dev/pty0 and /dev/ttyp0 act as "pseudo terminals". The test isatty("dev/pty0") returns true, so that programs that require an interactive terminal can write to it. Anything written to /dev/tty0 can be read from /dev/ptyp0. Write a C or shell program to write lots of data to /dev/ttyp0 and another to read this data from /dev/ptyp0. email: jan@newmarch.name
    Web: http://jan.newmarch.name/
    Last modified: 10 April 2001