CSE 80 -- Lecture 3 -- Jan 14

Assignment 1. Take the file dumbshell.c and modify it to handle background execution via ampersand (&) just like bash or csh (click on the link, and use File:Save As to get your own copy, or grab it from the public directory). The program as given understands sequencing via semicolon (;). It can be done in 16 lines of minor changes / new code. You may also want to study the hypertext version of the program before you start making the necessary changes; in it you'll find links to manual pages, etc. You should make a copy of the file (also available in ../public/dumbshell.c) in your own directory; the public directory is not writable by students. This assignment is due Tuesday, Jan 21.

Topic of today's lecture: I/O redirection and inheritance. Shell quoting. Filesystem structure; device files; mounting filesystems.

Shell quoting: backslash (\) escapes the special meaning of the next character, and may be used to prevent both globbing and dollar expansion (i.e., using the backslash to escape the globbing metacharacters and dollar signs); all text quoted by single quotes lose their special meaning, including backslash, double quotes, globbing metacharacters, and dollar signs; text quoted by double quotes are not globbed, but are dollar-expanded.

The filesystem in Unix is a tree, where each internal node is a directory and the leaf nodes are files. Every disk drive containing a filesystem has such a tree; when a drive is added, it is mounted onto the existing filesystem tree -- what this means is that the root of the tree from the new drive replaces a directory in the existing tree, so the command

	$ mount /dev/sd2a /usr2
mounts the disk device /dev/sd2a onto the current tree so that all future references to /usr2 will actually refer to the root of the tree from the disk /dev/sd2a instead. The original contents of the directory /usr2 becomes invisible after the mount operation (usually these `mount points' are empty directories anyway).

The name /dev/sd2a above is the name of a device file. A device file is an entry in the filesystem name space referring to a hardware device. In most Unix filesystems, the convention is that device files are all in the /dev directory, though Solaris uses /devices and /dev both. By making hardware devices appear as files, many standard utility programs may be used with hardware devices without special modification by I/O redirection or by using the device file names as parameters.

Next time: Magic numbers; executables and shell scripts.

[ CSE 80 | ACS home | CSE home | CSE calendar | bsy's home page ]
picture of bsy

bsy@cse.ucsd.edu, last updated Tue Mar 18 15:49:25 PST 1997.

email bsy