SUMMARY: dd + fixed size writes

From: Claude Scarpelli (claude@genethon.genethon.fr)
Date: Fri Jul 31 1992 - 15:00:42 CDT


Yestderday, I have posted a message in this mailing list about problem
using dd. 24 hours later I have received 9 replies. Of course,
most of them contained good answers : Sun Managers are wonderfull !

Let me remind you the problem :
I want to use dd to write QIC150 tapes. The device requires writes
on 512 bytes boundary. Moreover, I want the input of dd to be a
pipe.

I have tried the following option of dd, without success :
* obs=1k ( writes are not on 1k boundary [nor on 512])
* conv=sync ( writes are on 512 bytes boundary, but this
                ( doesn't work if input is a pipe)

I have join my previous message at the end of this mail. Look at it
for details.

The first correct answer came from sid cowles <scowles@ckm.ucsf.edu>
(in french) : Using obs=1k AND conv=sync AND no other thing do
what I want : writes are on 512 bytes boundary AND input from
pipe is handled correctly.

This raise another question, of less importance : Whatever I put
in obs, the ouput is always padded to 512 bytes. I think this is due to
the fact that conv=sync makes writes to be the same length than reads.
Interesting thing is that if I specify ibs, then dd fails
if input is a pipe. Maybe the combination of obs and conv=sync is
*magic*...

Most answers suggest this way of doing things. Jay Plett
<jay@Princeton.EDU> and Dieter Muller <dworkin@merlin.rootgroup.com>
suggest to pipe two dd, as :
| dd conv=block | dd conv=sync

Other people have wrote their own version of a simplified dd.
Matt Goheen <matt@wbst845e.xerox.com> tells about a tool from
Delta Microsystem, called bdd (He think). May be the gnu version
of dd does the job too.

Thank's to everybody who answers:
From: scowles@ckm.ucsf.edu (sid cowles)
From: Tom.Murray@cs.clemson.edu (Tom Murray)
From: Dieter Muller <dworkin@merlin.rootgroup.com>
From: "Jay Plett" <jay@Princeton.EDU>
From: ron%arfalas.horizon.com@Sdsc.BITNET (Ron McDaniels)
From: Mike Raffety <miker@sbcoc.com>
From: matt@wbst845e.xerox.com (Matt Goheen)
From: kalli!kevin@fourx.Aus.Sun.COM (Kevin Sheehan {Consulting Poster Child})
From: Andreas Koppenhoefer <koppenh@dia.informatik.uni-stuttgart.de>

My original query :

Hello,

I try to write files on QIC150 tapes using dd. My SunOS release is
4.1.2, on a 4/470.

The main problem is that the st driver requires modulo 512 bytes writes, ie
you have to call write(2) with a 512 bytes buffer.

I have been unable to instruct dd to do such write syscalls !
Uses of ibs, obs, bs (or combination of them) was unsuccessfull.

I then tried conv=sync. In this case (as trace(1) shows) incompletes
read are padded to the buffer size. Incidentally, the following write
is well padded. But this is useless if dd's input is a pipe. I have included
some output at the end of this mail.

I know that tar(1) should helps me. But for some obscure reasons,
I want to use dd after a pipe, with output to tape.

Here are some outputs:

genethon$ echo abc | trace dd obs=1k of=/dev/null
[stuff deleted]
read (3, "abc\n", 512) = 4 <- read data
read (3, "", 512) = 0 <- detects EOF
write (4, "abc\n", 4) = 4 <- write 4 bytes instead of 1K

genethon$ echo abc | trace dd of=/dev/null conv=sync
[stuff deleted]
read (3, "abc\n", 512) = 4 <- read data
write (4, "".., 512) = 512 <- write padded read data
read (3, "", 512) = 0 <- detects EOF

Everyone can easily show that if you do write(2) after each read(2), you
may introduce null bytes inside your data. Look :

genethon$ (echo abc ; sleep 2 ; echo def) | trace dd of=/tmp/output conv=sync
[stuff deleted]
read (3, "abc\n", 512) = 4 <- read (incomplete) but.....
write (4, "".., 512) = 512 <- write 512 bytes
read (3, "def\n", 512) = 4 <- read
write (4, "".., 512) = 512 <- write
read (3, "", 512) = 0 <- detects EOF

The result is a file of size 1024 bytes, instead of 512 (or 6).
Its content is 'abc' followed by 509 NULL, then 'def' followed by 509 NULL.

***********************
The Question is :
What command should I use to produce 'abcdef' followed by 506 NULL ?
***********************

As usual, I'll summarize if any interest,
------------------------------------------------------------------------------
Claude Scarpelli Internet : claude@genethon.fr
Human Polymorphism Study Center or : claude@cephb.fr



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:46 CDT