moss.fs
Class MProcFS

java.lang.Object
  extended by moss.fs.MProcFS
All Implemented Interfaces:
MFSOps

public class MProcFS
extends java.lang.Object
implements MFSOps

this class implements the "proc" file-system. This is one way in which user-processes can inspect various bits of the kernel (e.g. loaded modules, mounted file-systems, etc.)


Constructor Summary
MProcFS()
           
 
Method Summary
 int access(java.lang.String path, int amode)
          tests for access to a file
static void finalinit()
          called to perform final kernel initialisation (in the context of the init-task)
 int link(java.lang.String oldpath, java.lang.String newpath)
          creates a `hard-link'
 int mkdir(java.lang.String path, int flags)
          creates a directory in the file-system
 int mknod(java.lang.String path, int mode, int majmin)
          creates a special file on the file-system
 int mount(java.lang.String mount_path, java.lang.String[] options)
          called when the proc file-system is mounted.
 int open(java.lang.String path, MFile handle, int flags, int mode)
          called to open a file.
 int opendir(java.lang.String path, MFile handle)
          called to open a directory (read-only!).
 int readlink(java.lang.String path, byte[] buf, int buflen)
          reads the contents of a symbolic-link on the file-system
static int register_procdir(java.lang.String name)
          creates a directory in the proess file-system
static MInode register_procimpl(java.lang.String name, MProcFSIf impl)
          registers something with the process file-system
 int rmdir(java.lang.String path)
          removes a directory from the file-system (must be empty)
 int stat(java.lang.String path, MInode statbuf)
          retrieves information about a name on the file-system
 int symlink(java.lang.String oldpath, java.lang.String newpath)
          creates a symbolic link
 int umount(java.lang.String[] options)
          this is called before the proc file-system is un-mounted.
 int unlink(java.lang.String path)
          removes a name from the file-system
static int unregister_procdir(java.lang.String name)
          removes a directory in the process file-system
static int unregister_procimpl(java.lang.String name)
          unregisters something from the process file-system
 int utime(java.lang.String path, long[] times)
          sets access and modification times for a file (inode)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MProcFS

public MProcFS()
Method Detail

finalinit

public static void finalinit()
called to perform final kernel initialisation (in the context of the init-task)


register_procimpl

public static MInode register_procimpl(java.lang.String name,
                                       MProcFSIf impl)
registers something with the process file-system

Parameters:
name - entry-name. may be something like "foo/bar", but the "foo" must exist first
impl - implementation
Returns:
an MInode for the entry, or null on error (if it already exists)

unregister_procimpl

public static int unregister_procimpl(java.lang.String name)
unregisters something from the process file-system

Parameters:
name - entry-name. may be something like "foo/bar"
Returns:
0 on success, otherwise < 0 indicating error

register_procdir

public static int register_procdir(java.lang.String name)
creates a directory in the proess file-system

Parameters:
name - name of the directory to create
Returns:
0 on success, otherwise < 0 indicating error

unregister_procdir

public static int unregister_procdir(java.lang.String name)
removes a directory in the process file-system

Parameters:
name - name of the directory to remove
Returns:
0 on success, otherwise < 0 indicating error

mount

public int mount(java.lang.String mount_path,
                 java.lang.String[] options)
called when the proc file-system is mounted. Performs specific initialisation.

Specified by:
mount in interface MFSOps
Parameters:
mount_path - full path from the root (/) to where this is being mounted. A single "/" indicates that this is being mounted as the root file-system.
options - file-system specific options
Returns:
0 on success, or < 0 indicating error

umount

public int umount(java.lang.String[] options)
this is called before the proc file-system is un-mounted.

Specified by:
umount in interface MFSOps
Parameters:
options - file-system specific un-mounting options
Returns:
0 on success, or < 0 indicating error

open

public int open(java.lang.String path,
                MFile handle,
                int flags,
                int mode)
called to open a file.

Specified by:
open in interface MFSOps
Parameters:
path - relative path to the file (e.g. `etc/passwd' for the root file-system)
handle - file-handle to be associated with this file
flags - open flags
mode - file mode if creating
Returns:
0 on success, or < 0 indicating error

opendir

public int opendir(java.lang.String path,
                   MFile handle)
called to open a directory (read-only!).

Specified by:
opendir in interface MFSOps
Parameters:
path - relative path to the directory (e.g. `etc/init.d' for the root file-system)
handle - file-handle to be associated with this directory
Returns:
0 on success, or < 0 indicating error

mkdir

public int mkdir(java.lang.String path,
                 int flags)
creates a directory in the file-system

Specified by:
mkdir in interface MFSOps
Parameters:
path - relative path to the directory to be created
flags - flags (mode)
Returns:
0 on success, or < 0 indicating error

unlink

public int unlink(java.lang.String path)
removes a name from the file-system

Specified by:
unlink in interface MFSOps
Parameters:
path - relative path to the name to be removed
Returns:
0 on success, or < 0 indicating error

rmdir

public int rmdir(java.lang.String path)
removes a directory from the file-system (must be empty)

Specified by:
rmdir in interface MFSOps
Parameters:
path - relative path to the directory to be removed
Returns:
0 on success, or < 0 indicating error

link

public int link(java.lang.String oldpath,
                java.lang.String newpath)
creates a `hard-link'

Specified by:
link in interface MFSOps
Parameters:
oldpath - existing relative path (e.g. local/packages/nmh for "usr" file-system)
newpath - new relative path
Returns:
0 on success, or < 0 indicating error

symlink

public int symlink(java.lang.String oldpath,
                   java.lang.String newpath)
creates a symbolic link

Specified by:
symlink in interface MFSOps
Parameters:
oldpath - full path to existing name (e.g. /usr/local/packages/nmh-1.4 for "usr" file-system)
newpath - relative path to new link (e.g. local/packages/nmh for "usr" file-system)
Returns:
0 on success, or < 0 indicating error

mknod

public int mknod(java.lang.String path,
                 int mode,
                 int majmin)
creates a special file on the file-system

Specified by:
mknod in interface MFSOps
Parameters:
path - relative path to file to create
mode - file mode flags
majmin - major and minor numbers `((major << 16) | minor)' for block/char special files, otherwise ignored.
Returns:
0 on success, or < 0 indicating error

readlink

public int readlink(java.lang.String path,
                    byte[] buf,
                    int buflen)
reads the contents of a symbolic-link on the file-system

Specified by:
readlink in interface MFSOps
Parameters:
path - relative path to symbolic link on file-system
buf - buffer where the link data is stored
buflen - maximum number of bytes to write into `buf'
Returns:
number of bytes read on success, or < 0 indicating error

utime

public int utime(java.lang.String path,
                 long[] times)
sets access and modification times for a file (inode)

Specified by:
utime in interface MFSOps
Parameters:
path - relative path to name
times - array of two `long's that are the access and modification times respectively
Returns:
0 on success, or < 0 indicating error

stat

public int stat(java.lang.String path,
                MInode statbuf)
retrieves information about a name on the file-system

Specified by:
stat in interface MFSOps
Parameters:
path - relative path to name
statbuf - buffer in which information is placed
Returns:
0 on success, or < 0 indicating error

access

public int access(java.lang.String path,
                  int amode)
tests for access to a file

Specified by:
access in interface MFSOps
Parameters:
path - relative path to file/directory
amode - access mode
Returns:
0 on success, or < 0 indicating error