NAME
cmdfs – command execution file system

SYNOPSIS
cmdfs [ –abcd ] [ –s srv ] [ –m mnt ]

DESCRIPTION
Cmdfs provides a way to run rc(1) commands through a file system interface and provides means to customize the name space for the commands. It serves a two–level directory and mounts itself by default at /mnt/cmd and at mnt under option –m. A connection to the file system is posted at /srv/cmdfs or at srv under option –s. Flags –abc are similar to those of bind(1). Flag –d enables debug diagnostics and may be repeated to increase verbosity.

The top of the hierarchy is a directory that contains a clone file and one more directories per existing command. Each command directory contains several files:
ctl       to write control requests and read status for the command.
stdin     to write to the command standard input.
stdout    to read from the command standard output.
stderr    to read from the command standard error.
wait      to read the command exit status (and await for it to complete).

Opening the clone file creates a command and returns an open file descriptor for its ctl file. Reading from it a first time would return the name of the directory for the command.

Before executing a command, its stdin, stdout, and stderr files may be open to connect to its I/O descriptors and its wait file may be open to read later from it and await for command completion.

Once appropriate files have been open, the following control requests may be issued to the control file:
bind args       Similar to bind(1), to customize the name space for the entire cmdfs prior to execution of the command.
mount args      Similar to mount(1), for the same reason.
chdir dir       Changes the directory of the command right before executing it.
kill          Terminates the command (even if it did not run yet).
forkns         Makes cmdfs to fork its own name space.
run cmd ...     executes cmd along with any argument supplied. The command is executed by supplying it as given to rc(1).

Reading the ctl file reports the command directory name, the status string (either born, exec, or dead), the PID for the command in the Plan 9 system, and the first argument (the name of the command).

SOURCE
/sys/src/cmd/cmdfs.c

BUGS
The chdir control request does not report errors. It would be better to adjust the name space per–command and not using the one of the entire file system.
Copyright © 2008 Lucent Technologies. All rights reserved.