<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- permission is obtained from the copyright holder. -->
|
<!-- permission is obtained from the copyright holder. -->
|
<HTML
|
<HTML
|
><HEAD
|
><HEAD
|
><TITLE
|
><TITLE
|
>Mount Table</TITLE
|
>Mount Table</TITLE
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
<META
|
<META
|
NAME="GENERATOR"
|
NAME="GENERATOR"
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
"><LINK
|
"><LINK
|
REL="HOME"
|
REL="HOME"
|
TITLE="eCos Reference Manual"
|
TITLE="eCos Reference Manual"
|
HREF="ecos-ref.html"><LINK
|
HREF="ecos-ref.html"><LINK
|
REL="UP"
|
REL="UP"
|
TITLE="File System Support Infrastructure"
|
TITLE="File System Support Infrastructure"
|
HREF="fileio.html"><LINK
|
HREF="fileio.html"><LINK
|
REL="PREVIOUS"
|
REL="PREVIOUS"
|
TITLE="File System Table"
|
TITLE="File System Table"
|
HREF="fileio-fstab.html"><LINK
|
HREF="fileio-fstab.html"><LINK
|
REL="NEXT"
|
REL="NEXT"
|
TITLE="File Table"
|
TITLE="File Table"
|
HREF="fileio-file-table.html"></HEAD
|
HREF="fileio-file-table.html"></HEAD
|
><BODY
|
><BODY
|
CLASS="CHAPTER"
|
CLASS="CHAPTER"
|
BGCOLOR="#FFFFFF"
|
BGCOLOR="#FFFFFF"
|
TEXT="#000000"
|
TEXT="#000000"
|
LINK="#0000FF"
|
LINK="#0000FF"
|
VLINK="#840084"
|
VLINK="#840084"
|
ALINK="#0000FF"
|
ALINK="#0000FF"
|
><DIV
|
><DIV
|
CLASS="NAVHEADER"
|
CLASS="NAVHEADER"
|
><TABLE
|
><TABLE
|
SUMMARY="Header navigation table"
|
SUMMARY="Header navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TH
|
><TH
|
COLSPAN="3"
|
COLSPAN="3"
|
ALIGN="center"
|
ALIGN="center"
|
>eCos Reference Manual</TH
|
>eCos Reference Manual</TH
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="fileio-fstab.html"
|
HREF="fileio-fstab.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="80%"
|
WIDTH="80%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="fileio-file-table.html"
|
HREF="fileio-file-table.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"></DIV
|
WIDTH="100%"></DIV
|
><DIV
|
><DIV
|
CLASS="CHAPTER"
|
CLASS="CHAPTER"
|
><H1
|
><H1
|
><A
|
><A
|
NAME="FILEIO-MOUNT-TABLE">Chapter 21. Mount Table</H1
|
NAME="FILEIO-MOUNT-TABLE">Chapter 21. Mount Table</H1
|
><P
|
><P
|
>The mount table records the filesystems that are actually active.
|
>The mount table records the filesystems that are actually active.
|
These can be seen as being analogous to mount points in Unix systems.</P
|
These can be seen as being analogous to mount points in Unix systems.</P
|
><P
|
><P
|
>There are two sources of mount table entries. Filesystems (or other
|
>There are two sources of mount table entries. Filesystems (or other
|
components) may export static entries to the table using the
|
components) may export static entries to the table using the
|
<TT
|
<TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>MTAB_ENTRY()</TT
|
>MTAB_ENTRY()</TT
|
> macro. Alternatively, new entries may
|
> macro. Alternatively, new entries may
|
be installed at run time using the <TT
|
be installed at run time using the <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>mount()</TT
|
>mount()</TT
|
>
|
>
|
function. Both types of entry may be unmounted with the
|
function. Both types of entry may be unmounted with the
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>umount()</TT
|
>umount()</TT
|
> function.</P
|
> function.</P
|
><P
|
><P
|
>A mount table entry has the following structure:</P
|
>A mount table entry has the following structure:</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>struct cyg_mtab_entry
|
>struct cyg_mtab_entry
|
{
|
{
|
const char *name; // name of mount point
|
const char *name; // name of mount point
|
const char *fsname; // name of implementing filesystem
|
const char *fsname; // name of implementing filesystem
|
const char *devname; // name of hardware device
|
const char *devname; // name of hardware device
|
CYG_ADDRWORD data; // private data value
|
CYG_ADDRWORD data; // private data value
|
cyg_bool valid; // Valid entry?
|
cyg_bool valid; // Valid entry?
|
cyg_fstab_entry *fs; // pointer to fstab entry
|
cyg_fstab_entry *fs; // pointer to fstab entry
|
cyg_dir root; // root directory pointer
|
cyg_dir root; // root directory pointer
|
};</PRE
|
};</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>The <TT
|
>The <TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>name</I
|
>name</I
|
></TT
|
></TT
|
> field identifies the mount
|
> field identifies the mount
|
point. This is used to direct rooted filenames (filenames that
|
point. This is used to direct rooted filenames (filenames that
|
begin with "/") to the correct filesystem. When a file
|
begin with "/") to the correct filesystem. When a file
|
name that begins with "/" is submitted, it is matched
|
name that begins with "/" is submitted, it is matched
|
against the <TT
|
against the <TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>name</I
|
>name</I
|
></TT
|
></TT
|
> fields of all valid mount
|
> fields of all valid mount
|
table entries. The entry that yields the longest match terminating
|
table entries. The entry that yields the longest match terminating
|
before a "/", or end of string, wins and the appropriate
|
before a "/", or end of string, wins and the appropriate
|
function from the filesystem table entry is then passed the remainder
|
function from the filesystem table entry is then passed the remainder
|
of the file name together with a pointer to the table entry and the
|
of the file name together with a pointer to the table entry and the
|
value of the <TT
|
value of the <TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>root</I
|
>root</I
|
></TT
|
></TT
|
> field as the directory
|
> field as the directory
|
pointer.</P
|
pointer.</P
|
><P
|
><P
|
>For example, consider a mount table that contains the following
|
>For example, consider a mount table that contains the following
|
entries:</P
|
entries:</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
> { "/", "msdos", "/dev/hd0", ... }
|
> { "/", "msdos", "/dev/hd0", ... }
|
{ "/fd", "msdos", "/dev/fd0", ... }
|
{ "/fd", "msdos", "/dev/fd0", ... }
|
{ "/rom", "romfs", "", ... }
|
{ "/rom", "romfs", "", ... }
|
{ "/tmp", "ramfs", "", ... }
|
{ "/tmp", "ramfs", "", ... }
|
{ "/dev", "devfs", "", ... }</PRE
|
{ "/dev", "devfs", "", ... }</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>An attempt to open "/tmp/foo" would be directed to the RAM
|
>An attempt to open "/tmp/foo" would be directed to the RAM
|
filesystem while an open of "/bar/bundy" would be directed
|
filesystem while an open of "/bar/bundy" would be directed
|
to the hard disc MSDOS filesystem. Opening "/dev/tty0" would
|
to the hard disc MSDOS filesystem. Opening "/dev/tty0" would
|
be directed to the device management filesystem for lookup in the
|
be directed to the device management filesystem for lookup in the
|
device table.</P
|
device table.</P
|
><P
|
><P
|
>Unrooted file names (those that do not begin with a '/') are passed
|
>Unrooted file names (those that do not begin with a '/') are passed
|
straight to the filesystem that contains the current directory. The
|
straight to the filesystem that contains the current directory. The
|
current directory is represented by a pair consisting of a mount table
|
current directory is represented by a pair consisting of a mount table
|
entry and a directory pointer.</P
|
entry and a directory pointer.</P
|
><P
|
><P
|
>The <TT
|
>The <TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>fsname</I
|
>fsname</I
|
></TT
|
></TT
|
> field points to a string that
|
> field points to a string that
|
should match the <TT
|
should match the <TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>name</I
|
>name</I
|
></TT
|
></TT
|
> field of the
|
> field of the
|
implementing filesystem. During initialization the mount table is
|
implementing filesystem. During initialization the mount table is
|
scanned and the <TT
|
scanned and the <TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>fsname</I
|
>fsname</I
|
></TT
|
></TT
|
> entries looked up in
|
> entries looked up in
|
the filesystem table. For each match, the filesystem's _mount_
|
the filesystem table. For each match, the filesystem's _mount_
|
function is called and if successful the mount table entry is marked
|
function is called and if successful the mount table entry is marked
|
as valid and the <TT
|
as valid and the <TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>fs</I
|
>fs</I
|
></TT
|
></TT
|
> pointer installed.</P
|
> pointer installed.</P
|
><P
|
><P
|
>The <TT
|
>The <TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>devname</I
|
>devname</I
|
></TT
|
></TT
|
> field contains the name of the
|
> field contains the name of the
|
device that this filesystem is to use. This may match an entry in the
|
device that this filesystem is to use. This may match an entry in the
|
device table (see later) or may be a string that is specific to the
|
device table (see later) or may be a string that is specific to the
|
filesystem if it has its own internal device drivers.</P
|
filesystem if it has its own internal device drivers.</P
|
><P
|
><P
|
>The <TT
|
>The <TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>data</I
|
>data</I
|
></TT
|
></TT
|
> field is a private data value. This
|
> field is a private data value. This
|
may be installed either statically when the table entry is defined, or
|
may be installed either statically when the table entry is defined, or
|
may be installed during the <TT
|
may be installed during the <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>mount()</TT
|
>mount()</TT
|
> operation.</P
|
> operation.</P
|
><P
|
><P
|
>The <TT
|
>The <TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>valid</I
|
>valid</I
|
></TT
|
></TT
|
> field indicates whether this mount
|
> field indicates whether this mount
|
point has actually been mounted successfully. Entries with a false
|
point has actually been mounted successfully. Entries with a false
|
<TT
|
<TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>valid</I
|
>valid</I
|
></TT
|
></TT
|
> field are ignored when searching for a
|
> field are ignored when searching for a
|
name match.</P
|
name match.</P
|
><P
|
><P
|
>The <TT
|
>The <TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>fs</I
|
>fs</I
|
></TT
|
></TT
|
> field is installed after a successful
|
> field is installed after a successful
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>mount()</TT
|
>mount()</TT
|
> operation to point to the implementing
|
> operation to point to the implementing
|
filesystem.</P
|
filesystem.</P
|
><P
|
><P
|
>The <TT
|
>The <TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>root</I
|
>root</I
|
></TT
|
></TT
|
> field contains a directory pointer
|
> field contains a directory pointer
|
value that the filesystem can interpret as the root of its directory
|
value that the filesystem can interpret as the root of its directory
|
tree. This is passed as the <TT
|
tree. This is passed as the <TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>dir</I
|
>dir</I
|
></TT
|
></TT
|
> argument of
|
> argument of
|
filesystem functions that operate on rooted filenames. This field must
|
filesystem functions that operate on rooted filenames. This field must
|
be initialized by the filesystem's <TT
|
be initialized by the filesystem's <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>mount()</TT
|
>mount()</TT
|
>
|
>
|
function.</P
|
function.</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="NAVFOOTER"
|
CLASS="NAVFOOTER"
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"><TABLE
|
WIDTH="100%"><TABLE
|
SUMMARY="Footer navigation table"
|
SUMMARY="Footer navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="fileio-fstab.html"
|
HREF="fileio-fstab.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="ecos-ref.html"
|
HREF="ecos-ref.html"
|
ACCESSKEY="H"
|
ACCESSKEY="H"
|
>Home</A
|
>Home</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="fileio-file-table.html"
|
HREF="fileio-file-table.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
>File System Table</TD
|
>File System Table</TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="fileio.html"
|
HREF="fileio.html"
|
ACCESSKEY="U"
|
ACCESSKEY="U"
|
>Up</A
|
>Up</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
>File Table</TD
|
>File Table</TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
></BODY
|
></BODY
|
></HTML
|
></HTML
|
|
|