⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0222-0224.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:


<HTML>

<HEAD>

<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:Filesystems, Disks, and Other Devices</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!-- ISBN=0672311739 //-->

<!-- TITLE=RED HAT LINUX 2ND EDITION //-->

<!-- AUTHOR=DAVID PITTS ET AL //-->

<!-- PUBLISHER=MACMILLAN //-->

<!-- IMPRINT=SAMS PUBLISHING //-->

<!-- PUBLICATION DATE=1998 //-->

<!-- CHAPTER=11 //-->

<!-- PAGES=0195-0228 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="0219-0221.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0225-0227.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-222"><P>Page 222</P></A>



<CENTER>

<TABLE BGCOLOR="#FFFF99">

<TR><TD><B>

TIP

</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

If you ever find that your terminal state has been messed up, then you can usually fix

this with the command stty sane and Ctrl+J. Note that the command is ended with

Ctrl+J, rather than Enter (which is the same as Ctrl+M). This is because the

icrnl option might have been turned off. This is fixed again with

stty sane. GNU bash will always cope with CRs that have not been converted to LF anyway, but some other programs won't.

<BR><BR>

If this still doesn't work, and the screen font appears to have been changed, try typing

echo, pressing Ctrl+V and Esc, typing c, and pressing Ctrl+J. You press Ctrl+V to make

the terminal driver pass the next key through without processing. You can get a similar effect

by typing reset and pressing Ctrl+J, but the program

reset is only available if the ncurses package is installed.

</BLOCKQUOTE></TD></TR>

</TABLE></CENTER>

</P>

<P>Programs can turn off the processing that the line driver does by default; the resulting

behavior (raw mode) allows programs to read unprocessed input from the terminal driver (for

example, CR is not mapped to LF), and control characters don't produce the signals described in

the table earlier in this section. The stty sane command will return things to

normal.

</P>









<H4><A NAME="ch11_ 25">





Serial Communications

</A></H4>









<P>Although the terminal interfaces used most commonly under Linux are the console driver

and the pseudo-terminals driven by programs like

xterm, script, and expect, the original terminal interface involved serial communications. In fact, this still lingers on; a

pseudo-tty associated with an xterm window still has an associated baud rate as shown in the example in the

section &quot;The Terminal Device Driver.&quot; Changing this baud rate has no actual effect, though. For

real serial ports, however, the baud rate and many other parameters have a direct relevance.

The device nodes relating to the serial ports are composed of two &quot;teams,&quot; with the names

/dev/cua* and /dev/ttyS*. These allow the same serial hardware to be used for both incoming

and outgoing serial connections, as explained later in the section &quot;Using Modems.&quot;

</P>









<H4><A NAME="ch11_ 26">

Configuring the Serial Ports



</A></H4>









<P>Serial port configuration is mostly done either with the

stty command or directly by programs using the interface outlined in the

termios manual page. The stty command offers almost

all the configuration possibilities provided by

termios; however, there are configuration issues

for serial hardware that are not addressed by stty. The

setserial command allows the configuration of the correct IRQ settings for each serial port and of extra-fast baud rates that the

standard termios specification doesn't provide. For more detailed information, refer to the

Linux Serial-HOWTO and the manual page for

setserial.

</P>









<H4><A NAME="ch11_ 27">





Using Modems

</A></H4>









<P>Modems (other than &quot;WinModems&quot;) are very flexible devices. They allow dial-up

terminal access and wide area networking, and they also often allow the sending and receiving of

faxes

</P>



<A NAME="PAGENUM-223"><P>Page 223</P></A>













<P>or voice-mail. The two &quot;teams&quot; of serial device nodes mentioned earlier are intended

specifically for good modem support, and they look like this:

</P>





<!-- CODE //-->

<PRE>

$ ls -l /dev/ttyS* /dev/cua* /dev/mo*

crw-rw----   1 root     uucp       5,  64 Jan  1  1980 /dev/cua0

crw-rw----   1 root     uucp       5,  65 Jan  1  1980 /dev/cua1

crw-rw----   1 root     uucp       5,  66 Jan  1  1980 /dev/cua2

crw-rw----   1 root     uucp       5,  67 Jan  1  1980 /dev/cua3

lrwxrwxrwx   1 root     uucp            4 Jun  7 14:16 /dev/modem -&gt; cua2

lrwxrwxrwx   1 root     root           10 Sep  6  1996 /dev/mouse -&gt; /dev/ttyS0

crw-r--r--   1 root     root       4,  64 Nov  1 08:56 /dev/ttyS0

crw-r--r--   1 root     root       4,  65 May 29  1995 /dev/ttyS1

crw-r--r--   1 root     root       4,  66 Jan  1  1980 /dev/ttyS2

crw-r--r--   1 root     root       4,  67 Jan  1  1980 /dev/ttyS3

