[Top] [Prev] [Next]


cmd - interface to host operating system commands


bind -a '#C' /



The cmd device provides an interface to commands on the host operating system. By convention, this kernel device (#C) is bound (with the -a option) to the root directory. After binding, the entry point to this facility, the file /cmd/clone, is available. Opening that file provides a handle for launching a command, managing the command's I/O, and checking the command's status.


Opening /cmd/clone creates (or allocates a currently unused) directory, n (a decimal integer), under /cmd. Directory n contains files ctl, data, and status. The file descriptor returned from the open of clone provides access to the /cmd/n/ctl file selected by cmd for subsequent operations.


Reading /cmd/n/ctl (via the file descriptor returned from opening /cmd/clone) provides n, a value that can be used to construct filenames for the related files. Writes to /cmd/n/ctl must be of the format:

	exec oscmd args...

Prior to launching the command cmd prints at the console a line (128 bytes, maximum) of the format:

	devcmd: 'oscmd args...' pid pid

The string between the single quotes matches the command written to /cmd/n/ctl and pid is the number (in decimal format) of the process running the emulator. Each field is separated by a single blank.

File offset is ignored for both reading and writing.


Reading /cmd/n/data obtains the data that the command is writing to its standard output and standard error.

Writing to /cmd/n/data sends the data into the command's standard input.

/cmd/n/status (read-only)

Writing is disallowed.

Reading /cmd/n/status provides a status line (maximum128 bytes) of the format:

	cmd/n refcnt state cmd args...

where each field separator is a single blank. The meaning of each field is:

The directory n where status resides.


The number (decimal) of open file descriptors for /cmd/n/ctl.


The status of the interface in directory /cmd/n. Details below.

cmd [args]...

The active command. Output only for state "Execute".

A cmd directory n can be in the following states

Allocated for use but not yet running a command.


Running a command


Command completed. Available for reallocation via /cmd/clone.

Directory Management

Once closed, a directory n created by cmd persists and is reused by cmd in response to later openings of /cmd/clone. The cmd device only creates a new directory when all others (if any) are in use.

Command Execution

Unix-Hosted Systems

The command is run via the /bin/sh program as follows

	/bin/sh -c 'cmd args...'

Emulator run by root:

If available, the emulator runs the command with a host user ID (uid) and host group ID (gid) corresponding to Inferno's representation for the user's identity. If not available, the emulator runs the command with uidnobody and gidnobody.

Emulator not run by root:

Commands are run on the host with the same host identity as the emulator

Windows-Hosted Systems

The command must be a binary executable (not a command interpreter built-in) in the emulator's path.

The command is always run with the same host identity as the emulator.

See Also

Overview of the emulator


Inferno command interface to the cmd device

[Top] [Prev] [Next]

Copyright © 1996,Lucent Technologies, Inc. All rights reserved.