Middleware, development tools, realtime operating system
software and services for superior embedded design


Home
QNX Community Resources
QNX Documentation Library
QNX Community Resources

QNX Community Resources

QNX Software Systems
Developer Resources
Blogs
Board support packages
Foundry27 projects
Forums
Hardware support listing
Online video tutorials
Product documentation
Technical Articles

[Previous] [Contents] [Next]

prefix

Examine or change the pathname prefix tree (QNX)

Syntax:

prefix [-A prefix=string] [-D prefix] 
       [-n node_id] [-R prefix=string]
       [-s]

Options:

-A prefix=string
Add prefix with alias string.
-D prefix
Delete the specified prefix. If the prefix is directly owned by a resource manager (is not an alias prefix), unmount the device. (See umount.)
-n node_id
Print the prefix string from the indicated node.
-R prefix=string
Replace the specified prefix with new alias string. This is the equivalent of deleting the prefix (-D prefix) then adding the prefix (-A prefix=string).
-s
When adding/changing an alias prefix, skip checks for real mount points.

Description:

The pathname space is administered through the use of two forms of prefixes:

  1. prefixes registered by I/O managers
  2. aliases

The prefix utility allows you to examine and modify the pathname prefix tree.

The prefix tree is essentially an in-memory pathname redirector that is maintained on each computer. When a file is opened, its pathname is matched against the prefix strings in order to direct the request to open the file to the appropriate I/O manager.

For example, the character device manager Dev registers the /dev prefix. Therefore, when a process calls open() with /dev/xxx, a prefix match of /dev will occur and the open() will be directed to Dev (the prefix's owner).

The form of an I/O manager prefix is as follows:

    prefix=pid,unit

where pid is the process ID of the I/O resource manager and the unit number is a single character assigned by the I/O manager. For example, if Fsys is process 3 and Dev is process 5, then the prefix tree might appear as:

    /=3,b
    /dev=5,a
    /dev/hd0=3,a
    /dev/hd0t77=3,d

Note that Fsys has registered three prefixes:

In cases where prefixes overlap, the longest match always wins. Therefore, in the example above, references to /dev/hd0 and /dev/hd0t77 are directed to Fsys rather than to Dev, while all other pathnames starting with /dev are still forwarded to Dev.

Aliases

In addition to this absolute redirection to an I/O manager, another form of prefix, called an alias, lets you replace a matched prefix with a new prefix, which is then re-applied to the prefix tree. Unlike the I/O manager form of prefix, aliases can be modified using the prefix utility. An alias is of the form:

    prefix=replacement_string

Aliases are often used to map remote resources into the local pathname space. For example, a diskless workstation might typically create an alias for its root (/) to a filesystem on another node:

    prefix -A /=//10/

Aliases can also be used to create special device names. For example, the following command:

    prefix -A /dev/console=//20/dev/con1

would alias /dev/console to the primary console on node 20.

The -A option adds a new prefix to the prefix tree. The prefix being added must not already be in the tree.

The -R option deletes, then adds, a prefix to the prefix tree.

The -D option deletes an existing prefix from the prefix tree.

Examples:

List the prefix tree currently in effect:

    prefix

List the prefix tree in effect on node 20:

    prefix -n 20

Create prefix aliases for /home1=//10/home1 and /home2=//14/home2:

    prefix -A /home1=//10/home1 -A /home2=//14/home2

Create a prefix alias for /dev/printer pointing to //12/dev/spool/text:

    prefix -A /dev/printer=//12/dev/spool/text

Remove the prefix for /dev/printer:

    prefix -D /dev/printer

Caveats:

Since redefining the prefix aliases affects all the processes on the computer, you should do this with caution, especially when dealing with definitions for root (/).

See also:

ln

System Architecture


[Previous] [Contents] [Next]