Operating Systems Project 4

The goals of this project are:
  1. to familiarize yourselves with device management and disk mounting in Unix-like systems
  2. to familiarize yourselves with the Minix block drivers
  3. to familiarize yourselves with the Minix RAM disk driver

As before, this is an individual or group project.

2019/03/12: I have added an option 2. At your choice, you may deliver option 1 or option 2.

Description of Option 1

I want you to add a new ram disk device to your Minix system. This should be a disk of size 4,194,304 bytes (4MB, 4 * 1024 * 1024 bytes). This assumes you have much more than 4MB of memory in your system.

The project consists in creating such a device and making it work. It should be possible to mount(1) your device, which should be called /dev/mydisk -- you may or may not need to create this device with mknod(8) once you have completed your changes to memory.c. To convince yourself that your disk works, you should copy one or more source files to it and compile them, then execute the code.

Description of Option 2

I want you to add a new ram disk device to your Minix system. This new ramdisk should be called /dev/hex and should be a device similar to /dev/zero. Like /dev/zero, /dev/hex ignores anything written to it. The difference is that reads from /dev/hex return the infinitely repeated string "0123456789abcdef" (no spaces or newlines, just the 16 bytes repeated over and over again). For example, the following code:

  int fd = open ("/dev/hex", O_RDONLY);
  char buffer [21];
  int n1 = read (fd, buffer, 20);
  buffer [20] = '\0';
  char b4 [5];
  int n2 = read (fd, buffer, 4);
  b4 [4] = '\0';
  printf ("/dev/hex returned %s and %s\n", buffer, b4);
should print:
/dev/hex returned 0123456789abcdef0123 and 4567
Note that /dev/hex is similar to /dev/random and /dev/urandom on other systems, but produces output that is easier to verify. Also note that the sequence of bytes produced must be independent of any open and close operations -- the next read after the device has returned "3" will always produce "4".

Overall comment

Because the project is relatively simple, this project description gives few details. You are expected to figure out the details yourself. This includes, where appropriate, consulting with the instructor and using the mailing list to consult with your colleagues. The instructor plans to read email occasionally during spring break.

For 2019, there are instructions for how to install minix. However, be sure to apply all the comments from the developer's guide. In particular, the ISO (cdrom) that you install should be for version 3.4.0rc6

Turning in the project

The project should be sent in by email. Please send me the following:

  1. a brief description of the status (success or lack thereof) of your project.
  2. For both options, send me the output of ls -l /dev/yourdevice (either /dev/mydisk or /dev/hex).
  3. a complete copy of your memory.c file. Most of your changes should be to this file.
  4. any other information that is needed to reproduce what you did.
  5. for Option 1 only, if you think you have succeeded, include the entire output of df(1), showing all the disk devices on your system including your new device.
Although you will need to define
#  define MY_DEV           7  /* minor device for /dev/mydisk */
(HEX_DEV for option 2) and redefine
#  define RAM_DEV_FIRST            8    /* first minor device for /dev/ram* */
in include/minix/dmap.h, there is no need to include these details in the project submission.

The minix ramdisk

In case you want to experiment with the built-in minix3 ramdisk, the way to do it is as follows:
  1. ramdisk size, e.g., ramdisk 4096
  2. mkfs.mfs /dev/ram (note: in Linux you would use mke2fs or some other mk*fs command)
  3. mount /dev/ram /mnt
  4. df or mount should show the new file system