I learned how to spell PSEUDO
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5010 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
ad9fbd5e95
commit
a51cd50e88
24 changed files with 466 additions and 466 deletions
|
|
@ -3119,7 +3119,7 @@
|
|||
function called stm32_clockenable() that can be used by PM logic to re-start
|
||||
the PLL after re-awakening from deep sleep modes.
|
||||
* fs/fs_foreachinode.c and fs/fs_foreachmountpoint.c: All logic to traverse
|
||||
inodes and mountpoints in the NuttX psuedo-file system.
|
||||
inodes and mountpoints in the NuttX pseudo-file system.
|
||||
* fs/fat/fs_fat32.c: Max. filename length reported by statfs() was wrong
|
||||
if FAT long file names were enabled.
|
||||
* lib/stdio/lib_libvsprintf.c: Fieldwidth and justification were not
|
||||
|
|
|
|||
|
|
@ -1,388 +1,388 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>NFS Client How-To</title>
|
||||
</head>
|
||||
<body background="backgd.gif">
|
||||
<hr><hr>
|
||||
|
||||
<table width ="100%">
|
||||
<tr align="center" bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<h1><big><font color="#3c34ec"><i>NFS Client How-To</i></font></big></h1>
|
||||
<p>Last Updated: June 18, 2012</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr><hr>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<h1>Table of Contents</h1>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<center><table width ="80%">
|
||||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
|
||||
<td>
|
||||
<a href="#nfsconfiguration">Adding NFS to the NuttX Configuration</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
|
||||
<td>
|
||||
<a href="#mountinterface">Mount Interface</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
|
||||
<td>
|
||||
<a href="#nfsmount">NFS Mount Command</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
|
||||
<td>
|
||||
<a href="#serverconfig">Configuring the NFS server (Ubuntu)</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table></center>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="nfsconfiguration"><h1>Adding NFS to the NuttX Configuration</h1></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
The NFS client is easily added to your configuration:
|
||||
You simply need to add <code>CONFIG_NFS</code> to your <code>nuttx/.config</code> file.
|
||||
There are, however, a few dependencies on other system settings:
|
||||
</p>
|
||||
<ol>
|
||||
<li>
|
||||
First, there are number of things that you must configure in order to be able to use any file system:
|
||||
</li>
|
||||
<ul>
|
||||
<li>
|
||||
<code>CONFIG_NFILE_DESCRIPTORS > 0</code>. You must include support for file descriptors.
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_DISABLE_MOUNTPOINT=n</code>. You must include support for mount points in the psuedo-file system.
|
||||
</li>
|
||||
</ul>
|
||||
<li>
|
||||
And there are several dependencies on the networking configuration.
|
||||
At a minimum, you need to have the following selections:
|
||||
</li>
|
||||
<ul>
|
||||
<li>
|
||||
<code>CONFIG_NET=y</code>. General networking support.
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_UDP=y</code>. Support for UDP.
|
||||
</li>
|
||||
</ul>
|
||||
</ol>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="mountinterface"><h1>Mount Interface</h1></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
A low-level, C-callable interface is provided to mount a file system.
|
||||
That interface is called <code>mount()</code> and is mentioned in the <a href="NuttxPortingGuide.html#NxFileSystem"><code>porting guide</code></a> and is prototyped in the header file <code>include/sys/mount.h</code>:
|
||||
</p>
|
||||
<ul><pre>
|
||||
int mount(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, const void *data);
|
||||
</pre></ul>
|
||||
<p>
|
||||
<b>Synopsis</b>:
|
||||
<code>mount()</code> attaches the filesystem specified by the <code>source</code> block device name into the root file system at the path specified by <code>target</code>.
|
||||
</p>
|
||||
<p>
|
||||
<b>Input Paramters</b>:
|
||||
<ul>
|
||||
<li><code>source</code>. A null-terminated string providing the fill path to a block driver in the NuttX psuedo-file system.
|
||||
<li><code>target</code>. The location in the NuttX psuedo-file system where the volume will be mounted.
|
||||
<li><code>filesystemtype</code>. A string identifying the type of file system to use.
|
||||
<li><code>mountflags</code>. Various flags that can be used to qualify how the file system is mounted.
|
||||
<li><code>data</code>. Opaque data that is passed to the file system with the mount occurs.
|
||||
</ul>
|
||||
</p>
|
||||
<p>
|
||||
<b>Returned Values</b>
|
||||
Zero is returned on success; -1 is returned on an error and <code>errno</code> is set appropriately:
|
||||
<ul>
|
||||
<li><code>EACCES</code>.
|
||||
A component of a path was not searchable or mounting a read-onlyfilesystem was attempted without giving the <code>MS_RDONLY</code> flag.
|
||||
</li>
|
||||
<li><code>EBUSY</code>.
|
||||
<code>source</code> is already mounted.
|
||||
</li>
|
||||
<li><code>EFAULT</code>.
|
||||
One of the pointer arguments points outside the user address space.
|
||||
</li>
|
||||
<li><code>EINVAL</code>.
|
||||
<code>source</code> had an invalid superblock.
|
||||
</li>
|
||||
<li><code>ENODEV</code>.
|
||||
<code>filesystemtype</code> not configured
|
||||
</li>
|
||||
<li><code>ENOENT</code>.
|
||||
A pathname was empty or had a nonexistent component.
|
||||
</li>
|
||||
<li><code>ENOMEM</code>.
|
||||
Could not allocate a memory to copy filenames or data into.
|
||||
</li>
|
||||
<li><code>ENOTBLK</code>.
|
||||
<code>source</code> is not a block device
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
<p>
|
||||
This same interface can be used to mount a remote, NFS file system using some special parameters.
|
||||
The NFS mount differs from the <i>normal</i> file system mount in that: (1) there is no block driver for the NFS file system, and (2) special parameters must be passed as <code>data</code> to describe the remote NFS server.
|
||||
Thus the following code snippet might represent how an NFS file system is mounted:
|
||||
</p>
|
||||
<ul><pre>
|
||||
#include <sys/mount.h>
|
||||
#include <nuttx/fs/nfs.h>
|
||||
|
||||
struct nfs_args data;
|
||||
char *mountpoint;
|
||||
|
||||
ret = mount(NULL, mountpoint, string "nfs", 0, (FAR void *)&data);
|
||||
</pre></ul>
|
||||
<p>
|
||||
NOTE that: (1) the block driver paramter is <code>NULL</code>.
|
||||
The <code>mount()</code> is smart enough to know that no block driver is needed with the NFS file system.
|
||||
(2) The NFS file system is identified with the simple string "nfs"
|
||||
(3) A reference to <code>struct nfs_args</code> is passed as an NFS-specific argument.
|
||||
</p>
|
||||
<p>
|
||||
The NFS-specific interface is described in the file <code>include/nuttx/fs/nfs.h</code>.
|
||||
There you can see that <code>struct nfs_args</code> is defined as:
|
||||
</p>
|
||||
<ul><pre>
|
||||
struct nfs_args
|
||||
{
|
||||
uint8_t addrlen; /* Length of address */
|
||||
uint8_t sotype; /* Socket type */
|
||||
uint8_t flags; /* Flags, determines if following are valid: */
|
||||
uint8_t timeo; /* Time value in deciseconds (with NFSMNT_TIMEO) */
|
||||
uint8_t retrans; /* Times to retry send (with NFSMNT_RETRANS) */
|
||||
uint16_t wsize; /* Write size in bytes (with NFSMNT_WSIZE) */
|
||||
uint16_t rsize; /* Read size in bytes (with NFSMNT_RSIZE) */
|
||||
uint16_t readdirsize; /* readdir size in bytes (with NFSMNT_READDIRSIZE) */
|
||||
char *path; /* Server's path of the directory being mount */
|
||||
struct sockaddr_storage addr; /* File server address (requires 32-bit alignment) */
|
||||
};
|
||||
</pre></ul>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="nfsmount"><h1>NFS Mount Command</h1></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
The <a href="NuttShell.html">NuttShell (NSH)</a> also supports a command called <code>nfsmount</code>
|
||||
that can be used to mount a remote file system via the NSH command line.
|
||||
</p>
|
||||
<p>
|
||||
<b>Command Syntax:</b>
|
||||
</p>
|
||||
<ul><pre>
|
||||
nfsmount <server-address> <mount-point> <remote-path>
|
||||
</pre></ul>
|
||||
<p>
|
||||
<b>Synopsis</b>.
|
||||
The <code>nfsmount</code> command mounts a network file system in the NuttX psuedo filesystem.
|
||||
The <code>nfsmount</code> will use NFSv3 UDP protocol to mount the remote file system.
|
||||
</p>
|
||||
<p>
|
||||
<b>Command Line Arguments</b>.
|
||||
The <code>nfsmount</code> takes three arguments:
|
||||
</p>
|
||||
<ol>
|
||||
<li>
|
||||
The <code><server-address></code> is the IP address of the server exporting the file system you wish to mount.
|
||||
This implementation of NFS for the NuttX RTOS is only for a local area network, so the server and client must be in the same network.
|
||||
</li>
|
||||
<li>
|
||||
The <code><mount-point ></code> is the location in the NuttX pseudo filesystem where the mounted volume will appear.
|
||||
This mount point can only reside in the NuttX pseudo filesystem.
|
||||
By convention, this mount point is a subdirectory under <code>/mnt</code>.
|
||||
The mount command will create whatever psuedo directories that may be needed to complete the full path (but the full path must not already exist).
|
||||
</li>
|
||||
<li>
|
||||
The <code><remote-path></code> is the file system <code>/</code> directory being exported from server.
|
||||
This <code>/</code> directory must have been configured for exportation on the server before when the NFS server was set up.
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<p>
|
||||
After the volume has been mounted in the NuttX pseudo filesystem, it may be access in the same way as other objects in the file system.
|
||||
</p>
|
||||
<p>
|
||||
<b>Example</b>.
|
||||
Suppose the the NFS server has been configured to export the directory <code>/export/shared</code>.
|
||||
The the following command would mount that file system (assuming that the target also has privileges to mount the file system).
|
||||
</p>
|
||||
<ul><pre>
|
||||
NuttShell (NSH)
|
||||
nsh> ls /mnt
|
||||
/mnt:
|
||||
nsh: ls: no such directory: /mnt
|
||||
nsh> nfsmount 10.0.0.1 /mnt/nfs /export/shared
|
||||
nsh> ls -l /mnt/nfs
|
||||
/mnt/nfs:
|
||||
drwxrwxrwx 4096 ..
|
||||
drwxrwxrwx 4096 testdir/
|
||||
-rw-rw-rw- 6 ctest.txt
|
||||
-rw-r--r-- 15 btest.txt
|
||||
drwxrwxrwx 4096 .
|
||||
nsh> echo "This is a test" >/mnt/nfs/testdir/testfile.txt
|
||||
nsh> ls -l /mnt/nfs/testdir
|
||||
/mnt/nfs/testdir:
|
||||
-rw-rw-rw- 21 another.txt
|
||||
drwxrwxrwx 4096 ..
|
||||
drwxrwxrwx 4096 .
|
||||
-rw-rw-rw- 16 testfile.txt
|
||||
nsh> cat /mnt/nfs/testdir/testfile.txt
|
||||
This is a test
|
||||
</pre></ul>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="serverconfig"><h1>Configuring the NFS server (Ubuntu)</h1></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
Setting up the server will be done in two steps:
|
||||
First, setting up the configuration file for NFS, and then starting the NFS services.
|
||||
But first, you need to install the nfs server on Ubuntu with the these two commands:
|
||||
</p>
|
||||
<ul><pre>
|
||||
# sudo apt-get install nfs-common</FONT>
|
||||
# sudo apt-get install nfs-kernel-server</FONT>
|
||||
</pre></ul>
|
||||
|
||||
<p>
|
||||
After that, we need to make or choose the directory we want to export from the NFS server.
|
||||
In our case, we are going to make a new directory called <code>/export</code>.
|
||||
</p>
|
||||
<ul><pre>
|
||||
# sudo mkdir /export
|
||||
</pre></ul>
|
||||
<p>
|
||||
It is important that <code>/export</code> directory allow access to everyone (777 permissions) as we will be accessing the NFS share from the client with no authentication.
|
||||
</p>
|
||||
<ul><pre>
|
||||
# sudo chmod 777 /export
|
||||
</pre></ul>
|
||||
<p>
|
||||
When all this is done, we will need to edit the configuration file to set up an NFS server: <code>/etc/exports</code>.
|
||||
This file contains a list of entries;
|
||||
each entry indicates a volume that is shared and how it is shared.
|
||||
For more information for a complete description of all the setup options for this file you can check in the man pages (<code>man export</code>).</p>
|
||||
An entry in <code>/etc/exports</code> will typically look like this:
|
||||
</p>
|
||||
<ul><pre>
|
||||
directory machine1(option11,option12)
|
||||
</pre></ul>
|
||||
<p>
|
||||
So for our example we export <coce>/export</code> to the client 10.0.0.2 add the entry:
|
||||
</p>
|
||||
<ul><pre>
|
||||
/export 10.0.0.2(rw)
|
||||
</pre></ul>
|
||||
<p>
|
||||
In our case we are using all the default options except for the <code>ro</code> that we replaced with <code>rw</code> so that our client will have read and write access to the directory that we are exporting.
|
||||
</p>
|
||||
</p>
|
||||
After we do all the require configurations, we are ready to start the server with the next command:
|
||||
</p>
|
||||
<ul><pre>
|
||||
# sudo /etc/init.d/nfs-kernel-server start
|
||||
</pre></ul>
|
||||
</p>
|
||||
Note: If you later decide to add more NFS exports to the /etc/exports file, you will need to either restart NFS daemon
|
||||
or run command exportfs.
|
||||
</p>
|
||||
<ul><pre>
|
||||
# sudo /etc/init.d/nfs-kernel-server start
|
||||
</pre></ul>
|
||||
<p>Or</p>
|
||||
<ul><pre>
|
||||
# exportfs -ra
|
||||
</pre></ul>
|
||||
<p>
|
||||
Now we can check if the export directory and our mount point is properly set up.
|
||||
</p>
|
||||
<ul><pre>
|
||||
# sudo showmount -e
|
||||
# sudo showmount -a
|
||||
</pre></ul>
|
||||
<p>
|
||||
And also we can verify if NFS is running in the system with:
|
||||
</p>
|
||||
<P STYLE="margin-left: 0.49in; margin-bottom: 0in; line-height: 100%">
|
||||
<ul><pre>
|
||||
# rpcinfo –p</FONT>
|
||||
program vers proto port
|
||||
100000 2 tcp 111 portmapper
|
||||
100000 2 udp 111 portmapper
|
||||
100011 1 udp 749 rquotad
|
||||
100011 2 udp 749 rquotad
|
||||
100005 1 udp 759 mountd
|
||||
100005 1 tcp 761 mountd
|
||||
100005 2 udp 764 mountd
|
||||
100005 2 tcp 766 mountd
|
||||
100005 3 udp 769 mountd
|
||||
100005 3 tcp 771 mountd
|
||||
100003 2 udp 2049 nfs
|
||||
100003 3 udp 2049 nfs
|
||||
300019 1 tcp 830 amd
|
||||
300019 1 udp 831 amd
|
||||
100024 1 udp 944 status
|
||||
100024 1 tcp 946 status
|
||||
100021 1 udp 1042 nlockmgr
|
||||
100021 3 udp 1042 nlockmgr
|
||||
100021 4 udp 1042 nlockmgr
|
||||
100021 1 tcp 1629 nlockmgr
|
||||
100021 3 tcp 1629 nlockmgr
|
||||
100021 4 tcp 1629 nlockmgr
|
||||
</pre></ul>
|
||||
<p>
|
||||
Now your NFS sever is sharing <code>/export</code> directory to be accessed.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<html>
|
||||
<head>
|
||||
<title>NFS Client How-To</title>
|
||||
</head>
|
||||
<body background="backgd.gif">
|
||||
<hr><hr>
|
||||
|
||||
<table width ="100%">
|
||||
<tr align="center" bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<h1><big><font color="#3c34ec"><i>NFS Client How-To</i></font></big></h1>
|
||||
<p>Last Updated: June 18, 2012</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr><hr>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<h1>Table of Contents</h1>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<center><table width ="80%">
|
||||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
|
||||
<td>
|
||||
<a href="#nfsconfiguration">Adding NFS to the NuttX Configuration</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
|
||||
<td>
|
||||
<a href="#mountinterface">Mount Interface</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
|
||||
<td>
|
||||
<a href="#nfsmount">NFS Mount Command</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
|
||||
<td>
|
||||
<a href="#serverconfig">Configuring the NFS server (Ubuntu)</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table></center>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="nfsconfiguration"><h1>Adding NFS to the NuttX Configuration</h1></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
The NFS client is easily added to your configuration:
|
||||
You simply need to add <code>CONFIG_NFS</code> to your <code>nuttx/.config</code> file.
|
||||
There are, however, a few dependencies on other system settings:
|
||||
</p>
|
||||
<ol>
|
||||
<li>
|
||||
First, there are number of things that you must configure in order to be able to use any file system:
|
||||
</li>
|
||||
<ul>
|
||||
<li>
|
||||
<code>CONFIG_NFILE_DESCRIPTORS > 0</code>. You must include support for file descriptors.
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_DISABLE_MOUNTPOINT=n</code>. You must include support for mount points in the pseudo-file system.
|
||||
</li>
|
||||
</ul>
|
||||
<li>
|
||||
And there are several dependencies on the networking configuration.
|
||||
At a minimum, you need to have the following selections:
|
||||
</li>
|
||||
<ul>
|
||||
<li>
|
||||
<code>CONFIG_NET=y</code>. General networking support.
|
||||
</li>
|
||||
<li>
|
||||
<code>CONFIG_NET_UDP=y</code>. Support for UDP.
|
||||
</li>
|
||||
</ul>
|
||||
</ol>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="mountinterface"><h1>Mount Interface</h1></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
A low-level, C-callable interface is provided to mount a file system.
|
||||
That interface is called <code>mount()</code> and is mentioned in the <a href="NuttxPortingGuide.html#NxFileSystem"><code>porting guide</code></a> and is prototyped in the header file <code>include/sys/mount.h</code>:
|
||||
</p>
|
||||
<ul><pre>
|
||||
int mount(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, const void *data);
|
||||
</pre></ul>
|
||||
<p>
|
||||
<b>Synopsis</b>:
|
||||
<code>mount()</code> attaches the filesystem specified by the <code>source</code> block device name into the root file system at the path specified by <code>target</code>.
|
||||
</p>
|
||||
<p>
|
||||
<b>Input Paramters</b>:
|
||||
<ul>
|
||||
<li><code>source</code>. A null-terminated string providing the fill path to a block driver in the NuttX pseudo-file system.
|
||||
<li><code>target</code>. The location in the NuttX pseudo-file system where the volume will be mounted.
|
||||
<li><code>filesystemtype</code>. A string identifying the type of file system to use.
|
||||
<li><code>mountflags</code>. Various flags that can be used to qualify how the file system is mounted.
|
||||
<li><code>data</code>. Opaque data that is passed to the file system with the mount occurs.
|
||||
</ul>
|
||||
</p>
|
||||
<p>
|
||||
<b>Returned Values</b>
|
||||
Zero is returned on success; -1 is returned on an error and <code>errno</code> is set appropriately:
|
||||
<ul>
|
||||
<li><code>EACCES</code>.
|
||||
A component of a path was not searchable or mounting a read-onlyfilesystem was attempted without giving the <code>MS_RDONLY</code> flag.
|
||||
</li>
|
||||
<li><code>EBUSY</code>.
|
||||
<code>source</code> is already mounted.
|
||||
</li>
|
||||
<li><code>EFAULT</code>.
|
||||
One of the pointer arguments points outside the user address space.
|
||||
</li>
|
||||
<li><code>EINVAL</code>.
|
||||
<code>source</code> had an invalid superblock.
|
||||
</li>
|
||||
<li><code>ENODEV</code>.
|
||||
<code>filesystemtype</code> not configured
|
||||
</li>
|
||||
<li><code>ENOENT</code>.
|
||||
A pathname was empty or had a nonexistent component.
|
||||
</li>
|
||||
<li><code>ENOMEM</code>.
|
||||
Could not allocate a memory to copy filenames or data into.
|
||||
</li>
|
||||
<li><code>ENOTBLK</code>.
|
||||
<code>source</code> is not a block device
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
<p>
|
||||
This same interface can be used to mount a remote, NFS file system using some special parameters.
|
||||
The NFS mount differs from the <i>normal</i> file system mount in that: (1) there is no block driver for the NFS file system, and (2) special parameters must be passed as <code>data</code> to describe the remote NFS server.
|
||||
Thus the following code snippet might represent how an NFS file system is mounted:
|
||||
</p>
|
||||
<ul><pre>
|
||||
#include <sys/mount.h>
|
||||
#include <nuttx/fs/nfs.h>
|
||||
|
||||
struct nfs_args data;
|
||||
char *mountpoint;
|
||||
|
||||
ret = mount(NULL, mountpoint, string "nfs", 0, (FAR void *)&data);
|
||||
</pre></ul>
|
||||
<p>
|
||||
NOTE that: (1) the block driver paramter is <code>NULL</code>.
|
||||
The <code>mount()</code> is smart enough to know that no block driver is needed with the NFS file system.
|
||||
(2) The NFS file system is identified with the simple string "nfs"
|
||||
(3) A reference to <code>struct nfs_args</code> is passed as an NFS-specific argument.
|
||||
</p>
|
||||
<p>
|
||||
The NFS-specific interface is described in the file <code>include/nuttx/fs/nfs.h</code>.
|
||||
There you can see that <code>struct nfs_args</code> is defined as:
|
||||
</p>
|
||||
<ul><pre>
|
||||
struct nfs_args
|
||||
{
|
||||
uint8_t addrlen; /* Length of address */
|
||||
uint8_t sotype; /* Socket type */
|
||||
uint8_t flags; /* Flags, determines if following are valid: */
|
||||
uint8_t timeo; /* Time value in deciseconds (with NFSMNT_TIMEO) */
|
||||
uint8_t retrans; /* Times to retry send (with NFSMNT_RETRANS) */
|
||||
uint16_t wsize; /* Write size in bytes (with NFSMNT_WSIZE) */
|
||||
uint16_t rsize; /* Read size in bytes (with NFSMNT_RSIZE) */
|
||||
uint16_t readdirsize; /* readdir size in bytes (with NFSMNT_READDIRSIZE) */
|
||||
char *path; /* Server's path of the directory being mount */
|
||||
struct sockaddr_storage addr; /* File server address (requires 32-bit alignment) */
|
||||
};
|
||||
</pre></ul>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="nfsmount"><h1>NFS Mount Command</h1></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
The <a href="NuttShell.html">NuttShell (NSH)</a> also supports a command called <code>nfsmount</code>
|
||||
that can be used to mount a remote file system via the NSH command line.
|
||||
</p>
|
||||
<p>
|
||||
<b>Command Syntax:</b>
|
||||
</p>
|
||||
<ul><pre>
|
||||
nfsmount <server-address> <mount-point> <remote-path>
|
||||
</pre></ul>
|
||||
<p>
|
||||
<b>Synopsis</b>.
|
||||
The <code>nfsmount</code> command mounts a network file system in the NuttX pseudo filesystem.
|
||||
The <code>nfsmount</code> will use NFSv3 UDP protocol to mount the remote file system.
|
||||
</p>
|
||||
<p>
|
||||
<b>Command Line Arguments</b>.
|
||||
The <code>nfsmount</code> takes three arguments:
|
||||
</p>
|
||||
<ol>
|
||||
<li>
|
||||
The <code><server-address></code> is the IP address of the server exporting the file system you wish to mount.
|
||||
This implementation of NFS for the NuttX RTOS is only for a local area network, so the server and client must be in the same network.
|
||||
</li>
|
||||
<li>
|
||||
The <code><mount-point ></code> is the location in the NuttX pseudo filesystem where the mounted volume will appear.
|
||||
This mount point can only reside in the NuttX pseudo filesystem.
|
||||
By convention, this mount point is a subdirectory under <code>/mnt</code>.
|
||||
The mount command will create whatever pseudo directories that may be needed to complete the full path (but the full path must not already exist).
|
||||
</li>
|
||||
<li>
|
||||
The <code><remote-path></code> is the file system <code>/</code> directory being exported from server.
|
||||
This <code>/</code> directory must have been configured for exportation on the server before when the NFS server was set up.
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<p>
|
||||
After the volume has been mounted in the NuttX pseudo filesystem, it may be access in the same way as other objects in the file system.
|
||||
</p>
|
||||
<p>
|
||||
<b>Example</b>.
|
||||
Suppose the the NFS server has been configured to export the directory <code>/export/shared</code>.
|
||||
The the following command would mount that file system (assuming that the target also has privileges to mount the file system).
|
||||
</p>
|
||||
<ul><pre>
|
||||
NuttShell (NSH)
|
||||
nsh> ls /mnt
|
||||
/mnt:
|
||||
nsh: ls: no such directory: /mnt
|
||||
nsh> nfsmount 10.0.0.1 /mnt/nfs /export/shared
|
||||
nsh> ls -l /mnt/nfs
|
||||
/mnt/nfs:
|
||||
drwxrwxrwx 4096 ..
|
||||
drwxrwxrwx 4096 testdir/
|
||||
-rw-rw-rw- 6 ctest.txt
|
||||
-rw-r--r-- 15 btest.txt
|
||||
drwxrwxrwx 4096 .
|
||||
nsh> echo "This is a test" >/mnt/nfs/testdir/testfile.txt
|
||||
nsh> ls -l /mnt/nfs/testdir
|
||||
/mnt/nfs/testdir:
|
||||
-rw-rw-rw- 21 another.txt
|
||||
drwxrwxrwx 4096 ..
|
||||
drwxrwxrwx 4096 .
|
||||
-rw-rw-rw- 16 testfile.txt
|
||||
nsh> cat /mnt/nfs/testdir/testfile.txt
|
||||
This is a test
|
||||
</pre></ul>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="serverconfig"><h1>Configuring the NFS server (Ubuntu)</h1></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
Setting up the server will be done in two steps:
|
||||
First, setting up the configuration file for NFS, and then starting the NFS services.
|
||||
But first, you need to install the nfs server on Ubuntu with the these two commands:
|
||||
</p>
|
||||
<ul><pre>
|
||||
# sudo apt-get install nfs-common</FONT>
|
||||
# sudo apt-get install nfs-kernel-server</FONT>
|
||||
</pre></ul>
|
||||
|
||||
<p>
|
||||
After that, we need to make or choose the directory we want to export from the NFS server.
|
||||
In our case, we are going to make a new directory called <code>/export</code>.
|
||||
</p>
|
||||
<ul><pre>
|
||||
# sudo mkdir /export
|
||||
</pre></ul>
|
||||
<p>
|
||||
It is important that <code>/export</code> directory allow access to everyone (777 permissions) as we will be accessing the NFS share from the client with no authentication.
|
||||
</p>
|
||||
<ul><pre>
|
||||
# sudo chmod 777 /export
|
||||
</pre></ul>
|
||||
<p>
|
||||
When all this is done, we will need to edit the configuration file to set up an NFS server: <code>/etc/exports</code>.
|
||||
This file contains a list of entries;
|
||||
each entry indicates a volume that is shared and how it is shared.
|
||||
For more information for a complete description of all the setup options for this file you can check in the man pages (<code>man export</code>).</p>
|
||||
An entry in <code>/etc/exports</code> will typically look like this:
|
||||
</p>
|
||||
<ul><pre>
|
||||
directory machine1(option11,option12)
|
||||
</pre></ul>
|
||||
<p>
|
||||
So for our example we export <coce>/export</code> to the client 10.0.0.2 add the entry:
|
||||
</p>
|
||||
<ul><pre>
|
||||
/export 10.0.0.2(rw)
|
||||
</pre></ul>
|
||||
<p>
|
||||
In our case we are using all the default options except for the <code>ro</code> that we replaced with <code>rw</code> so that our client will have read and write access to the directory that we are exporting.
|
||||
</p>
|
||||
</p>
|
||||
After we do all the require configurations, we are ready to start the server with the next command:
|
||||
</p>
|
||||
<ul><pre>
|
||||
# sudo /etc/init.d/nfs-kernel-server start
|
||||
</pre></ul>
|
||||
</p>
|
||||
Note: If you later decide to add more NFS exports to the /etc/exports file, you will need to either restart NFS daemon
|
||||
or run command exportfs.
|
||||
</p>
|
||||
<ul><pre>
|
||||
# sudo /etc/init.d/nfs-kernel-server start
|
||||
</pre></ul>
|
||||
<p>Or</p>
|
||||
<ul><pre>
|
||||
# exportfs -ra
|
||||
</pre></ul>
|
||||
<p>
|
||||
Now we can check if the export directory and our mount point is properly set up.
|
||||
</p>
|
||||
<ul><pre>
|
||||
# sudo showmount -e
|
||||
# sudo showmount -a
|
||||
</pre></ul>
|
||||
<p>
|
||||
And also we can verify if NFS is running in the system with:
|
||||
</p>
|
||||
<P STYLE="margin-left: 0.49in; margin-bottom: 0in; line-height: 100%">
|
||||
<ul><pre>
|
||||
# rpcinfo –p</FONT>
|
||||
program vers proto port
|
||||
100000 2 tcp 111 portmapper
|
||||
100000 2 udp 111 portmapper
|
||||
100011 1 udp 749 rquotad
|
||||
100011 2 udp 749 rquotad
|
||||
100005 1 udp 759 mountd
|
||||
100005 1 tcp 761 mountd
|
||||
100005 2 udp 764 mountd
|
||||
100005 2 tcp 766 mountd
|
||||
100005 3 udp 769 mountd
|
||||
100005 3 tcp 771 mountd
|
||||
100003 2 udp 2049 nfs
|
||||
100003 3 udp 2049 nfs
|
||||
300019 1 tcp 830 amd
|
||||
300019 1 udp 831 amd
|
||||
100024 1 udp 944 status
|
||||
100024 1 tcp 946 status
|
||||
100021 1 udp 1042 nlockmgr
|
||||
100021 3 udp 1042 nlockmgr
|
||||
100021 4 udp 1042 nlockmgr
|
||||
100021 1 tcp 1629 nlockmgr
|
||||
100021 3 tcp 1629 nlockmgr
|
||||
100021 4 tcp 1629 nlockmgr
|
||||
</pre></ul>
|
||||
<p>
|
||||
Now your NFS sever is sharing <code>/export</code> directory to be accessed.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1400,7 +1400,7 @@ mkfifo <path>
|
|||
<p>
|
||||
<b>Synopsis</b>.
|
||||
Creates a FIFO character device anywhere in the pseudo file system, creating
|
||||
whatever psuedo directories that may be needed to complete the <code><path></code>.
|
||||
whatever pseudo directories that may be needed to complete the <code><path></code>.
|
||||
By convention, however, device drivers are place in the standard <code>/dev</code> directory.
|
||||
After it is created, the FIFO device may be used as any other device driver.
|
||||
NSH provides this command to access the <a href="NuttxUserGuide.html#mkfifo"><code>mkfifo()</code></a> NuttX API.
|
||||
|
|
@ -1492,7 +1492,7 @@ mount -t <fstype> <block-device> <code><dir-path></code>
|
|||
If no paramters are provided on the command line after the <code>mount</code> command, then the <code>mount</code> command will enumerate all of the current mountpoints on the console.
|
||||
</p>
|
||||
<p>
|
||||
If the mount parameters are provied on the command after the <code>mount</code> command, then the <code>mount</code> command will mount a file system in the NuttX psuedo-file system.
|
||||
If the mount parameters are provied on the command after the <code>mount</code> command, then the <code>mount</code> command will mount a file system in the NuttX pseudo-file system.
|
||||
<code>mount</code>' performs a three way association, binding:
|
||||
</p>
|
||||
<ol>
|
||||
|
|
@ -1513,7 +1513,7 @@ mount -t <fstype> <block-device> <code><dir-path></code>
|
|||
<a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> where the mounted volume will appear.
|
||||
This mount point can only reside in the NuttX <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a>.
|
||||
By convention, this mount point is a subdirectory under <code>/mnt</code>.
|
||||
The mount command will create whatever psuedo directories that may be needed to complete the
|
||||
The mount command will create whatever pseudo directories that may be needed to complete the
|
||||
full path but the full path must not already exist.
|
||||
</li>
|
||||
</ol>
|
||||
|
|
|
|||
4
TODO
4
TODO
|
|
@ -703,9 +703,9 @@ o File system / Generic drivers (fs/, drivers/)
|
|||
|
||||
Title: REMOVING PIPES AND FIFOS
|
||||
Description: There is no way to remove a FIFO or PIPE created in the
|
||||
psuedo filesystem. Once created, they persist indefinitely
|
||||
pseudo filesystem. Once created, they persist indefinitely
|
||||
and cannot be unlinked. This is actually a more generic
|
||||
issue: unlink does not work for anything in the psuedo-
|
||||
issue: unlink does not work for anything in the pseudo-
|
||||
filesystem.
|
||||
Status: Open, but partially resolved: pipe buffer is at least freed
|
||||
when there are not open references to the pipe/FIFO.
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ host operations. To make these modifications, do the following:
|
|||
|
||||
When this change is made, NSH should be extended to support USB flash
|
||||
devices. When a FLASH device is inserted, you should see a device
|
||||
appear in the /dev (psuedo) directory. The device name should be
|
||||
appear in the /dev (pseudo) directory. The device name should be
|
||||
like /dev/sda, /dev/sdb, etc. The USB mass storage device, is present
|
||||
it can be mounted from the NSH command line like:
|
||||
|
||||
|
|
|
|||
|
|
@ -829,7 +829,7 @@ host operations. To make these modifications, do the following:
|
|||
|
||||
When this change is made, NSH should be extended to support USB flash
|
||||
devices. When a FLASH device is inserted, you should see a device
|
||||
appear in the /dev (psuedo) directory. The device name should be
|
||||
appear in the /dev (pseudo) directory. The device name should be
|
||||
like /dev/sda, /dev/sdb, etc. The USB mass storage device, is present
|
||||
it can be mounted from the NSH command line like:
|
||||
|
||||
|
|
|
|||
|
|
@ -384,7 +384,7 @@ host operations. To make these modifications, do the following:
|
|||
|
||||
When this change is made, NSH should be extended to support USB flash
|
||||
devices. When a FLASH device is inserted, you should see a device
|
||||
appear in the /dev (psuedo) directory. The device name should be
|
||||
appear in the /dev (pseudo) directory. The device name should be
|
||||
like /dev/sda, /dev/sdb, etc. The USB mass storage device, is present
|
||||
it can be mounted from the NSH command line like:
|
||||
|
||||
|
|
|
|||
|
|
@ -788,7 +788,7 @@ USB host operations. To make these modifications, do the following:
|
|||
|
||||
When this change is made, NSH should be extended to support USB flash
|
||||
devices. When a FLASH device is inserted, you should see a device
|
||||
appear in the /dev (psuedo) directory. The device name should be
|
||||
appear in the /dev (pseudo) directory. The device name should be
|
||||
like /dev/sda, /dev/sdb, etc. The USB mass storage device, is present
|
||||
it can be mounted from the NSH command line like:
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ int closedir(FAR DIR *dirp)
|
|||
*/
|
||||
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
if (INODE_IS_MOUNTPT(inode) && !DIRENT_ISPSUEDONODE(idir->fd_flags))
|
||||
if (INODE_IS_MOUNTPT(inode) && !DIRENT_ISPSEUDONODE(idir->fd_flags))
|
||||
{
|
||||
/* The node is a file system mointpoint. Verify that the mountpoint
|
||||
* supports the closedir() method (not an error if it does not)
|
||||
|
|
@ -117,13 +117,13 @@ int closedir(FAR DIR *dirp)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
/* The node is part of the root psuedo file system, release
|
||||
/* The node is part of the root pseudo file system, release
|
||||
* our contained reference to the 'next' inode.
|
||||
*/
|
||||
|
||||
if (idir->u.psuedo.fd_next)
|
||||
if (idir->u.pseudo.fd_next)
|
||||
{
|
||||
inode_release(idir->u.psuedo.fd_next);
|
||||
inode_release(idir->u.pseudo.fd_next);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ int files_dup(FAR struct file *filep1, FAR struct file *filep2)
|
|||
#endif
|
||||
#endif
|
||||
{
|
||||
/* Open the psuedo file or device driver */
|
||||
/* Open the pseudo file or device driver */
|
||||
|
||||
ret = inode->u.i_ops->open(filep2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ int foreach_inodelevel(FAR struct inode *node, struct inode_path_s *info)
|
|||
* when the callback 'handler' returns a non-zero value, or when all of
|
||||
* the inodes have been visited.
|
||||
*
|
||||
* NOTE 1: Use with caution... The psuedo-file system is locked throughout
|
||||
* NOTE 1: Use with caution... The pseudo-file system is locked throughout
|
||||
* the traversal.
|
||||
* NOTE 2: The search algorithm is recursive and could, in principle, use
|
||||
* an indeterminant amount of stack space. This will not usually be a
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ static int mountpoint_filter(FAR struct inode *node,
|
|||
* mountpoint inodes. It is intended to support the mount() command to
|
||||
* when the mount command is used to enumerate mounts.
|
||||
*
|
||||
* NOTE 1: Use with caution... The psuedo-file system is locked throughout
|
||||
* NOTE 1: Use with caution... The pseudo-file system is locked throughout
|
||||
* the traversal.
|
||||
* NOTE 2: The search algorithm is recursive and could, in principle, use
|
||||
* an indeterminant amount of stack space. This will not usually be a
|
||||
|
|
|
|||
|
|
@ -75,10 +75,10 @@
|
|||
|
||||
/* Mountpoint fd_flags values */
|
||||
|
||||
#define DIRENTFLAGS_PSUEDONODE 1
|
||||
#define DIRENTFLAGS_PSEUDONODE 1
|
||||
|
||||
#define DIRENT_SETPSUEDONODE(f) do (f) |= DIRENTFLAGS_PSUEDONODE; while (0)
|
||||
#define DIRENT_ISPSUEDONODE(f) (((f) & DIRENTFLAGS_PSUEDONODE) != 0)
|
||||
#define DIRENT_SETPSEUDONODE(f) do (f) |= DIRENTFLAGS_PSEUDONODE; while (0)
|
||||
#define DIRENT_ISPSEUDONODE(f) (((f) & DIRENTFLAGS_PSEUDONODE) != 0)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
|
|
@ -236,7 +236,7 @@ EXTERN void inode_release(FAR struct inode *inode);
|
|||
* when the callback 'handler' returns a non-zero value, or when all of
|
||||
* the inodes have been visited.
|
||||
*
|
||||
* NOTE 1: Use with caution... The psuedo-file system is locked throughout
|
||||
* NOTE 1: Use with caution... The pseudo-file system is locked throughout
|
||||
* the traversal.
|
||||
* NOTE 2: The search algorithm is recursive and could, in principle, use
|
||||
* an indeterminant amount of stack space. This will not usually be a
|
||||
|
|
|
|||
|
|
@ -138,19 +138,19 @@ static inline int open_mountpoint(FAR struct inode *inode,
|
|||
|
||||
static void open_pseudodir(FAR struct inode *inode, FAR struct fs_dirent_s *dir)
|
||||
{
|
||||
/* We have a valid psuedo-filesystem node. Take two references on the
|
||||
/* We have a valid pseudo-filesystem node. Take two references on the
|
||||
* inode -- one for the parent (fd_root) and one for the child (fd_next).
|
||||
* Note that we do not call inode_addref because we are holding the tree
|
||||
* semaphore and that would result in deadlock.
|
||||
*/
|
||||
|
||||
inode->i_crefs += 2;
|
||||
dir->u.psuedo.fd_next = inode; /* This is the next node to use for readdir() */
|
||||
dir->u.pseudo.fd_next = inode; /* This is the next node to use for readdir() */
|
||||
|
||||
/* Flag the inode as belonging to the psuedo-filesystem */
|
||||
/* Flag the inode as belonging to the pseudo-filesystem */
|
||||
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
DIRENT_SETPSUEDONODE(dir->fd_flags);
|
||||
DIRENT_SETPSEUDONODE(dir->fd_flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -242,7 +242,7 @@ FAR DIR *opendir(FAR const char *path)
|
|||
}
|
||||
|
||||
/* Populate the DIR structure and return it to the caller. The way that
|
||||
* we do this depends on whenever this is a "normal" psuedo-file-system
|
||||
* we do this depends on whenever this is a "normal" pseudo-file-system
|
||||
* inode or a file system mountpoint.
|
||||
*/
|
||||
|
||||
|
|
@ -262,7 +262,7 @@ FAR DIR *opendir(FAR const char *path)
|
|||
open_pseudodir(inode, dir);
|
||||
}
|
||||
|
||||
/* Is this a node in the psuedo filesystem? Or a mountpoint? If the node
|
||||
/* Is this a node in the pseudo filesystem? Or a mountpoint? If the node
|
||||
* is the root (bisroot == TRUE), then this is a special case.
|
||||
*/
|
||||
|
||||
|
|
@ -280,7 +280,7 @@ FAR DIR *opendir(FAR const char *path)
|
|||
#endif
|
||||
else
|
||||
{
|
||||
/* The node is part of the root psuedo file system. Does the inode have a child?
|
||||
/* The node is part of the root pseudo file system. Does the inode have a child?
|
||||
* If so that the child would be the 'root' of a list of nodes under
|
||||
* the directory.
|
||||
*/
|
||||
|
|
@ -292,7 +292,7 @@ FAR DIR *opendir(FAR const char *path)
|
|||
goto errout_with_direntry;
|
||||
}
|
||||
|
||||
/* It looks we have a valid psuedo-filesystem directory node. */
|
||||
/* It looks we have a valid pseudo-filesystem directory node. */
|
||||
|
||||
open_pseudodir(inode, dir);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,16 +53,16 @@
|
|||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: readpsuedodir
|
||||
* Name: readpseudodir
|
||||
****************************************************************************/
|
||||
|
||||
static inline int readpsuedodir(struct fs_dirent_s *idir)
|
||||
static inline int readpseudodir(struct fs_dirent_s *idir)
|
||||
{
|
||||
FAR struct inode *prev;
|
||||
|
||||
/* Check if we are at the end of the list */
|
||||
|
||||
if (!idir->u.psuedo.fd_next)
|
||||
if (!idir->u.pseudo.fd_next)
|
||||
{
|
||||
/* End of file and error conditions are not distinguishable
|
||||
* with readdir. Here we return -ENOENT to signal the end
|
||||
|
|
@ -74,21 +74,21 @@ static inline int readpsuedodir(struct fs_dirent_s *idir)
|
|||
|
||||
/* Copy the inode name into the dirent structure */
|
||||
|
||||
strncpy(idir->fd_dir.d_name, idir->u.psuedo.fd_next->i_name, NAME_MAX+1);
|
||||
strncpy(idir->fd_dir.d_name, idir->u.pseudo.fd_next->i_name, NAME_MAX+1);
|
||||
|
||||
/* If the node has file operations, we will say that it is
|
||||
* a file.
|
||||
*/
|
||||
|
||||
idir->fd_dir.d_type = 0;
|
||||
if (idir->u.psuedo.fd_next->u.i_ops)
|
||||
if (idir->u.pseudo.fd_next->u.i_ops)
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
if (INODE_IS_BLOCK(idir->u.psuedo.fd_next))
|
||||
if (INODE_IS_BLOCK(idir->u.pseudo.fd_next))
|
||||
{
|
||||
idir->fd_dir.d_type |= DTYPE_BLK;
|
||||
}
|
||||
if (INODE_IS_MOUNTPT(idir->u.psuedo.fd_next))
|
||||
if (INODE_IS_MOUNTPT(idir->u.pseudo.fd_next))
|
||||
{
|
||||
idir->fd_dir.d_type |= DTYPE_DIRECTORY;
|
||||
}
|
||||
|
|
@ -103,7 +103,7 @@ static inline int readpsuedodir(struct fs_dirent_s *idir)
|
|||
* is a directory. NOTE: that the node can be both!
|
||||
*/
|
||||
|
||||
if (idir->u.psuedo.fd_next->i_child || !idir->u.psuedo.fd_next->u.i_ops)
|
||||
if (idir->u.pseudo.fd_next->i_child || !idir->u.pseudo.fd_next->u.i_ops)
|
||||
{
|
||||
idir->fd_dir.d_type |= DTYPE_DIRECTORY;
|
||||
}
|
||||
|
|
@ -112,14 +112,14 @@ static inline int readpsuedodir(struct fs_dirent_s *idir)
|
|||
|
||||
inode_semtake();
|
||||
|
||||
prev = idir->u.psuedo.fd_next;
|
||||
idir->u.psuedo.fd_next = prev->i_peer; /* The next node to visit */
|
||||
prev = idir->u.pseudo.fd_next;
|
||||
idir->u.pseudo.fd_next = prev->i_peer; /* The next node to visit */
|
||||
|
||||
if (idir->u.psuedo.fd_next)
|
||||
if (idir->u.pseudo.fd_next)
|
||||
{
|
||||
/* Increment the reference count on this next node */
|
||||
|
||||
idir->u.psuedo.fd_next->i_crefs++;
|
||||
idir->u.pseudo.fd_next->i_crefs++;
|
||||
}
|
||||
|
||||
inode_semgive();
|
||||
|
|
@ -179,7 +179,7 @@ FAR struct dirent *readdir(DIR *dirp)
|
|||
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
inode = idir->fd_root;
|
||||
if (INODE_IS_MOUNTPT(inode) && !DIRENT_ISPSUEDONODE(idir->fd_flags))
|
||||
if (INODE_IS_MOUNTPT(inode) && !DIRENT_ISPSEUDONODE(idir->fd_flags))
|
||||
{
|
||||
/* The node is a file system mointpoint. Verify that the mountpoint
|
||||
* supports the readdir() method
|
||||
|
|
@ -198,9 +198,9 @@ FAR struct dirent *readdir(DIR *dirp)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
/* The node is part of the root psuedo file system */
|
||||
/* The node is part of the root pseudo file system */
|
||||
|
||||
ret = readpsuedodir(idir);
|
||||
ret = readpseudodir(idir);
|
||||
}
|
||||
|
||||
/* ret < 0 is an error. Special case: ret = -ENOENT is end of file */
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@
|
|||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: rewindpsuedodir
|
||||
* Name: rewindpseudodir
|
||||
****************************************************************************/
|
||||
|
||||
static inline void rewindpsuedodir(struct fs_dirent_s *idir)
|
||||
static inline void rewindpseudodir(struct fs_dirent_s *idir)
|
||||
{
|
||||
struct inode *prev;
|
||||
|
||||
|
|
@ -63,8 +63,8 @@ static inline void rewindpsuedodir(struct fs_dirent_s *idir)
|
|||
|
||||
/* Reset the position to the beginning */
|
||||
|
||||
prev = idir->u.psuedo.fd_next; /* (Save to delete later) */
|
||||
idir->u.psuedo.fd_next = idir->fd_root; /* The next node to visit */
|
||||
prev = idir->u.pseudo.fd_next; /* (Save to delete later) */
|
||||
idir->u.pseudo.fd_next = idir->fd_root; /* The next node to visit */
|
||||
idir->fd_position = 0; /* Reset position */
|
||||
|
||||
/* Increment the reference count on the root=next node. We
|
||||
|
|
@ -138,8 +138,8 @@ void rewinddir(FAR DIR *dirp)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
/* The node is part of the root psuedo file system */
|
||||
/* The node is part of the root pseudo file system */
|
||||
|
||||
rewindpsuedodir(idir);
|
||||
rewindpseudodir(idir);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@
|
|||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: seekpsuedodir
|
||||
* Name: seekpseudodir
|
||||
****************************************************************************/
|
||||
|
||||
static inline void seekpsuedodir(struct fs_dirent_s *idir, off_t offset)
|
||||
static inline void seekpseudodir(struct fs_dirent_s *idir, off_t offset)
|
||||
{
|
||||
struct inode *curr;
|
||||
struct inode *prev;
|
||||
|
|
@ -76,7 +76,7 @@ static inline void seekpsuedodir(struct fs_dirent_s *idir, off_t offset)
|
|||
else
|
||||
{
|
||||
pos = idir->fd_position;
|
||||
curr = idir->u.psuedo.fd_next;
|
||||
curr = idir->u.pseudo.fd_next;
|
||||
}
|
||||
|
||||
/* Traverse the peer list starting at the 'root' of the
|
||||
|
|
@ -90,8 +90,8 @@ static inline void seekpsuedodir(struct fs_dirent_s *idir, off_t offset)
|
|||
|
||||
/* Now get the inode to vist next time that readdir() is called */
|
||||
|
||||
prev = idir->u.psuedo.fd_next;
|
||||
idir->u.psuedo.fd_next = curr; /* The next node to visit (might be null) */
|
||||
prev = idir->u.pseudo.fd_next;
|
||||
idir->u.pseudo.fd_next = curr; /* The next node to visit (might be null) */
|
||||
idir->fd_position = pos; /* Might be beyond the last dirent */
|
||||
|
||||
if (curr)
|
||||
|
|
@ -223,8 +223,8 @@ void seekdir(FAR DIR *dirp, off_t offset)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
/* The node is part of the root psuedo file system */
|
||||
/* The node is part of the root pseudo file system */
|
||||
|
||||
seekpsuedodir(idir, offset);
|
||||
seekpseudodir(idir, offset);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
10
fs/fs_stat.c
10
fs/fs_stat.c
|
|
@ -51,10 +51,10 @@
|
|||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: statpsuedo
|
||||
* Name: statpseudo
|
||||
****************************************************************************/
|
||||
|
||||
static inline int statpsuedo(FAR struct inode *inode, FAR struct stat *buf)
|
||||
static inline int statpseudo(FAR struct inode *inode, FAR struct stat *buf)
|
||||
{
|
||||
/* Most of the stat entries just do not apply */
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ static inline int statpsuedo(FAR struct inode *inode, FAR struct stat *buf)
|
|||
{
|
||||
/* If it has no operations, then it must just be a intermediate
|
||||
* node in the inode tree. It is something like a directory.
|
||||
* We'll say that all psuedo-directories are read-able but not
|
||||
* We'll say that all pseudo-directories are read-able but not
|
||||
* write-able.
|
||||
*/
|
||||
|
||||
|
|
@ -195,9 +195,9 @@ int stat(const char *path, FAR struct stat *buf)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
/* The node is part of the root psuedo file system */
|
||||
/* The node is part of the root pseudo file system */
|
||||
|
||||
ret = statpsuedo(inode, buf);
|
||||
ret = statpseudo(inode, buf);
|
||||
}
|
||||
|
||||
/* Check if the stat operation was successful */
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@
|
|||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: statpsuedo
|
||||
* Name: statpseudo
|
||||
****************************************************************************/
|
||||
|
||||
static inline int statpsuedofs(FAR struct inode *inode, FAR struct statfs *buf)
|
||||
static inline int statpseudofs(FAR struct inode *inode, FAR struct statfs *buf)
|
||||
{
|
||||
memset(buf, 0, sizeof(struct statfs));
|
||||
buf->f_type = PROC_SUPER_MAGIC;
|
||||
|
|
@ -137,9 +137,9 @@ int statfs(FAR const char *path, FAR struct statfs *buf)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
/* The node is part of the root psuedo file system */
|
||||
/* The node is part of the root pseudo file system */
|
||||
|
||||
ret = statpsuedofs(inode, buf);
|
||||
ret = statpseudofs(inode, buf);
|
||||
}
|
||||
|
||||
/* Check if the statfs operation was successful */
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ int syslog_initialize(void)
|
|||
SYSLOG_OFLAGS, 0666);
|
||||
}
|
||||
|
||||
/* No... then it must be a character driver in the NuttX psuedo-
|
||||
/* No... then it must be a character driver in the NuttX pseudo-
|
||||
* file system.
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@
|
|||
* Name: unregister_blockdriver
|
||||
*
|
||||
* Description:
|
||||
* Remove the block driver inode at 'path' from the psuedo-file system
|
||||
* Remove the block driver inode at 'path' from the pseudo-file system
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@
|
|||
* Name: unregister_driver
|
||||
*
|
||||
* Description:
|
||||
* Remove the character driver inode at 'path' from the psuedo-file system
|
||||
* Remove the character driver inode at 'path' from the pseudo-file system
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -65,12 +65,12 @@
|
|||
* reference, a position, a dirent structure, and file-system-specific
|
||||
* information.
|
||||
*
|
||||
* For the root psuedo-file system, we need retain only the 'next' inode
|
||||
* For the root pseudo-file system, we need retain only the 'next' inode
|
||||
* need for the next readdir() operation. We hold a reference on this
|
||||
* inode so we know that it will persist until closedir is called.
|
||||
*/
|
||||
|
||||
struct fs_psuedodir_s
|
||||
struct fs_pseudodir_s
|
||||
{
|
||||
struct inode *fd_next; /* The inode for the next call to readdir() */
|
||||
};
|
||||
|
|
@ -140,7 +140,7 @@ struct fs_dirent_s
|
|||
{
|
||||
/* This is the node that was opened by opendir. The type of the inode
|
||||
* determines the way that the readdir() operations are performed. For the
|
||||
* psuedo root psuedo-file system, it is also used to support rewind.
|
||||
* pseudo root pseudo-file system, it is also used to support rewind.
|
||||
*
|
||||
* We hold a reference on this inode so we know that it will persist until
|
||||
* closedir() is called (although inodes linked to this inode may change).
|
||||
|
|
@ -166,9 +166,9 @@ struct fs_dirent_s
|
|||
|
||||
union
|
||||
{
|
||||
/* Private data used by the built-in psuedo-file system */
|
||||
/* Private data used by the built-in pseudo-file system */
|
||||
|
||||
struct fs_psuedodir_s psuedo;
|
||||
struct fs_pseudodir_s pseudo;
|
||||
|
||||
/* Private data used by other file systems */
|
||||
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ union inode_ops_u
|
|||
#endif
|
||||
};
|
||||
|
||||
/* This structure represents one inode in the Nuttx psuedo-file system */
|
||||
/* This structure represents one inode in the Nuttx pseudo-file system */
|
||||
|
||||
struct inode
|
||||
{
|
||||
|
|
@ -342,7 +342,7 @@ EXTERN void weak_function fs_initialize(void);
|
|||
* mountpoint inodes. It is intended to support the mount() command to
|
||||
* when the mount command is used to enumerate mounts.
|
||||
*
|
||||
* NOTE 1: Use with caution... The psuedo-file system is locked throughout
|
||||
* NOTE 1: Use with caution... The pseudo-file system is locked throughout
|
||||
* the traversal.
|
||||
* NOTE 2: The search algorithm is recursive and could, in principle, use
|
||||
* an indeterminant amount of stack space. This will not usually be a
|
||||
|
|
@ -415,7 +415,7 @@ EXTERN int register_blockdriver(const char *path,
|
|||
* Name: unregister_driver
|
||||
*
|
||||
* Description:
|
||||
* Remove the character driver inode at 'path' from the psuedo-file system
|
||||
* Remove the character driver inode at 'path' from the pseudo-file system
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
@ -426,7 +426,7 @@ EXTERN int unregister_driver(const char *path);
|
|||
* Name: unregister_blockdriver
|
||||
*
|
||||
* Description:
|
||||
* Remove the block driver inode at 'path' from the psuedo-file system
|
||||
* Remove the block driver inode at 'path' from the pseudo-file system
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue