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

static size_t mapInode ( byte_t ***  buf,
struct Image image,
byte_t  track,
byte_t  sector,
log_t  log,
const struct DirEnt *  dirent 
) [static]

Get a block pointer table to all blocks in the file starting at the specified track and sector.

buf the block pointer table
image the disk image
track track number of the file's first block
sector sector number of the file's first block
log Call-back function for diagnostic output
dirent directory entry for diagnostic output (optional)
the number of blocks mapped (0 on failure)

Definition at line 452 of file image.c.

References Image::buf, getBlock(), getGeometry(), isFreeBlock(), Filename::name, Filename::recordLength, Filename::type, Image::type, and Warnings.

Referenced by allocBlock(), backupBAM(), blocksFree(), checkSideSectors(), freeBlock(), getDirEnt(), ReadImage(), restoreBAM(), and setupSideSectors().

  const struct DiskGeometry* geom;
  int t, s;
  size_t size;
  byte_t* block;

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

  /* Determine the number of blocks. */
  for (t = track, s = sector, size = 0; t; size++) {
    if (size > geom->blocks)
      return 0; /* endless file */

    if (!(block = getBlock (image, t, s)))
      return 0;

    if (isFreeBlock (image, t, s)) {
      if (!log)
      return 0;
      else {
      struct Filename name;
      if (dirent) {
        memcpy (name.name, dirent->name, sizeof name.name);
        name.type = dirent->type;
        name.recordLength = dirent->recordLength;
      (*log) (Warnings, dirent ? &name : 0,
            "Unallocated block %u,%u reachable from %u,%u",
            t, s, track, sector);

    t = block[0];
    s = block[1];

  /* Set up the block pointer table. */

  if (!(*buf = malloc (size * sizeof **buf)))
    return 0;

  for (t = track, s = sector, size = 0; t; size++) {
    if (!((*buf)[size] = getBlock (image, t, s))) {
      free (*buf);
      *buf = 0;
      return 0;

    t = (*buf)[size][0];
    s = (*buf)[size][1];

  return size;

Generated by  Doxygen 1.6.0   Back to index