Links

[previous] [next] [table of contents] [index]

If you keep a lot of mail in a lot of folders, you may want to file the same message in more than one folder. Because MH stores its messages in separate UNIX files, it can take advantage of a UNIX feature called a link. (To keep everything simple, Figure Important parts of a UNIX filesystem doesn't show them. But the Figure Two linked messages does.)

What's a Link?

Basically, a link is a name for a file. UNIX lets you have many links to the same file. In other words, the same file can have a lot of names.

Even when you have several links to a file, there's only one copy of the file stored on the computer's disk -- that file has several names. If you add another link (another name), the new link doesn't take any more disk space. (The directory file which holds the entry for the link will use a few characters to store the link itself, but that's usually insignificant.)

When you use the MH refile -link command, it links a message from one folder into another. In other words, it creates a second name for the same file without removing the original name.

Technical Stuff About Links

When UNIX stores a file on the disk, the file's name (or, in the case of MH, the file's message number) is just a convenience for users. To find the file, UNIX actually uses its i-number. An i-number identifies the file to UNIX.

A file can have as many links (as many names), in as many directories, as you want to give it. UNIX just relates the name to the file's i-number. In fact, a directory is basically just a list of filenames and their i-numbers.

The next Figure shows an example of a message with two links. One link is in the friends folder: message number 5. The other link is in the meals folder: message number 1. Both links have the same i-number (6241), so they both "point to" the same file on the disk. (If you know about "pointers" in programming, a link is a lot like a pointer to a memory location.)

Links can't span filesystems. Many newer UNIX filesystems have symbolic links. Symbolic links can span filesystems, but they take disk space to store.

Figure: Two linked messages

twolinme.gif

[Table of Contents] [Index] [Previous: Special Files for exmh] [Next: Caution About MH Files and Newline Characters]


Last change $Date: 1996/06/06 15:11:08 $

This file is from the third edition of the book MH & xmh: Email for Users & Programmers, ISBN 1-56592-093-7, by Jerry Peek. Copyright 1991, 1992, 1995 by O'Reilly & Associates, Inc. This file is freely-available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see the file copying.htm.

Suggestions are welcome: Jerry Peek <jerry@ora.com>

Questions or problems regarding this web site should be directed to Steve Gielda.
Copyright 1999 www.cotse.com.  All rights reserved.
Last modified: Friday April 02, 1999.