Operating Systems 2019F: Assignment 3

From Soma-notes
Jump to navigation Jump to search

Please submit the answers to the following questions via CULearn by 11:55 PM on Sunday, November 24, 2019. There are 20 points in 10 questions.

Submit your answers as a single text file named "<username>-comp3000-assign3.txt" (where username is your MyCarletonOne username). The first four lines of this file should be "COMP 3000 Assignment 3", your name, student number, and the date of submission. You may wish to format your answers in Markdown to improve their appearance.

No other formats will be accepted. Submitting in another format will likely result in your assignment not being graded and you receiving no marks for this assignment. In particular do not submit an MS Word or OpenOffice file as your answers document!

Don't forget to include what outside resources you used to complete each of your answers, including other students, man pages, and web resources. You do not need to list help from the instructor, TA, or information found in the textbook.

Please make your best effort to do a proper implementation where required. There will be times where you may be tempted to copy large portions of code from other parts of the kernel. While you may have to copy a small number of lines, avoid duplicating significant functionality.

Questions

  1. [1] How can you change the inode associated with a regular file? Specifically, what commands can you run that will result in a file that has exactly the same name as before but has a different inode? Please give the commands and explain what each does.
  2. [1] Does a "hole" in a UNIX file affect its logical size? What about its physical size? Explain briefly.
  3. [1] To setup key-based login using ssh, what file do you have to create or change on the remote system? What do you put in it?
  4. [2] What is the difference in behavior between "dd bs=1024 count=10" and "dd bs=2048 count=5" when run in a terminal? Why is there this difference? (You may want to use strace.)
  5. [2] How do you recover an ext4 filesystem using a backup superblock? Show your answer is correct by creating a filesystem, erasing its primary superblock (only), and then recovering the filesystem using a backup superblock.
  6. [2] How could you erase all superblocks (inculding backups) in an ext4 filesystem? Specifically, how could you find them all, and what command could you use to erase each of them (and nothing else)?
  7. [2] When you specify the -a (archive) flag to rsync, it is equivalent to the flags -rlptgoD. Why are each of these flags important to "archiving"? What are two ways that a copy produced with just "-a" won't be an exact copy?
  8. [2] What is one advantage of using key-based logins with ssh? What is one disadvantage?
  9. [2] Can you open a file if you only know its inode number? How does this help explain how inode numbers shown in sshfs don't correspond to the inode numbers on the remote system?
  10. [5] What trace command could you use to do each of the following? Explain each part of the command you give. Hint: you may want to look at the System.map for your kernel in /boot, it has the symbols defined by the current kernel.
    1. Report every time the chdir system call was made along with the directory that was changed to.
    2. Report every time a specific bash process does a write system call.
    3. Report what userspace function called the write system call to a specific bash process
    4. Report every 64-bit call to the clone system call (or every call to clone)
    5. Report every 64-bit call to the execve system call (or every call to execve), reporting the program that was executed.

Solutions

Assignment 3 solutions