Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ttysrch(4) — Motorola System V 88k Release 4 Version 4.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ps(1)

ttyname(3C)

clone(7)

ttysrch(4)  —  FILE FORMATS

NAME

ttysrch − directory search list for ttyname

DESCRIPTION

ttysrch is an optional file that is used by the ttyname library routine.  This file contains either the names of directories in /dev that contain terminal and terminal-related device files, or the filenames of priority devices.  The purpose of this file is to improve the performance of ttyname by indicating which subdirectories in /dev contain terminal-related device files and should be searched first.  Each entry must appear on separate lines and must begin with /dev.  Those path names that do not begin with /dev will be ignored and a warning will be sent to the console.  Blank lines (lines containing only white space) and lines beginning with the comment character "#" will be ignored.  If a specific device is listed, ttyname will specifically examine that device to determine whether or not it meets the matching criteria described below.  Specific device names must be listed as a semi-colon separated list with no spaces and a terminating semi-colon (eg. "/dev/console;/dev/contty;").  Specific device names should be listed prior to any directory which contains the device or any alias of the device since the order of the entries dictates the order of the search.  For each directory listed (except for the special entry /dev), ttyname will recursively search through subdirectories looking for a match.  If /dev appears in the ttysrch file, the /dev directory itself will be searched but there will not be a recursive search through its subdirectories. 

When ttyname searches through the device files, it tries to find a file whose major/minor device number, file system identifier, and inode number match that of the file descriptor it was given as an argument.  If a match is not found, it will settle for a match of just major/minor device and file system identifier, if one can be found.  However, if the file descriptor is associated with a cloned device (see clone(7)), this algorithm does not work efficiently because the inode number of the device file associated with a clonable device will never match the inode number of the file descriptor that was returned by the open of that clonable device.  To help with these situations, entries can be put into the /etc/ttysrch file to improve performance when cloned devices are used as terminals on a system (for example, for remote login).  However, this is only useful if the minor devices related to a cloned device are put into a subdirectory.  (It is important to note that device files need not exist for cloned devices and if that is the case, ttyname will eventually fail.)  For example if /dev/tcp is a cloned device, there could be a subdirectory /dev/inet that contains files tcp000, tcp001, tcp002, etc.  that correspond to the minor devices of the starlan driver.  An optional second field is used in the /etc/ttysrch file to indicate the matching criteria.  This field is separated by white space (any combination of blanks or tabs).  The letter M means major/minor device number, F means file system identifier, and I means inode number.  If this field is not specified for an entry, the default is MFI which means try to match on all three.  For cloned devices the field should be MF, which indicates that it is not necessary to match on the inode number. 

There is another option called A which means alias.  This option is immediately followed by the full path name (must also begin with /dev) of the alias for the device.  After finding a device name (matching MFI), if the option A is present, ttyname appends the minor device number of the found device to the provided alias to form a new name.  Then it checks the aliased device to make sure it is the same as the found device and returns the new name.  For example, if /dev/pts0 is hard linked to /dev/pts/0 and the alias option is present, ttyname() returns /dev/pts0. 

The purpose of having a specific device name in the ttysrch file is to allow ttyname to correctly distinguish between several file system objects which have identical matching criteria.  An example would be /dev/console which is linked to /dev/systty, /dev/contty00, and /dev/syscon.  In such cases, ttyname will return whichever object it encounters first.  If there is a specific device name listed in the ttysrch file (eg. /dev/console), then that object will always be compared against the matching criteria first and the ambiguity will be removed. 

Without the /etc/ttysrch file, ttyname will search the /dev directory by first looking in the directories /dev/term, /dev/pts, and /dev/xt.  If a system has terminal devices installed in directories other than these, it may help performance if the ttysrch file is created and contains that list of directories. 

The command ps(1) maintains a database of terminal device names.  If /etc/ttysrch is modified, the database file /etc/ps_data should be removed.  Removing the database causes it to be automatically rebuilt. 

EXAMPLE

A sample /etc/ttysrch file follows:

/dev/console;/dev/contty;
/dev/termMFI
/dev/ptsMFI
/dev/xtMFI
/dev/inetMF

This file tells ttyname that it should first check for a match with /dev/console and /dev/contty.  Following an unsuccessful match with /dev/console and /dev/contty, it should search through those directories listed and when searching through the /dev/inet directory, if a file is encountered whose major/minor devices and file system identifier match that of the file descriptor argument to ttyname, this device name should be considered a match. 

A sample /etc/ttysrch file for the alias option follows:

/dev/termMFI
/dev/ptsA/dev/pts
/dev/xtMFI
/dev/inetMF

The second line in this file tells ttyname to return /dev/pts0 for /dev/pts/0, /dev/pts1 for /dev/pts/1 etc. 

FILES

/etc/ps_data, /etc/ttysrch

SEE ALSO

ps(1), ttyname(3C), clone(7)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026