📄 c-fileaxs2.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> File Access Applications </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-fileaxs.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-fileaxs.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-fileaxs1.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-fileaxs3.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="90008">11.2 RSH and FTP </a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="90010"> </a>The VxWorks I/O driver <b class="library">netDrv</b> implements remote file access using either of the protocols, RSH or FTP. The <b class="library">netDrv</b> driver uses these protocols to read the entire remote file into local memory when the file is opened, and to write the file back when it is closed (if it was modified).</p><dd><p class="Body"><a name="90011"> </a>The VxWorks I/O driver <b class="library">nfsDrv</b> implements remote file access using NFS. This protocol transfers only the data actually read or written to the file and thus is considerably more efficient, both in terms of memory utilization and throughput. However, it is somewhat more cumbersome to set up initially than the other protocols. The following sections describe the implementation and configuration of these protocols.</p><dd><p class="Body"><a name="90012"> </a>A separate VxWorks I/O device is created for every host that services remote file accesses. When a file on one of these devices is accessed, <b class="library">netDrv</b> uses either RSH or FTP to transfer the file to or from VxWorks: </p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="90014"> </a>Using RSH, <b class="library">netDrv</b> remotely executes the <b class="command">cat</b> command to copy the entire requested file to and from the target. The RSH protocol is serviced by the remote shell daemon <b class="command">rshd</b>. See the reference entry for <b class="library">remLib</b>.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="90017"> </a>Using FTP, <b class="library">netDrv</b> uses the <b class="symbol_UC">RETR</b> and <b class="symbol_UC">STOR</b> commands to retrieve and store the entire requested file. The <b class="library">netDrv</b> driver uses a library of routines, in <b class="library">ftpLib</b>, that implements the client side for the Internet File Transfer Protocol. VxWorks tasks can transfer files to and from FTP servers on the network and invoke other FTP functions. See the reference entry for <b class="library">ftpLib</b>.</li></ul></p></dl><dl class="margin"><dd><p class="Body"><a name="90019"> </a>VxWorks can also function as an FTP server. The FTP daemon running on a VxWorks server handles calls from host system and VxWorks clients, and can also boot another VxWorks system. To boot from the VxWorks server with a local disk, specify the Internet address of the VxWorks server in the <b class="symbol_lc">host inet</b> field of the boot parameters, supply a password in the <b class="symbol_lc">ftp password</b> field, and specify the shared-memory network as the boot device. </p><dd><p class="Body"><a name="90023"> </a>In the following example (also see <a href="c-fileaxs2.html#90036">Figure 11-1</a>), a slave on the shared-memory network boots from the master CPU's local SCSI disk. (For more information on shared-memory networks, see <a href="c-dll5.html#85549"><i class="title">3.5 Shared-Memory Network on the Backplane</i></a>.) Note that VxWorks requires a non-empty <b class="symbol_lc">ftp password</b> field. This is true even if VxWorks is configured with FTP server security turned off (the default). The relevant configuration macro is <b class="symbol_UC">INCLUDE_FTPD_SECURITY</b>. However, if FTP security checks are turned on, the <b class="symbol_lc">ftp password </b>field must contain a valid password for the specified user.<b class="symbol_lc"> </b></p><dd><p class="Body"><a name="90028"> </a>The following boot parameters are for the slave processor (<b>vxSlave</b>):</p><dl class="margin"><dd><pre class="Code2"><b><a name="90029">boot device : sm=0x800000 processor number : 1 host name : vxServer file name : /sd0/vx2 inet on backplane (b) : 161.27.0.2 host inet (h) : 161.27.0.1 user (u) : caraboo ftp password (pw) (blank=use rsh) : ignored </a></b></pre></dl><dd><p class="Body"><a name="90030"> </a>The FTP server daemon is initialized on the VxWorks server based on the configuration. The relevant configuration macro is <b class="symbol_UC">INCLUDE_FTP_SERVER</b>. See also the reference entry for <b class="library">ftpdLib</b>. <div class="frame"><h4 class="EntityTitle"><a name="90036"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 11-1: FTP Boot Example</font></a></h4><dl class="margin"><div class="Anchor"><a name="90067"> </a><img class="figure" border="0" src="images/c-fileaxsa.gif"></div></dl></div></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="90069">11.2.1 Allowing Remote File Access with RSH </a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="90071"> </a>An RSH request includes the name of the requesting user. The request is treated like a remote login by that user. </p><dd><p class="Body"><a name="90072"> </a>For Windows hosts, the availability and functionality of this facility is determined by your version of Windows and the networking software you are using. See that documentation for details.</p><dd><p class="Body"><a name="90074"> </a>For UNIX hosts, such remote logins are restricted by means of the host file <b class="file">.rhosts</b> in the user's home directory, and more globally with the host file <b class="file">/etc/hosts.equiv</b>. The <b class="file">.rhosts</b> file contains a list of system names (as defined in <b class="file">/etc/hosts</b>) that have access to that user's login. Therefore, make sure that the user's home directory has a <b class="file">.rhosts</b> file listing the VxWorks systems, each on a separate line, that are allowed to access files remotely using the user's name.</p><dd><p class="Body"><a name="90075"> </a>The <b class="file">/etc/hosts.equiv</b> file provides a less selective mechanism. Systems listed in this file are allowed login access to any user defined on the local system (except the super-user <b>root</b>). Thus, adding VxWorks system names to <b class="file">/etc/hosts.equiv</b> allows those VxWorks systems to access files using any user name on the UNIX system.</p><dd><p class="Body"><a name="90077"> </a>The FTP protocol, unlike RSH, specifies both the user name and password on every request. Therefore, when using FTP, the UNIX system does not use the <b class="file">.rhosts</b> or <b class="file">/etc/hosts.equiv</b> files to authorize remote access.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="90078">11.2.2 Creating VxWorks Network Devices that use RSH or FTP</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="90081"> </a>The routine <b class="routine"><i class="routine">netDevCreate</i></b><b>(</b> <b>)</b> is used to create a VxWorks I/O device for a particular remote host system:</p><dl class="margin"><dd><pre class="Code2"><b><a name="90082">netDevCreate ("<i class="textVariable">devName</i>", "<i class="textVariable">host</i>", <i class="textVariable">protocol</i>)</a></b></pre></dl><dd><p class="Body"><a name="90083"> </a>Its arguments are:</p></dl><dl class="margin"><dd><div class="Item"><a name="90084"> </a><i class="textVariable">devName</i> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="90085"> </a>The name of the device to be created. </div><br></dl></dl><dd><div class="Item"><a name="90086"> </a><i class="textVariable">host</i> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="90087"> </a>The Internet address of the host in dot notation, or the name of the remote system as specified in a previous call to <b class="routine"><i class="routine">hostAdd</i></b><b>(</b> <b>)</b>. It is traditional to use as the device name the host name followed by a colon. </div><br></dl></dl><dd><div class="Item"><a name="90088"> </a><i class="textVariable">protocol</i> </div><dl class="margin"><dl class="margin"><dd><div class="Indent2"><a name="90089"> </a>The file transfer protocol: 0 for RSH or 1 for FTP. </div><br></dl></dl></dl><dl class="margin"><dd><p class="Body"><a name="90090"> </a>For example, the following call creates a new I/O device on VxWorks called <b>mars:</b>, which accesses files on the host system <b>mars</b> using RSH:</p><dl class="margin"><dd><pre class="Code2"><b><a name="90091"></b><tt class="output">-> </tt><b>netDevCreate "mars:", "mars", 0</a></b></pre></dl><dd><p class="Body"><a name="90092"> </a>After a network device is created, files on that host can be accessed by appending the host path name to the device name. For example, the file name <b class="file">mars:/usr/darger/myfile</b> refers to the file <b class="file">/usr/darger/myfile</b> on the <b>mars</b> system. This file can be read and/or written exactly like a local file. For example, the following Tornado shell command opens that file for I/O access:</p><dl class="margin"><dd><pre class="Code2"><b><a name="90093"></b><tt class="output">-></tt><b> fd = open ("mars:/usr/darger/myfile", 2)</a></b></pre></dl><dd><p class="Body"><a name="90095"> </a>The VxWorks network startup routine, <b class="routine"><i class="routine">usrNetInit</i></b><b>(</b> <b>)</b> in <b class="file">usrNetwork.c</b>, automatically creates a network device for the host name specified in the VxWorks boot parameters. If no FTP password was specified in the boot parameters, the network device is specified with the RSH protocol. If a password was specified, FTP is used.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="90096">11.2.3 Setting the User ID for Remote File Access with RSH or FTP</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="90098"> </a>All FTP and RSH requests to a remote system include the user name. All FTP requests include a password as well as a user name. From VxWorks you can specify the user name and password for remote requests by calling <b class="routine"><i class="routine">iam</i></b><b>(</b> <b>)</b>:</p><dl class="margin"><dd><pre class="Code2"><b><a name="90100">iam ("<i class="textVariable">username</i>", "<i class="textVariable">password</i>")</a></b></pre></dl><dd><p class="Body"><a name="90101"> </a>The first argument to <b class="routine"><i class="routine">iam</i></b><b>(</b> <b>)</b> is the user name that identifies you when you access remote systems. The second argument is the FTP password. This is ignored if RSH is being used, and can be specified as NULL or 0 (zero).</p><dd><p class="Body"><a name="90102"> </a>For example, the following command tells VxWorks that all accesses to remote systems with RSH or FTP are through user <i class="term">darger</i>, and if FTP is used, the password is <i class="term">unreal</i>:</p><dl class="margin"><dd><pre class="Code2"><b><a name="90103"></b><tt class="output">-> </tt><b>iam "darger", "unreal"</a></b></pre></dl><dd><p class="Body"><a name="90105"> </a>The VxWorks network startup routine, <b class="routine"><i class="routine">usrNetInit</i></b><b>(</b> <b>)</b> in <b class="file">usrNetwork.c</b>, initially sets the user name and password to those specified in the boot parameters.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="90106">11.2.4 File Permissions</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="90108"> </a>For a VxWorks system to have access to a particular file on a host, permissions on the host system must be set up so that the user name that VxWorks is using has permission to read that file (and write it, if necessary). This means that it must have permission to access all directories in the path, as well as the file itself. </p><dd><p class="Body"><a name="90109"> </a>The easiest way to check this is to log in to the host with the user name VxWorks uses, and try to read or write the file in question. If you cannot do this, neither can the VxWorks system.</p></dl></dl><a name="foot"><hr></a><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-fileaxs.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-fileaxs.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-fileaxs1.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-fileaxs3.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc. conversion tool: Quadralay WebWorks Publisher 4.0.11 template: CSS Template, Jan 1998 - Jefro --->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -