COMP 3000 Lab 5 2011: Difference between revisions

From Soma-notes
Created page with "A few guidelines: * Submit your solutions for both Part A and Part B via WebCT by Sunday, November 6th at 11:30 PM. * Please answer using a single text file. Do not submit doc,…"
 
Line 12: Line 12:
==Part B==
==Part B==
# Create a simple C program to generate a sparse file consisting of the word "Hello", one million bytes of blank space, and then "world\n".  (Your final file should have a logical size of 1,000,011 bytes.)
# Create a simple C program to generate a sparse file consisting of the word "Hello", one million bytes of blank space, and then "world\n".  (Your final file should have a logical size of 1,000,011 bytes.)
# Create a C program "sparse-copy" 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.  B, however, should be a sparse file, in that 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.)

Revision as of 02:25, 31 October 2011

A few guidelines:

  • Submit your solutions for both Part A and Part B via WebCT by Sunday, November 6th at 11:30 PM.
  • Please answer using a single text file. 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. (Please don't just cut and paste your work into a text box on webct.)
  • 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

  1. Run the command truncate -s 2G foo. What is the logical size of foo, and how much space does it consume on disk?

Part B

  1. Create a simple C program to generate a sparse file consisting of the word "Hello", one million bytes of blank space, and then "world\n". (Your final file should have a logical size of 1,000,011 bytes.)
  2. Create a C program "sparse-copy" 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. B, however, should be a sparse file, in that 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.)