COMP 3000 Lab 4 2012

From Soma-notes
Revision as of 12:56, 15 October 2012 by Soma (talk | contribs) (Created page with "'''This lab is not yet finalized.''' A few guidelines: * Submit your solutions for both Part A and Part B via cuLearn by Friday, October 19th at 11:55 pm. * Please answer using …")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This lab is not yet finalized.

A few guidelines:

  • Submit your solutions for both Part A and Part B via cuLearn by Friday, October 19th at 11:55 pm.
  • Please answer using a single text file (with a .txt extension). Do not submit doc, docx, pdf, or other formats. Also, please do not submit an archive (zip, tarball, rar) of multiple text files, just upload one. Anything other than a single text file will receive no credit.
  • Show all your work. Short answers are not sufficient; you should list any websites or individuals you consult and should document any experiments you conducted. For any question that you could just answer without any external reference or experiment, write "(no work required)" after your answer.
  • All submitted code and commands should compile and run. Partial code fragments or explanations may not be given credit. While code may use standard C and UNIX/Linux libraries, no code should rely on external binaries.
  • The exercises in this lab require root access on a Linux system. Note that an Ubuntu Live CD should be a sufficiently powerful environment if you do not have an already installed system. Just boot the CD in the VM and select "Try Ubuntu."

Part A

Be sure to do the following questions in order.

  1. [0.5] Run the command truncate -s 2G foo. What is the logical size of foo, and how much space does it consume on disk?
  2. [0.5] Run mkfs.ext4 foo. (Say "yes" to operating on a regular file.) What is the logical size of foo now, and how much space does it now consume on disk?
  3. [0.5] Run mount -o loop foo /mnt. What does this command do?
  4. [0.5] Run cp /bin/ls /mnt. What does this command do?
  5. [0.5] Run umount /mnt. Can you still access /mnt/ls? Why or why not?
  6. [0.5] Run dd if=/dev/zero of=foo conv=notrunc count=10 bs=512. What does this command do?
  7. [0.5] Run mount -o loop foo /mnt again. Why did the command fail?
  8. [0.5] What command can you run to make foo mountable again?

Part B

  1. [2] Create a simple C program to generate a file consisting of the word "Hello", one million bytes of blank space (null bytes), and then "world\n", but that consumes only a small number of blocks on disk while having a logical size of 1,000,011 bytes.
  2. [2] Create a C program "mycopy.c" that takes two filenames A and B as command line arguments. This program should copy the contents of A to B, making B a byte-for-byte copy of A. Zero bytes in A should consume little to no space in B. (Hint: You'll have to use the sparse file creation technique of the previous question here.)
  3. [2] Describe a simple way an attacker could get root access on a system if loopback mounts were permitted for non-privileged users.