On Tue, 7 Nov 2006, Geoff Steckel wrote:

> > > > Index: position.c
> > > > ===================================================================
> > > > RCS file: /cvs/src/bin/dd/position.c,v
> > > > retrieving revision 1.7
> > > > diff -u -p -r1.7 position.c
> > > > --- position.c  11 Jun 2003 23:42:12 -0000      1.7
> > > > +++ position.c  6 Nov 2006 12:07:54 -0000
> > > > @@ -71,7 +71,7 @@ pos_in(void)
> > > >         int warned;
> > > >  
> > > >         /* If not a pipe or tape device, try to seek on it. */
> > > > -       if (!(in.flags & (ISPIPE|ISTAPE))) {
> > > > +       if (!(in.flags & (ISPIPE|ISTAPE|ISCHR))) {
> > > >                 if (lseek(in.fd, in.offset * in.dbsz, SEEK_CUR) == -1)
> > > >                         err(1, "%s", in.name);
> > > >                 return;
> 
> 
> I may be reading this totally wrong, but won't this
> change prevent using seek on a character disk device?
> That would be a -major- loss of functionality as
> dd has traditionally been used to read areas past
> bad spots on disks.  If I'm wrong, apologies to everyone.
>    geoff steckel

Hmmm, I think you are right. Maybe better test for isatty()?

        -Otto

Index: position.c
===================================================================
RCS file: /cvs/src/bin/dd/position.c,v
retrieving revision 1.8
diff -u -p -r1.8 position.c
--- position.c  7 Nov 2006 07:10:24 -0000       1.8
+++ position.c  7 Nov 2006 10:23:17 -0000
@@ -70,8 +70,8 @@ pos_in(void)
        off_t cnt;
        int warned;
 
-       /* If not a pipe, tape or char device, try to seek on it. */
-       if (!(in.flags & (ISPIPE|ISTAPE|ISCHR))) {
+       /* If not a pipe, tape or tty device, try to seek on it. */
+       if (!(in.flags & (ISPIPE|ISTAPE)) && !isatty(in.fd)) {
                if (lseek(in.fd, in.offset * in.dbsz, SEEK_CUR) == -1)
                        err(1, "%s", in.name);
                return;

Reply via email to