Add NSH command to create RAMDISK
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@884 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
5d0513e1a1
commit
72e20b303a
@ -451,4 +451,6 @@
|
||||
* NSH: Created an HTML document and a more detailed README file describing NSH.
|
||||
* Added basic TFTP client logic (netutils/tftpc). Untested as of initial check-in.
|
||||
* NSH: Add get and put commands to support TFTP get and put operations.
|
||||
* NSH: Added a mkrd command that will create a RAMDISK that can be formatted
|
||||
and mounted.
|
||||
|
||||
|
@ -179,73 +179,79 @@
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<a href="#cmdmount">2.18 Mount a File System (mount)</a>
|
||||
<a href="#cmdmkrd">2.18 Create a RAMDISK (mkrd)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<a href="#cmdping">2.19 Check Network Peer (ping)</a>
|
||||
<a href="#cmdmount">2.19 Mount a File System (mount)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<a href="#cmdput">2.20 Send File Via TFTP (put)</a>
|
||||
<a href="#cmdping">2.20 Check Network Peer (ping)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<a href="#cmdpwd">2.21 Show Current Working Directory (pwd)</a>
|
||||
<a href="#cmdput">2.21 Send File Via TFTP (put)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<a href="#cmdrm">2.22 Remove a File (rm)</a>
|
||||
<a href="#cmdpwd">2.22 Show Current Working Directory (pwd)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<a href="#cmdrmdir">2.23 Remove a Directory (rmdir)</a>
|
||||
<a href="#cmdrm">2.23 Remove a File (rm)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<a href="#cmdset">2.24 Set an Environment Variable (set)</a>
|
||||
<a href="#cmdrmdir">2.24 Remove a Directory (rmdir)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<a href="#cmdsh">2.25 Execute an NSH Script (sh)</a>
|
||||
<a href="#cmdset">2.25 Set an Environment Variable (set)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<a href="#cmdsleep">2.26 Wait for Seconds (sleep)</a>
|
||||
<a href="#cmdsh">2.26 Execute an NSH Script (sh)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<a href="#cmdunmount">2.27 Unmount a File System (umount)</a>
|
||||
<a href="#cmdsleep">2.27 Wait for Seconds (sleep)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<a href="#cmdunset">2.28 Unset an Environment Variable (unset)</a>
|
||||
<a href="#cmdunmount">2.28 Unmount a File System (umount)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<a href="#cmdusleep">2.29 Wait for Microseconds (usleep)</a>
|
||||
<a href="#cmdunset">2.29 Unset an Environment Variable (unset)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<a href="#cmdusleep">2.30 Wait for Microseconds (usleep)</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -989,7 +995,58 @@ nsh>
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="cmdmount"><h2>2.18 Mount a File System (mount)</h2></a>
|
||||
<a name="cmdmkrd"><h2>2.18 Create a RAMDISK (mkrd)</h2></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p><b>Command Syntax:</b></p>
|
||||
<ul><pre>
|
||||
mkrd [-m <minor>] [-s <sector-size>] <nsectors>
|
||||
</pre></ul>
|
||||
<p>
|
||||
<b>Synopsis</b>.
|
||||
Create a ramdisk consisting of <code><nsectors></code>, each of size
|
||||
<code><sector-size></code> (or 512 bytes if <code><sector-size></code> is not specified.
|
||||
The ramdisk will be registered as <code>/dev/ram<n></code> (if <code><n></code> is not
|
||||
specified, mkrd will attempt to register the ramdisk as <code>/dev/ram0</code>.
|
||||
</p>
|
||||
<p><b>Example</b></p>
|
||||
<ul><pre>
|
||||
nsh> ls /dev
|
||||
/dev:
|
||||
console
|
||||
null
|
||||
ttyS0
|
||||
ttyS1
|
||||
nsh> mkrd 1024
|
||||
nsh> ls /dev
|
||||
/dev:
|
||||
console
|
||||
null
|
||||
ram0
|
||||
ttyS0
|
||||
ttyS1
|
||||
nsh>
|
||||
</pre></ul>
|
||||
<p>
|
||||
Once the ramdisk has been created, it may be formatted using
|
||||
the <code>mkfatfs</code> command and mounted using the <code>mount</code> command.
|
||||
</p>
|
||||
<p><b>Example</b></p>
|
||||
<ul><pre>
|
||||
nsh> mkrd 1024
|
||||
nsh> mkfatfs /dev/ram0
|
||||
nsh> mount -t vfat /dev/ram0 /tmp
|
||||
nsh> ls /tmp
|
||||
/tmp:
|
||||
nsh>
|
||||
</pre></ul>
|
||||
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="cmdmount"><h2>2.19 Mount a File System (mount)</h2></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1056,7 +1113,7 @@ nsh>
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="cmdping"><h2>2.19 Check Network Peer (ping)</h2></a>
|
||||
<a name="cmdping"><h2>2.20 Check Network Peer (ping)</h2></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1089,7 +1146,7 @@ nsh>
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="cmdput"><h2>2.20 Send File Via TFTP (put)</h2></a>
|
||||
<a name="cmdput"><h2>2.21 Send File Via TFTP (put)</h2></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1124,7 +1181,7 @@ put [-b|-n] [-f <remote-path>] -h <ip-address> <local-path>
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="cmdpwd"><h2>2.21 Show Current Working Directory (pwd)</h2></a>
|
||||
<a name="cmdpwd"><h2>2.22 Show Current Working Directory (pwd)</h2></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1154,7 +1211,7 @@ nsh>
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="cmdrm"><h2>2.22 Remove a File (rm)</h2></a>
|
||||
<a name="cmdrm"><h2>2.23 Remove a File (rm)</h2></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1188,7 +1245,7 @@ nsh>
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="cmdrmdir"><h2>2.23 Remove a Directory (rmdir)</h2></a>
|
||||
<a name="cmdrmdir"><h2>2.24 Remove a Directory (rmdir)</h2></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1223,7 +1280,7 @@ nsh>
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="cmdset"><h2>2.24 Set an Environment Variable (set)</h2></a>
|
||||
<a name="cmdset"><h2>2.25 Set an Environment Variable (set)</h2></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1249,7 +1306,7 @@ nsh>
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="cmdsh"><h2>2.25 Execute an NSH Script (sh)</h2></a>
|
||||
<a name="cmdsh"><h2>2.26 Execute an NSH Script (sh)</h2></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1267,7 +1324,7 @@ sh <script-path>
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="cmdsleep"><h2>2.26 Wait for Seconds (sleep)</h2></a>
|
||||
<a name="cmdsleep"><h2>2.27 Wait for Seconds (sleep)</h2></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1284,7 +1341,7 @@ sleep <sec>
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="cmdunmount"><h2>2.27 Unmount a File System (umount)</h2></a>
|
||||
<a name="cmdunmount"><h2>2.28 Unmount a File System (umount)</h2></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1314,7 +1371,7 @@ nsh>
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="cmdunset"><h2>2.28 Unset an Environment Variable (unset)</h2></a>
|
||||
<a name="cmdunset"><h2>2.29 Unset an Environment Variable (unset)</h2></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1340,7 +1397,7 @@ nsh>
|
||||
<table width ="100%">
|
||||
<tr bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<a name="cmdusleep"><h2>2.29 Wait for Microseconds (usleep)</h2></a>
|
||||
<a name="cmdusleep"><h2>2.30 Wait for Microseconds (usleep)</h2></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1448,7 +1505,11 @@ usleep <usec>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b><code>mkfifo</code></b></td>
|
||||
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td>
|
||||
<td><code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b><code>mkrd</code></b></td>
|
||||
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_FS_FAT</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b><code>mount</code></b></td>
|
||||
@ -1711,6 +1772,7 @@ usleep <usec>
|
||||
<li><a href="#cmdmkdir"><code>mkdir</code></a></li>
|
||||
<li><a href="#cmdmkfatfs"><code>mkfatfs</code></a></li>
|
||||
<li><a href="#cmdmkfifo"><code>mkfifo</code></a></li>
|
||||
<li><a href="#cmdmkrd"><code>mkrd</code></a></li>
|
||||
<li><a href="#cmdmount"><code>mount</code></a></li>
|
||||
<li><a href="#cmdoverview"><code>nice</code></a></li>
|
||||
<li><a href="#environvars"><code>OLDPWD</code></a></li>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<tr align="center" bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
|
||||
<p>Last Updated: September 5, 2008</p>
|
||||
<p>Last Updated: September 6, 2008</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1078,6 +1078,8 @@ nuttx-0.3.14 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* NSH: Created an HTML document and a more detailed README file describing NSH.
|
||||
* Added basic TFTP client logic (netutils/tftpc). Untested as of initial check-in.
|
||||
* NSH: Add get and put commands to support TFTP get and put operations.
|
||||
* NSH: Added a mkrd command that will create a RAMDISK that can be formatted
|
||||
and mounted.
|
||||
|
||||
pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
|
@ -78,21 +78,21 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
int i;
|
||||
#endif
|
||||
|
||||
dbg(" TCB=%p name=%s\n", tcb, tcb->argv[0]);
|
||||
sdbg(" TCB=%p name=%s\n", tcb, tcb->argv[0]);
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
if (tcb->filelist)
|
||||
{
|
||||
dbg(" filelist refcount=%d\n",
|
||||
tcb->filelist->fl_crefs);
|
||||
sdbg(" filelist refcount=%d\n",
|
||||
tcb->filelist->fl_crefs);
|
||||
|
||||
for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++)
|
||||
{
|
||||
struct inode *inode = tcb->filelist->fl_files[i].f_inode;
|
||||
if (inode)
|
||||
{
|
||||
dbg(" fd=%d refcount=%d\n",
|
||||
i, inode->i_crefs);
|
||||
sdbg(" fd=%d refcount=%d\n",
|
||||
i, inode->i_crefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,8 +101,8 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
if (tcb->streams)
|
||||
{
|
||||
dbg(" streamlist refcount=%d\n",
|
||||
tcb->streams->sl_crefs);
|
||||
sdbg(" streamlist refcount=%d\n",
|
||||
tcb->streams->sl_crefs);
|
||||
|
||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||
{
|
||||
@ -110,11 +110,11 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
if (filep->fs_filedes >= 0)
|
||||
{
|
||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||
dbg(" fd=%d nbytes=%d\n",
|
||||
filep->fs_filedes,
|
||||
sdbg(" fd=%d nbytes=%d\n",
|
||||
filep->fs_filedes,
|
||||
filep->fs_bufpos - filep->fs_bufstart);
|
||||
#else
|
||||
dbg(" fd=%d\n", filep->fs_filedes);
|
||||
sdbg(" fd=%d\n", filep->fs_filedes);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -148,10 +148,10 @@ void _exit(int status)
|
||||
|
||||
(void)irqsave();
|
||||
|
||||
lldbg("TCB=%p exitting\n", tcb);
|
||||
slldbg("TCB=%p exitting\n", tcb);
|
||||
|
||||
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
|
||||
lldbg("Other tasks:\n");
|
||||
slldbg("Other tasks:\n");
|
||||
sched_foreach(_up_dumponexit, NULL);
|
||||
#endif
|
||||
|
||||
@ -164,7 +164,7 @@ void _exit(int status)
|
||||
*/
|
||||
|
||||
tcb = (_TCB*)g_readytorun.head;
|
||||
lldbg("New Active Task TCB=%p\n", tcb);
|
||||
slldbg("New Active Task TCB=%p\n", tcb);
|
||||
|
||||
/* Then switch contexts */
|
||||
|
||||
|
@ -75,12 +75,12 @@
|
||||
static void up_calibratedelay(void)
|
||||
{
|
||||
int i;
|
||||
lldbg("Beginning 100s delay\n");
|
||||
slldbg("Beginning 100s delay\n");
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
up_mdelay(1000);
|
||||
}
|
||||
lldbg("End 100s delay\n");
|
||||
slldbg("End 100s delay\n");
|
||||
}
|
||||
#else
|
||||
# define up_calibratedelay()
|
||||
|
@ -76,7 +76,7 @@ void up_release_pending(void)
|
||||
{
|
||||
_TCB *rtcb = (_TCB*)g_readytorun.head;
|
||||
|
||||
lldbg("From TCB=%p\n", rtcb);
|
||||
slldbg("From TCB=%p\n", rtcb);
|
||||
|
||||
/* Merge the g_pendingtasks list into the g_readytorun task list */
|
||||
|
||||
@ -101,7 +101,7 @@ void up_release_pending(void)
|
||||
*/
|
||||
|
||||
rtcb = (_TCB*)g_readytorun.head;
|
||||
lldbg("New Active Task TCB=%p\n", rtcb);
|
||||
slldbg("New Active Task TCB=%p\n", rtcb);
|
||||
|
||||
/* Then switch contexts */
|
||||
|
||||
@ -121,7 +121,7 @@ void up_release_pending(void)
|
||||
*/
|
||||
|
||||
rtcb = (_TCB*)g_readytorun.head;
|
||||
lldbg("New Active Task TCB=%p\n", rtcb);
|
||||
slldbg("New Active Task TCB=%p\n", rtcb);
|
||||
|
||||
/* Then switch contexts */
|
||||
|
||||
|
@ -97,7 +97,7 @@ void up_reprioritize_rtr(_TCB *tcb, ubyte priority)
|
||||
_TCB *rtcb = (_TCB*)g_readytorun.head;
|
||||
boolean switch_needed;
|
||||
|
||||
lldbg("TCB=%p PRI=%d\n", tcb, priority);
|
||||
slldbg("TCB=%p PRI=%d\n", tcb, priority);
|
||||
|
||||
/* Remove the tcb task from the ready-to-run list.
|
||||
* sched_removereadytorun will return TRUE if we just
|
||||
@ -149,7 +149,7 @@ void up_reprioritize_rtr(_TCB *tcb, ubyte priority)
|
||||
*/
|
||||
|
||||
rtcb = (_TCB*)g_readytorun.head;
|
||||
lldbg("New Active Task TCB=%p\n", rtcb);
|
||||
slldbg("New Active Task TCB=%p\n", rtcb);
|
||||
|
||||
/* Then switch contexts */
|
||||
|
||||
@ -168,7 +168,7 @@ void up_reprioritize_rtr(_TCB *tcb, ubyte priority)
|
||||
*/
|
||||
|
||||
rtcb = (_TCB*)g_readytorun.head;
|
||||
lldbg("New Active Task TCB=%p\n", rtcb);
|
||||
slldbg("New Active Task TCB=%p\n", rtcb);
|
||||
|
||||
/* Then switch contexts */
|
||||
|
||||
|
@ -99,7 +99,7 @@ void up_schedule_sigaction(_TCB *tcb, sig_deliver_t sigdeliver)
|
||||
{
|
||||
/* Refuse to handle nested signal actions */
|
||||
|
||||
dbg("tcb=0x%p sigdeliver=0x%p\n", tcb, sigdeliver);
|
||||
sdbg("tcb=0x%p sigdeliver=0x%p\n", tcb, sigdeliver);
|
||||
|
||||
if (!tcb->xcp.sigdeliver)
|
||||
{
|
||||
@ -113,7 +113,7 @@ void up_schedule_sigaction(_TCB *tcb, sig_deliver_t sigdeliver)
|
||||
* being delivered to the currently executing task.
|
||||
*/
|
||||
|
||||
dbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs);
|
||||
sdbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs);
|
||||
|
||||
if (tcb == (_TCB*)g_readytorun.head)
|
||||
{
|
||||
|
@ -90,8 +90,8 @@ void up_sigdeliver(void)
|
||||
|
||||
up_ledon(LED_SIGNAL);
|
||||
|
||||
dbg("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
|
||||
rtcb, rtcb->xcp.sigdeliver, rtcb->sigpendactionq.head);
|
||||
sdbg("rtcb=%p sigdeliver=%p sigpendactionq.head=%p\n",
|
||||
rtcb, rtcb->xcp.sigdeliver, rtcb->sigpendactionq.head);
|
||||
ASSERT(rtcb->xcp.sigdeliver != NULL);
|
||||
|
||||
/* Save the real return state on the stack. */
|
||||
@ -124,7 +124,7 @@ void up_sigdeliver(void)
|
||||
* (it is probably EINTR).
|
||||
*/
|
||||
|
||||
dbg("Resuming\n");
|
||||
sdbg("Resuming\n");
|
||||
rtcb->pterrno = saved_errno;
|
||||
|
||||
/* Then restore the correct state for this thread of
|
||||
|
@ -39,7 +39,7 @@ examples/mount
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
This contains a simple test of filesystem mountpoints.
|
||||
|
||||
|
||||
* CONFIG_EXAMPLES_MOUNT_DEVNAME
|
||||
The name of the user-provided block device to mount.
|
||||
If CONFIG_EXAMPLES_MOUNT_DEVNAME is not provided, then
|
||||
|
@ -325,6 +325,45 @@ o mkfifo <path>
|
||||
brw-rw-rw- 0 ram0
|
||||
nsh>
|
||||
|
||||
o mkrd [-m <minor>] [-s <sector-size>] <nsectors>
|
||||
|
||||
Create a ramdisk consisting of <nsectors>, each of size
|
||||
<sector-size> (or 512 bytes if <sector-size> is not specified.
|
||||
The ramdisk will be registered as /dev/ram<n> (if <n> is not
|
||||
specified, mkrd will attempt to register the ramdisk as
|
||||
/dev/ram0.
|
||||
|
||||
Example:
|
||||
^^^^^^^^
|
||||
|
||||
nsh> ls /dev
|
||||
/dev:
|
||||
console
|
||||
null
|
||||
ttyS0
|
||||
ttyS1
|
||||
nsh> mkrd 1024
|
||||
nsh> ls /dev
|
||||
/dev:
|
||||
console
|
||||
null
|
||||
ram0
|
||||
ttyS0
|
||||
ttyS1
|
||||
nsh>
|
||||
|
||||
Once the ramdisk has been created, it may be formatted using
|
||||
the mkfatfs command and mounted using the mount command.
|
||||
|
||||
Example:
|
||||
^^^^^^^^
|
||||
nsh> mkrd 1024
|
||||
nsh> mkfatfs /dev/ram0
|
||||
nsh> mount -t vfat /dev/ram0 /tmp
|
||||
nsh> ls /tmp
|
||||
/tmp:
|
||||
nsh>
|
||||
|
||||
o mount -t <fstype> <block-device> <dir-path>
|
||||
|
||||
The 'mount' command mounts a file system in the NuttX psuedo
|
||||
@ -543,7 +582,8 @@ Command Dependencies on Configuration Settings
|
||||
mem ---
|
||||
mkdir !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
mkfatfs !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_FAT
|
||||
mkfifo !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
mkfifo CONFIG_NFILE_DESCRIPTORS > 0
|
||||
mkrd !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_FAT
|
||||
mount !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_FAT
|
||||
ping CONFIG_NET && CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING && !CONFIG_DISABLE_CLOCK && !CONFIG_DISABLE_SIGNALS
|
||||
ps --
|
||||
|
@ -284,6 +284,7 @@ extern int cmd_lbracket(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
# ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
extern int cmd_mkdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern int cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern int cmd_rm(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
extern int cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
# ifdef CONFIG_FS_FAT
|
||||
|
@ -48,6 +48,7 @@
|
||||
# include <sys/mount.h>
|
||||
# include <nuttx/mkfatfs.h>
|
||||
# endif
|
||||
# include <nuttx/ramdisk.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -756,7 +757,7 @@ int cmd_mkfatfs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
* Name: cmd_mkfifo
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
int cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
char *fullpath = nsh_getfullpath(vtbl, argv[1]);
|
||||
@ -775,6 +776,99 @@ int cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cmd_mkrd
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
const char *fmt;
|
||||
ubyte *buffer;
|
||||
uint32 nsectors;
|
||||
int sectsize = 512;
|
||||
int minor = 0;
|
||||
int ret;
|
||||
|
||||
/* Get the mount options */
|
||||
|
||||
int option;
|
||||
while ((option = getopt(argc, argv, ":m:s:")) != ERROR)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
case 'm':
|
||||
minor = atoi(optarg);
|
||||
if (minor < 0 || minor > 255)
|
||||
{
|
||||
fmt = g_fmtargrange;
|
||||
goto errout_with_fmt;
|
||||
}
|
||||
break;
|
||||
|
||||
case 's':
|
||||
sectsize = atoi(optarg);
|
||||
if (minor < 0 || minor > 16384)
|
||||
{
|
||||
fmt = g_fmtargrange;
|
||||
goto errout_with_fmt;
|
||||
}
|
||||
break;
|
||||
|
||||
case ':':
|
||||
fmt = g_fmtargrequired;
|
||||
goto errout_with_fmt;
|
||||
|
||||
case '?':
|
||||
default:
|
||||
fmt = g_fmtarginvalid;
|
||||
goto errout_with_fmt;
|
||||
}
|
||||
}
|
||||
|
||||
/* There should be exactly on parameter left on the command-line */
|
||||
|
||||
if (optind == argc-1)
|
||||
{
|
||||
nsectors = (uint32)atoi(argv[optind]);
|
||||
}
|
||||
else if (optind >= argc)
|
||||
{
|
||||
fmt = g_fmttoomanyargs;
|
||||
goto errout_with_fmt;
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt = g_fmtargrequired;
|
||||
goto errout_with_fmt;
|
||||
}
|
||||
|
||||
/* Allocate the memory backing up the ramdisk */
|
||||
|
||||
buffer = (ubyte*)malloc(sectsize * nsectors);
|
||||
if (!buffer)
|
||||
{
|
||||
fmt = g_fmtcmdoutofmemory;
|
||||
goto errout_with_fmt;
|
||||
}
|
||||
|
||||
/* Then register the ramdisk */
|
||||
|
||||
ret = rd_register(minor, buffer, nsectors, sectsize, TRUE);
|
||||
if (ret < 0)
|
||||
{
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "rd_register", NSH_ERRNO_OF(-ret));
|
||||
free(buffer);
|
||||
return ERROR;
|
||||
}
|
||||
return ret;
|
||||
|
||||
errout_with_fmt:
|
||||
nsh_output(vtbl, fmt, argv[0]);
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cmd_mount
|
||||
****************************************************************************/
|
||||
|
@ -163,6 +163,7 @@ static const struct cmdmap_s g_cmdmap[] =
|
||||
{ "mkfatfs", cmd_mkfatfs, 2, 2, "<path>" },
|
||||
#endif
|
||||
{ "mkfifo", cmd_mkfifo, 2, 2, "<path>" },
|
||||
{ "mkrd", cmd_mkrd, 2, 6, "[-m <minor>] [-s <sector-size>] <nsectors>" },
|
||||
#endif
|
||||
{ "mh", cmd_mh, 2, 3, "<hex-address>[=<hex-value>][ <hex-byte-count>]" },
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user