rawio
[Top] [All Lists]

Re: dd

To: bapper@xxxxxxxxxxxxxxx (Brian Pomerantz)
Subject: Re: dd
From: slurn@xxxxxxxxxxxxxxxxxxxx (Scott Lurndal)
Date: Thu, 30 Mar 2000 11:21:49 -0800 (PST)
Cc: rawio@xxxxxxxxxxx
In-reply-to: <20000330103430.A19958@skull.piratehaven.org> from "Brian Pomerantz" at Mar 30, 2000 10:34:30 AM
Sender: owner-rawio@xxxxxxxxxxx
> 
> Would it be possible to get the source code to the dd.raw file that is
> on the web page for the rawio patch?  I just wanted it for a reference
> on how to use the rawio facility.  Plus, I can't run it since I'm
> working with Linux on the Alpha platform.
> 
> 
> BAPper
> 

I sent the diffs off to the fileutil's maintainer quite
some time ago.  

*** /tmp/dd.c.orig      Wed Jul  7 16:19:02 1999
--- dd.c        Wed Jul  7 16:33:14 1999
***************
*** 532,547 ****
  copy (void)
  {
    unsigned char *ibuf, *bufstart; /* Input buffer. */
    int nread;                  /* Bytes read in the current block. */
    int exit_status = 0;

    /* Leave at least one extra byte at the beginning and end of `ibuf'
       for conv=swab, but keep the buffer address even.  But some peculiar
       device drivers work only with word-aligned buffers, so leave an
       extra two bytes.  */

!   ibuf = (unsigned char *) xmalloc (input_blocksize + 2 * SWAB_ALIGN_OFFSET);
!   ibuf += SWAB_ALIGN_OFFSET;

    if (conversions_mask & C_TWOBUFS)
      obuf = (unsigned char *) xmalloc (output_blocksize);
--- 532,572 ----
  copy (void)
  {
    unsigned char *ibuf, *bufstart; /* Input buffer. */
+   unsigned char *realbuf;       /* real buffer address before alignment */
    int nread;                  /* Bytes read in the current block. */
    int exit_status = 0;
+   int bump;                   /* Skip this amount to page align buffer */
+   unsigned long pagesize;

    /* Leave at least one extra byte at the beginning and end of `ibuf'
       for conv=swab, but keep the buffer address even.  But some peculiar
       device drivers work only with word-aligned buffers, so leave an
       extra two bytes.  */

!   /*
!    * Some devices require alignment on a sector or page boundary
!    * (e.g. character disk devices).  Align the input buffer to a
!    * page boundary to cover all bases.  Note that due to the swab
!    * algorithm, we must have at least one byte in the page before
!    * the input buffer; thus we allocate 2 pages of slop in the
!    * real buffer.   8k above the blocksize shouldn't bother anyone.
!    */
!
! #if defined(HAVE_GETPAGESIZE)
!   pagesize = getpagesize();
! #else
!   pagesize = 4096;
! #endif
!
!   realbuf = (unsigned char *) xmalloc(input_blocksize +
!                                     (2 * SWAB_ALIGN_OFFSET) +
!                                     (2 * pagesize) - 1);
!   ibuf = realbuf;
!   ibuf += SWAB_ALIGN_OFFSET;  /* allow space for swab */
!   bump = ((unsigned long) ibuf) & (pagesize - 1);
!   if (bump) {
!       ibuf += (pagesize - bump);
!   }

    if (conversions_mask & C_TWOBUFS)
      obuf = (unsigned char *) xmalloc (output_blocksize);
***************
*** 684,690 ****
        }
      }

!   free (ibuf - SWAB_ALIGN_OFFSET);
    if (obuf != ibuf)
      free (obuf);

--- 709,715 ----
        }
      }

!   free (realbuf);
    if (obuf != ibuf)
      free (obuf);

<Prev in Thread] Current Thread [Next in Thread>
  • dd, Brian Pomerantz
    • Re: dd, Scott Lurndal <=