</PRE>

<!-- END CODE //-->











<P>The /dev/cua* devices are intended for use for dialing out, and the

/dev/ttyS* devices are intended for dialing in. A process such as

getty can be waiting for an open system call to

complete (that is, waiting for the modem to signal that there is an incoming call) on the

/dev/ttyS0 device while you are opening the corresponding device

/dev/cua0, which refers to the same hardware. Because there can't be an incoming call on that line while you're using the

modem, getty continues to wait. Lock files keep everyone from trying to use the same device at

the same time.

</P>









<P>These days, internetworking is the most common use for modems by far. There are many

resources that will help you set up your machine for Internet access via a modem. See the

section &quot;Connecting to the Net with PPP&quot; in Chapter 13. Other resources include the Red Hat

PPP-Tips document, which can be found in the support section of Red Hat's Web site, the

EzPPP package, and the ISP-HOOKUP and PPP HOWTOS. There are also a large number of

useful mini-HOWTOs that each help with more specific things; these include the

Diald, Dip+SLiRP+CSLIP, Dynamic-IP-Hacks, IP-Masquerade, PPP-over-ISDN,

PPP-over-minicom, SLIP+proxyARP, and Tiny-News Linux mini-HOWTOs. If, on the other

hand, you send and receive e-mail by UUCP rather than Internet protocols, you should start by

reading the Linux UUCP HOWTO and the Linux Sendmail+UUCP

mini-HOWTO.

</P>









<H4><A NAME="ch11_ 28">





Generic SCSI Devices

</A></H4>









<P>Not all SCSI devices are hard disks, CD-ROM drives, or tape drives. Some are optical

scanners, CD-ROM recorders, or even electron microscopes. The kernel can't possibly abstract

the interfaces for all possible SCSI devices, so it gives user programs direct access to SCSI

hardware via the generic SCSI devices. These enable programs to send arbitrary SCSI commands to

hardware. Although this offers the opportunity of wreaking havoc by mistake, it also offers the

capability of driving all sorts of interesting hardware, of which the principal examples are

CD-ROM recorders. The SCSI device nodes all have names starting with

/dev/sg. SCSI commands are sent to the devices by writing data to the device, and the results are read back

by reading from the device.

</P>



<A NAME="PAGENUM-224"><P>Page 224</P></A>













<H3><A NAME="ch11_ 29">

CD-ROM Recorders

</A></H3>









<P>CD-ROM recorders are devices for recording data on special media that can be read in

ordinary CD-ROM drives. There are two stages in the writing of a CD: the generation of the

CD image and the writing of that image to the media.

</P>









<P>The surface of a CD-R (recordable CD) is only writable once, so if

mkisofs worked like the other mkfs tools it would always generate image files representing empty CDs. For this

reason, mkisofs populates the filesystem with files as it generates the image file.

</P>









<P>The CD image file is produced by the mkisofs program, which generates the structures for

an ISO9660 filesystem and populates it with the files from a directory tree. CDs are not

writable in the same sense as block devices; this is why they are not

actually block devices. The image file must be written to the CD-R with a specialized program,

cdwrite, which understands all the various proprietary schemes used for driving CD writers. All the CD writers supported

by Linux (as of version 2.0.30 of the kernel) are SCSI devices, so the kernel accommodates this

by providing access to the generic SCSI device interface that enables a program to send SCSI

commands to these devices.

</P>









<P>While burning (writing) a CD, it is usually important that the flow of data to the writer

keeps up with the speed at which the writer is going; otherwise, if the writer runs out of data to

write, the CD-R is ruined. For this reason, it is usual to use

mkisofs to generate an image file and then separately use

cdwrite to write this image file to the CD writer.

</P>









<P>It is possible to use a pipe to send the data from

mkisofs directly to cdwrite. This often works either because a fast machine can ensure that

mkisofs supplies the data fast enough to keep the CD writer busy or because the CD writer is not sensitive to data underruns. (Some of the

more expensive ones have internal hard disks to which the data is written as an intermediate

stage.) This technique is not recommended, however, because the generation of the intermediate

image file has other benefits; it enables you to test your CD image before the final writing of the

data takes place.

</P>









<H4><A NAME="ch11_ 30">





Testing CD Images

</A></H4>









<P>Just as you can use mkfs to create a filesystem inside an ordinary file, you can mount

filesystems contained in ordinary files by using the loopback device driver described previously. The

first example of mounting a loopback filesystem is a demonstration of how you can test a CD

image.

</P>









<H4><A NAME="ch11_ 31">





Other Character Devices

</A></H4>









<P>There are several other varieties of character devices, some which are used frequently. For

example, /dev/null is used very frequently.

</P>



<P><CENTER>

<a href="0219-0221.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0225-0227.html">Next</A>

</CENTER></P>









</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -