mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:22:32 +08:00
Add losetup to NSH
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1243 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -553,4 +553,5 @@
|
|||||||
* Added a block to character (BCH) driver. This is kind of the reverse of the loop
|
* Added a block to character (BCH) driver. This is kind of the reverse of the loop
|
||||||
device; it allows you access a block device like a character device.
|
device; it allows you access a block device like a character device.
|
||||||
* Added strcasecmp() and strncasecmp()
|
* Added strcasecmp() and strncasecmp()
|
||||||
* NSH: Added 'dd' command
|
* NSH: Added the 'dd' command
|
||||||
|
* NSH: Added the 'losetup' command
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>NuttX</title>
|
<title>NuttShell</title>
|
||||||
</head>
|
</head>
|
||||||
<body background="backgd.gif">
|
<body background="backgd.gif">
|
||||||
<hr><hr>
|
<hr><hr>
|
||||||
@@ -149,127 +149,133 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdls">2.12 List Directory Contents (ls)</a>
|
<a href="#cmdlosetup">2.12 Setup/teardown the Loop Device (losetup)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdmbhw">2.13 Access Memory (mb, mh, and mw)</a>
|
<a href="#cmdls">2.13 List Directory Contents (ls)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdmem">2.14 Show Memory Manager Status (mem)</a>
|
<a href="#cmdmbhw">2.14 Access Memory (mb, mh, and mw)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdps">2.15 Show Current Tasks and Threads (ps)</a>
|
<a href="#cmdmem">2.15 Show Memory Manager Status (mem)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdmkdir">2.16 Create a Directory (mkdir)</a>
|
<a href="#cmdps">2.16 Show Current Tasks and Threads (ps)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdmkfatfs">2.17 Create a FAT Filesystem (mkfatfs)</a>
|
<a href="#cmdmkdir">2.17 Create a Directory (mkdir)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdmkfifo">2.18 Create a FIFO (mkfifo)</a>
|
<a href="#cmdmkfatfs">2.18 Create a FAT Filesystem (mkfatfs)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdmkrd">2.19 Create a RAMDISK (mkrd)</a>
|
<a href="#cmdmkfifo">2.19 Create a FIFO (mkfifo)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdmount">2.20 Mount a File System (mount)</a>
|
<a href="#cmdmkrd">2.20 Create a RAMDISK (mkrd)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdping">2.21 Check Network Peer (ping)</a>
|
<a href="#cmdmount">2.21 Mount a File System (mount)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdput">2.22 Send File Via TFTP (put)</a>
|
<a href="#cmdping">2.22 Check Network Peer (ping)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdpwd">2.23 Show Current Working Directory (pwd)</a>
|
<a href="#cmdput">2.23 Send File Via TFTP (put)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdrm">2.24 Remove a File (rm)</a>
|
<a href="#cmdpwd">2.24 Show Current Working Directory (pwd)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdrmdir">2.25 Remove a Directory (rmdir)</a>
|
<a href="#cmdrm">2.25 Remove a File (rm)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdset">2.26 Set an Environment Variable (set)</a>
|
<a href="#cmdrmdir">2.26 Remove a Directory (rmdir)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdsh">2.27 Execute an NSH Script (sh)</a>
|
<a href="#cmdset">2.27 Set an Environment Variable (set)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdsleep">2.28 Wait for Seconds (sleep)</a>
|
<a href="#cmdsh">2.28 Execute an NSH Script (sh)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdunmount">2.29 Unmount a File System (umount)</a>
|
<a href="#cmdsleep">2.29 Wait for Seconds (sleep)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdunset">2.30 Unset an Environment Variable (unset)</a>
|
<a href="#cmdunmount">2.30 Unmount a File System (umount)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdusleep">2.31 Wait for Microseconds (usleep)</a>
|
<a href="#cmdunset">2.31 Unset an Environment Variable (unset)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><br></td>
|
<td><br></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="#cmdxd">2.32 Hexadecimal Dump (xd)</a>
|
<a href="#cmdusleep">2.32 Wait for Microseconds (usleep)</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><br></td>
|
||||||
|
<td>
|
||||||
|
<a href="#cmdxd">2.33 Hexadecimal Dump (xd)</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -936,7 +942,33 @@ eth0 HWaddr 00:18:11:80:10:06
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdls"><h2>2.12 List Directory Contents (ls)</h2></a>
|
<a name="cmdlosetup"><h2>2.12 Setup/teardown the Loop Device (losetup)</h2></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<a <p><b>Command Syntax 1:</b></p>
|
||||||
|
<ul><pre>
|
||||||
|
losetup [-o <offset>] [-r] <dev-path> <file-path>
|
||||||
|
</pre></ul>
|
||||||
|
<p>
|
||||||
|
<b>Synopsis</b>.
|
||||||
|
Setup the loop device at <dev-path> to access the file at <file-path> as a block device:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<a <p><b>Command Syntax 2:</b></p>
|
||||||
|
<ul><pre>
|
||||||
|
losetup d <dev-path>
|
||||||
|
</pre></ul>
|
||||||
|
<p>
|
||||||
|
<b>Synopsis</b>.
|
||||||
|
Teardown the setup for the loop device at <dev-path>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<table width ="100%">
|
||||||
|
<tr bgcolor="#e4e4e4">
|
||||||
|
<td>
|
||||||
|
<a name="cmdls"><h2>2.13 List Directory Contents (ls)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -973,7 +1005,7 @@ ls [-lRs] <dir-path>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdmbhw"><h2>2.13 Access Memory (mb, mh, and mw)</h2></a>
|
<a name="cmdmbhw"><h2>2.14 Access Memory (mb, mh, and mw)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1027,7 +1059,7 @@ nsh>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdmem"><h2>2.14 Show Memory Manager Status (mem)</h2></a>
|
<a name="cmdmem"><h2>2.15 Show Memory Manager Status (mem)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1076,7 +1108,7 @@ nsh>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdps"><h2>2.15 Show Current Tasks and Threads (ps)</h2></a>
|
<a name="cmdps"><h2>2.16 Show Current Tasks and Threads (ps)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1102,7 +1134,7 @@ nsh>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdmkdir"><h2>2.16 Create a Directory (mkdir)</h2></a>
|
<a name="cmdmkdir"><h2>2.17 Create a Directory (mkdir)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1137,7 +1169,7 @@ nsh>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdmkfatfs"><h2>2.17 Create a FAT Filesystem (mkfatfs)</h2></a>
|
<a name="cmdmkfatfs"><h2>2.18 Create a FAT Filesystem (mkfatfs)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1157,7 +1189,7 @@ mkfatfs <path>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdmkfifo"><h2>2.18 Create a FIFO (mkfifo)</h2></a>
|
<a name="cmdmkfifo"><h2>2.19 Create a FIFO (mkfifo)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1195,7 +1227,7 @@ nsh>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdmkrd"><h2>2.19 Create a RAMDISK (mkrd)</h2></a>
|
<a name="cmdmkrd"><h2>2.20 Create a RAMDISK (mkrd)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1246,7 +1278,7 @@ nsh>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdmount"><h2>2.20 Mount a File System (mount)</h2></a>
|
<a name="cmdmount"><h2>2.21 Mount a File System (mount)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1313,7 +1345,7 @@ nsh>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdping"><h2>2.21 Check Network Peer (ping)</h2></a>
|
<a name="cmdping"><h2>2.22 Check Network Peer (ping)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1346,7 +1378,7 @@ nsh>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdput"><h2>2.22 Send File Via TFTP (put)</h2></a>
|
<a name="cmdput"><h2>2.23 Send File Via TFTP (put)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1381,7 +1413,7 @@ put [-b|-n] [-f <remote-path>] -h <ip-address> <local-path>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdpwd"><h2>2.23 Show Current Working Directory (pwd)</h2></a>
|
<a name="cmdpwd"><h2>2.24 Show Current Working Directory (pwd)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1411,7 +1443,7 @@ nsh>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdrm"><h2>2.24 Remove a File (rm)</h2></a>
|
<a name="cmdrm"><h2>2.25 Remove a File (rm)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1445,7 +1477,7 @@ nsh>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdrmdir"><h2>2.25 Remove a Directory (rmdir)</h2></a>
|
<a name="cmdrmdir"><h2>2.26 Remove a Directory (rmdir)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1480,7 +1512,7 @@ nsh>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdset"><h2>2.26 Set an Environment Variable (set)</h2></a>
|
<a name="cmdset"><h2>2.27 Set an Environment Variable (set)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1506,7 +1538,7 @@ nsh>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdsh"><h2>2.27 Execute an NSH Script (sh)</h2></a>
|
<a name="cmdsh"><h2>2.28 Execute an NSH Script (sh)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1524,7 +1556,7 @@ sh <script-path>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdsleep"><h2>2.28 Wait for Seconds (sleep)</h2></a>
|
<a name="cmdsleep"><h2>2.29 Wait for Seconds (sleep)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1541,7 +1573,7 @@ sleep <sec>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdunmount"><h2>2.29 Unmount a File System (umount)</h2></a>
|
<a name="cmdunmount"><h2>2.30 Unmount a File System (umount)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1571,7 +1603,7 @@ nsh>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdunset"><h2>2.30 Unset an Environment Variable (unset)</h2></a>
|
<a name="cmdunset"><h2>2.31 Unset an Environment Variable (unset)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1597,7 +1629,7 @@ nsh>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdusleep"><h2>2.31 Wait for Microseconds (usleep)</h2></a>
|
<a name="cmdusleep"><h2>2.32 Wait for Microseconds (usleep)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1614,7 +1646,7 @@ usleep <usec>
|
|||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
<tr bgcolor="#e4e4e4">
|
<tr bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<a name="cmdxd"><h2>2.32 Hexadecimal dump (xd)</h2></a>
|
<a name="cmdxd"><h2>2.33 Hexadecimal dump (xd)</h2></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1733,6 +1765,11 @@ nsh>
|
|||||||
<td><code>CONFIG_NET</code></td>
|
<td><code>CONFIG_NET</code></td>
|
||||||
<td><code>CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG</code></td>
|
<td><code>CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG</code></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b><code>losetup</code></b></td>
|
||||||
|
<td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td>
|
||||||
|
<td><code>CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP</code></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><b><code>ls</code></b></td>
|
<td><b><code>ls</code></b></td>
|
||||||
<td><code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td>
|
<td><code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td>
|
||||||
@@ -2159,6 +2196,7 @@ nsh>
|
|||||||
<li><a href="#cmdhelp"><code>help</code></a></li>
|
<li><a href="#cmdhelp"><code>help</code></a></li>
|
||||||
<li><a href="#conditional"><code>if-then[-else]-fi</code></a></li>
|
<li><a href="#conditional"><code>if-then[-else]-fi</code></a></li>
|
||||||
<li><a href="#cmdifconfig"><code>ifconfig</code></a></li>
|
<li><a href="#cmdifconfig"><code>ifconfig</code></a></li>
|
||||||
|
<li><a href="#cmdlosetup"><code>losetup</code></a></li>
|
||||||
<li><a href="#cmdls">ls</code></a></li>
|
<li><a href="#cmdls">ls</code></a></li>
|
||||||
<li><a href="#cmdmbhw"><code>mb</code></a></li>
|
<li><a href="#cmdmbhw"><code>mb</code></a></li>
|
||||||
<li><a href="#cmdmbhw"><code>mh</code></a></li>
|
<li><a href="#cmdmbhw"><code>mh</code></a></li>
|
||||||
|
|||||||
@@ -1195,7 +1195,8 @@ nuttx-0.3.18 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
|||||||
into very small memory footprints.
|
into very small memory footprints.
|
||||||
* Added a block to character (BCH) driver. This is kind of the reverse of the loop
|
* Added a block to character (BCH) driver. This is kind of the reverse of the loop
|
||||||
device; it allows you access a block device like a character device.
|
device; it allows you access a block device like a character device.
|
||||||
* NSH: Added 'dd' command
|
* NSH: Added the 'dd' command
|
||||||
|
* NSH: Added the 'losetup' command
|
||||||
|
|
||||||
pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
|
|
||||||
|
|||||||
+23
-9
@@ -328,6 +328,19 @@ o ifconfig
|
|||||||
if uIP statistics are enabled (CONFIG_NET_STATISTICS), then
|
if uIP statistics are enabled (CONFIG_NET_STATISTICS), then
|
||||||
this command will also show the detailed state of uIP.
|
this command will also show the detailed state of uIP.
|
||||||
|
|
||||||
|
o losetup [-d <dev-path>] | [[-o <offset>] [-r] <ldev-path> <file-path>]
|
||||||
|
|
||||||
|
Setup or teardown the loop device:
|
||||||
|
|
||||||
|
1. Teardown the setup for the loop device at <dev-path>:
|
||||||
|
|
||||||
|
losetup d <dev-path>
|
||||||
|
|
||||||
|
2. Setup the loop device at <dev-path> to access the file at <file-path>
|
||||||
|
as a block device:
|
||||||
|
|
||||||
|
losetup [-o <offset>] [-r] <dev-path> <file-path>
|
||||||
|
|
||||||
o ls [-lRs] <dir-path>
|
o ls [-lRs] <dir-path>
|
||||||
|
|
||||||
Show the contents of the directory at <dir-path>. NOTE:
|
Show the contents of the directory at <dir-path>. NOTE:
|
||||||
@@ -721,6 +734,7 @@ Command Dependencies on Configuration Settings
|
|||||||
get CONFIG_NET && CONFIG_NET_UDP && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NET_BUFSIZE >= 558 (see note 1)
|
get CONFIG_NET && CONFIG_NET_UDP && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NET_BUFSIZE >= 558 (see note 1)
|
||||||
help --
|
help --
|
||||||
ifconfig CONFIG_NET
|
ifconfig CONFIG_NET
|
||||||
|
losetup !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
ls CONFIG_NFILE_DESCRIPTORS > 0
|
ls CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
mb,mh,mw ---
|
mb,mh,mw ---
|
||||||
mem ---
|
mem ---
|
||||||
@@ -762,15 +776,15 @@ also allow it to squeeze into very small memory footprints.
|
|||||||
CONFIG_EXAMPLES_NSH_DISABLE_CAT, CONFIG_EXAMPLES_NSH_DISABLE_CD, CONFIG_EXAMPLES_NSH_DISABLE_CP,
|
CONFIG_EXAMPLES_NSH_DISABLE_CAT, CONFIG_EXAMPLES_NSH_DISABLE_CD, CONFIG_EXAMPLES_NSH_DISABLE_CP,
|
||||||
CONFIG_EXAMPLES_NSH_DISABLE_DD, CONFIG_EXAMPLES_NSH_DISABLE_ECHO, CONFIG_EXAMPLES_NSH_DISABLE_EXEC,
|
CONFIG_EXAMPLES_NSH_DISABLE_DD, CONFIG_EXAMPLES_NSH_DISABLE_ECHO, CONFIG_EXAMPLES_NSH_DISABLE_EXEC,
|
||||||
CONFIG_EXAMPLES_NSH_DISABLE_EXIT, CONFIG_EXAMPLES_NSH_DISABLE_GET, CONFIG_EXAMPLES_NSH_DISABLE_HELP,
|
CONFIG_EXAMPLES_NSH_DISABLE_EXIT, CONFIG_EXAMPLES_NSH_DISABLE_GET, CONFIG_EXAMPLES_NSH_DISABLE_HELP,
|
||||||
CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG, CONFIG_EXAMPLES_NSH_DISABLE_LS, CONFIG_EXAMPLES_NSH_DISABLE_MB,
|
CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG, CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP, CONFIG_EXAMPLES_NSH_DISABLE_LS,
|
||||||
CONFIG_EXAMPLES_NSH_DISABLE_MEM, CONFIG_EXAMPLES_NSH_DISABLE_MKDIR, CONFIG_EXAMPLES_NSH_DISABLE_MKFATFS,
|
CONFIG_EXAMPLES_NSH_DISABLE_MB, CONFIG_EXAMPLES_NSH_DISABLE_MEM, CONFIG_EXAMPLES_NSH_DISABLE_MKDIR,
|
||||||
CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO, CONFIG_EXAMPLES_NSH_DISABLE_MKRD, CONFIG_EXAMPLES_NSH_DISABLE_MH,
|
CONFIG_EXAMPLES_NSH_DISABLE_MKFATFS, CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO, CONFIG_EXAMPLES_NSH_DISABLE_MKRD,
|
||||||
CONFIG_EXAMPLES_NSH_DISABLE_MOUNT, CONFIG_EXAMPLES_NSH_DISABLE_MW, CONFIG_EXAMPLES_NSH_DISABLE_PS,
|
CONFIG_EXAMPLES_NSH_DISABLE_MH, CONFIG_EXAMPLES_NSH_DISABLE_MOUNT, CONFIG_EXAMPLES_NSH_DISABLE_MW,
|
||||||
CONFIG_EXAMPLES_NSH_DISABLE_PING, CONFIG_EXAMPLES_NSH_DISABLE_PUT, CONFIG_EXAMPLES_NSH_DISABLE_PWD,
|
CONFIG_EXAMPLES_NSH_DISABLE_PS, CONFIG_EXAMPLES_NSH_DISABLE_PING, CONFIG_EXAMPLES_NSH_DISABLE_PUT,
|
||||||
CONFIG_EXAMPLES_NSH_DISABLE_RM, CONFIG_EXAMPLES_NSH_DISABLE_RMDIR, CONFIG_EXAMPLES_NSH_DISABLE_SET,
|
CONFIG_EXAMPLES_NSH_DISABLE_PWD, CONFIG_EXAMPLES_NSH_DISABLE_RM, CONFIG_EXAMPLES_NSH_DISABLE_RMDIR,
|
||||||
CONFIG_EXAMPLES_NSH_DISABLE_SH, CONFIG_EXAMPLES_NSH_DISABLE_SLEEP, CONFIG_EXAMPLES_NSH_DISABLE_TEST,
|
CONFIG_EXAMPLES_NSH_DISABLE_SET, CONFIG_EXAMPLES_NSH_DISABLE_SH, CONFIG_EXAMPLES_NSH_DISABLE_SLEEP,
|
||||||
CONFIG_EXAMPLES_NSH_DISABLE_UMOUNT, CONFIG_EXAMPLES_NSH_DISABLE_UNSET, CONFIG_EXAMPLES_NSH_DISABLE_USLEEP,
|
CONFIG_EXAMPLES_NSH_DISABLE_TEST, CONFIG_EXAMPLES_NSH_DISABLE_UMOUNT, CONFIG_EXAMPLES_NSH_DISABLE_UNSET,
|
||||||
CONFIG_EXAMPLES_NSH_DISABLE_XD
|
CONFIG_EXAMPLES_NSH_DISABLE_USLEEP, CONFIG_EXAMPLES_NSH_DISABLE_XD
|
||||||
|
|
||||||
NSH-Specific Configuration Settings
|
NSH-Specific Configuration Settings
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|||||||
@@ -378,6 +378,9 @@ extern int cmd_lbracket(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
|||||||
# endif
|
# endif
|
||||||
# endif /* CONFIG_NFILE_STREAMS && !CONFIG_EXAMPLES_NSH_DISABLESCRIPT */
|
# endif /* CONFIG_NFILE_STREAMS && !CONFIG_EXAMPLES_NSH_DISABLESCRIPT */
|
||||||
# ifndef CONFIG_DISABLE_MOUNTPOINT
|
# ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||||
|
# ifndef CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP
|
||||||
|
extern int cmd_losetup(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||||
|
# endif
|
||||||
# ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO
|
# ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO
|
||||||
extern int cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
extern int cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||||
# endif
|
# endif
|
||||||
|
|||||||
@@ -647,6 +647,128 @@ errout:
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: cmd_losetup
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)
|
||||||
|
#ifndef CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP
|
||||||
|
int cmd_losetup(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
|
{
|
||||||
|
char *loopdev = NULL;
|
||||||
|
char *filepath = NULL;
|
||||||
|
boolean teardown = FALSE;
|
||||||
|
boolean readonly = FALSE;
|
||||||
|
off_t offset = 0;
|
||||||
|
int ret = ERROR;
|
||||||
|
int option;
|
||||||
|
|
||||||
|
/* Get the losetup options: Two forms are supported:
|
||||||
|
*
|
||||||
|
* losetup -d <loop-device>
|
||||||
|
* losetup [-o <offset>] [-r] <loop-device> <filename>
|
||||||
|
*
|
||||||
|
* NOTE that the -o and -r options are accepted with the -d option, but
|
||||||
|
* will be ignored.
|
||||||
|
*/
|
||||||
|
|
||||||
|
while ((option = getopt(argc, argv, "d:o:r")) != ERROR)
|
||||||
|
{
|
||||||
|
switch (option)
|
||||||
|
{
|
||||||
|
case 'd':
|
||||||
|
loopdev = nsh_getfullpath(vtbl, optarg);
|
||||||
|
teardown = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'o':
|
||||||
|
offset = atoi(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'r':
|
||||||
|
readonly = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '?':
|
||||||
|
default:
|
||||||
|
nsh_output(vtbl, g_fmtarginvalid, argv[0]);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If this is not a tear down operation, then additional command line
|
||||||
|
* parameters are required.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!teardown)
|
||||||
|
{
|
||||||
|
/* There must be two arguments on the command line after the options */
|
||||||
|
|
||||||
|
if (optind + 1 < argc)
|
||||||
|
{
|
||||||
|
loopdev = nsh_getfullpath(vtbl, argv[optind]);
|
||||||
|
optind++;
|
||||||
|
|
||||||
|
filepath = nsh_getfullpath(vtbl, argv[optind]);
|
||||||
|
optind++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmtargrequired, argv[0]);
|
||||||
|
goto errout_with_paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* There should be nothing else on the command line */
|
||||||
|
|
||||||
|
if (optind < argc)
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmttoomanyargs, argv[0]);
|
||||||
|
goto errout_with_paths;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Perform the teardown operation */
|
||||||
|
|
||||||
|
if (teardown)
|
||||||
|
{
|
||||||
|
/* Tear down the loop device. */
|
||||||
|
|
||||||
|
ret = loteardown(loopdev);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "loteardown", NSH_ERRNO_OF(-ret));
|
||||||
|
goto errout_with_paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Set up the loop device */
|
||||||
|
|
||||||
|
ret = losetup(loopdev, filepath, 512, offset, readonly);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "losetup", NSH_ERRNO_OF(-ret));
|
||||||
|
goto errout_with_paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free memory */
|
||||||
|
|
||||||
|
errout_with_paths:
|
||||||
|
if (loopdev)
|
||||||
|
{
|
||||||
|
free(loopdev);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filepath)
|
||||||
|
{
|
||||||
|
free(filepath);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: cmd_ls
|
* Name: cmd_ls
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -188,6 +188,12 @@ static const struct cmdmap_s g_cmdmap[] =
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)
|
||||||
|
# ifndef CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP
|
||||||
|
{ "losetup", cmd_losetup, 3, 6, "[-d <dev-path>] | [[-o <offset>] [-r] <dev-path> <file-path>]" },
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
# ifndef CONFIG_EXAMPLES_NSH_DISABLE_LS
|
# ifndef CONFIG_EXAMPLES_NSH_DISABLE_LS
|
||||||
{ "ls", cmd_ls, 1, 5, "[-lRs] <dir-path>" },
|
{ "ls", cmd_ls, 1, 5, "[-lRs] <dir-path>" },
|
||||||
|
|||||||
Reference in New Issue
Block a user