Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl Subject: Re: PERL PL28 and reading raw devices (problem) Message-ID: <1990Sep26.182153.4901@iwarp.intel.com> Date: 26 Sep 90 18:21:53 GMT References: <1990Sep26.122859.18935@uvaarpa.Virginia.EDU> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 38 In-Reply-To: telxon!ping!gorpong@uunet.uu.net In article <1990Sep26.122859.18935@uvaarpa.Virginia.EDU>, telxon!ping!gorpong@uunet writes: | I am reading the tape with the perl read(SRC_TAPE, $_, $blksize); and | SRC_TAPE is opened either "< device" or "dd if=device |" | The exact same code works when the open is opening up a 'dd' command to | read the device. Is there something which perl is doing to the bytes | read in from the raw device which it does not do when reading from a pipe? Raw devices are sensitive to the *real* number of bytes being passed to the read(2) system call. Between Perl's read() and the read(2) system call sits the standard I/O package, which is free to break up requests into little teenytiny blocks or big huge blocks at will. So the number in the read() has very little to do with the number passed to read(2). For now, you can do something like: open(DD,"dd if=/dev/rst1 bs=20b |"); while(read(DD,$_,8192)) { # 8192 is arbitrary } and in the future (Perl 4.0), something like: open(TAPE,"/dev/rst1"); while($err = sysread(TAPE,$_,20*512)) { } or you can use syscall() now if you can figure out what to pass it. Just remember that the number of bytes read by read() has nothing to do with the blocking on the tape, but to the bytes transfered from stdio's buffers to your program. print (("Just another ", "buffered ", "Perl hacker,")[0,2]) -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/