Fall 2005

Clay Shields


front | classes | research | personal | contact

Project 1 - Disk Capacity Calculator

Assigned: Sept. 21
Design due: Sept. 26th
Program source code due: October 3rd

Disk Space Calculator


This semester we will be doing some projects that relate to computer forensics. Computer forensics is the art and science of examining a computer to find evidence about what the computers users have been doing.

As we know, the computer hard drive is the only place on the computer where information remains after the power is turned off. A single hard drive might have tens or hundreds of thousands of different files on it, in addition to other informative artifacts left by programs and the operating system in the course of their normal operation. There are a surprising number of disk artifacts which include the times and dates files were viewed, moved or deleted; copies or remnants of deleted files; files that have been printed, even if they were not saved; automatically stored versions of web pages, images, and e-mails the user saw; transcripts of chat sessions; and information from programs that were running in memory but were saved to disk temporarily.

For this first assignment, we are going to learn about hard drives and how they work. First, you should read this description of hard drives from HowStuffWorks.com to understand what is going on inside the drive. You can also read the Wikipedia entry for more detail.

A computer hard drive consists of a stack of flat platters, commonly made of glass coated with a magnetic material. It also has a number of arms that have magnetic read/write heads can read and write magentic bits onto the surface of the platters. The platter surface is organized into tracks, which are data traces that run in concentric circles on the platter. The series of tracks across the stack of platters makes up a cylinder. Each cylinder is divided into sectors. To find the capacity of the drive, we can multiply the number of heads in the drive by the number of cylinders by the number of sectors per track to find the total number of sectors on the drive. Each sector holds 512 bytes of data. Multiply these two together to find the capacity of the drive in bytes.

Drive manufacturers market drives based on their capacity. The number of bytes per drive is pretty huge, so rather than print the total number of bytes, drives are marketed as having a number of gigabytes, a gigabyte being several billion bytes. They quite naturally make their drives look as large as possible, so they use decimal gigbytes, or 109 bytes. Computer operating systems, however, use binary gigabytes properly named gibibytes which are 230 bytes. The table below shows decimal and binary measures of bytes.

Multiples of bytes
Decimal prefix Binary prefixes
Name Symbol Multiple Name Symbol Multiple
kilobyte kB 103 kibibyte KiB 210
megabyte MB 106 mebibyte MiB 220
gigabyte GB 109 gibibyte GiB 230
terabyte TB 1012 tebibyte TiB 240
petabyte PB 1015 pebibyte PiB 250
exabyte EB 1018 exbibyte EiB 260

Your Assignment

For this project, you will write a program that takes for input the number of cylinders, sectors, and heads on a hard drive. It will then compute the capacity of the drive in bytes, and then output the capacity in both decimal and binary measurements. Below is the output of a program that does this:
gusun> ./disks
This program takes the number of cylinders, sectors, and heads on a hard drive and returns the capacity of the drive.

Enter number of cylinders: 1200
Enter number of sectors: 900
Enter number of heads: 2
Capacity in bytes: 1105920000
The capacity of the disk is:
Decimal bytes: 1 GB 105 MB 920 KB and 0 B.
Binary bytes: 1 GiB 30 MiB 704 KiB and 0 B.

You can also run a version of a program that does this yourself, by logging onto gusun and typing ~clay/disks. This can be helpful in testing your own program.

Part 1 - Design Document

For the first part you are to submit a design document showing the algorithm you plan to implement. Write it out neatly using a language which is similar to that from Homework 1 and has the following terms:
  1. input
  2. output
  3. calculate
  4. if condition, then statement
  5. if condition, then statement; otherwise, statement
  6. start
  7. stop
If you need to group multiple statements together, say in an if statement, use
    begin
       statement
       ...
       statement
    end
A copy of your algorithm is due in class. Be sure to keep a copy for yourself!

Part 2 - Program Source Code

Important: Your output and input should be very similar to that shown in the example program. Please ask for the input in exactly the same order shown and only request the same items shown - do not ask for any other input. This will assist in grading your program.

Include the following header in your source code.

//
// Project 1
// Name: <your name>
// E-mail: <your e-mail address>
// COSC 071
//
// In accordance with the class policies and Georgetown's Honor Code,
// I certify that I have neither given nor received any assistance
// on this project with the exceptions of the lecture notes and those
// items noted below.
//
// Description: <Describe your program>
//

You will submit your source code using the submit program. This is the .cc file. Do not submit the compiled version! I don't speak binary very well.

To submit your program, make sure there is a copy of the source code on your account on gusun. You may name your program what you like - let's assume that it is called disks.cc. To submit your program electronically, use the submit program like we did in Homework 2, but with the command:

submit -a p1 -f disks.cc

I will not be enabling the electronic submission until after the design documents are in, so don't try to submit too early.