Logo Search packages:      
Sourcecode: cbmconvert version File versions  Download package

static bool restoreBAM ( struct Image image,
byte_t **  BAM 
) [static]

Restore a back-up copy of the disk image's Block Availability Map.

Parameters:
image the disk image
BAM the BAM backup
Returns:
true on success

Definition at line 954 of file image.c.

References Image::buf, Image::dirtrack, getBlock(), getGeometry(), Im1541, Im1571, Im1581, ImUnknown, mapInode(), and Image::type.

Referenced by WriteImage(), and writeInode().

{
  const struct DiskGeometry* geom;

  if (!BAM || !*BAM ||
      !image || !image->buf || !(geom = getGeometry (image->type)))
    return false;

  switch (image->type) {
  case ImUnknown:
    return false;
  case Im1541:
    {
      byte_t* bamblock;

      if (!(bamblock = getBlock (image, image->dirtrack, 0)))
      return false;

      memcpy (&bamblock[4], *BAM, geom->tracks << 2);
      free (*BAM);
      *BAM = 0;

      return true;
    }
  case Im1571:
    {
      byte_t* bamblock;

      if (!(bamblock = getBlock (image, image->dirtrack, 0)))
      return false;

      memcpy (&bamblock[4], *BAM, 35 << 2);
      memcpy (&bamblock[0xDD], BAM[35 << 2], 35);

      if (!(bamblock = getBlock (image, 35 + image->dirtrack, 0)))
      return false;

      memcpy (bamblock, BAM[35 * 5], 35 * 3);
      free (*BAM);
      *BAM = 0;

      return true;
    }
  case Im1581:
    {
      byte_t** bamblocks = 0;

      if (2 != mapInode (&bamblocks, image, image->dirtrack, 1, 0, 0)) {
      if (bamblocks) free (bamblocks);
      return false;
      }

      memcpy (bamblocks[0], *BAM, 256);
      memcpy (bamblocks[1], *BAM + 256, 256);

      free (bamblocks);
      free (BAM);
      *BAM = 0;

      return true;
    }
  }

  return false;
}


Generated by  Doxygen 1.6.0   Back to index