File:  [WindowsNT SDKs] / ntddk / src / scsi / qic117 / gttpinfo.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 18:31:12 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: ntddk-nov-1993, HEAD
Microsoft Windows NT Build 511 (DDK SDK) 11-01-1993

/*++

Copyright (c) 1993 - Colorado Memory Systems, Inc.
All Rights Reserved

Module Name:

    gttpinfo.c

Abstract:

    Gets volume information (end of data,  number of volumes, etc).

Revision History:



--*/

//
// include files
//

#include <ntddk.h>
#include <ntddtape.h>
#include "common.h"
#include "q117.h"
#include "protos.h"


STATUS
q117ReadVolumeEntry(
    PVOLUME_TABLE_ENTRY VolumeEntry,
    PQ117_CONTEXT Context
    )

/*++

Routine Description:

    Transfers the VolDir structure to the given location and defines
    CurrentOperation.EndOfUsedTape if called for the VolDir structure that has 0 for its
    startblock.

    This routine will also define 'CurrentOperation.EndOfUsedTape' provided it is called for
    all the entries that are on the Tape Directory.  (This is determined
    when the 'startblock' field of the VolDir is 0.

Arguments:

    TheVolumeTable -

    Context -

Return Value:

    NoErr,  any Driver error except BadBlk, RdncUnsc,
    <LinkRC>, EndOfVol (if caller exceeds block of 256th VolDir entry).

--*/

{
    STATUS ret;
    ULONG size;

    //
    // Read in a volume entry
    //
    size = sizeof(*VolumeEntry);

    ret = q117ReadTape(VolumeEntry, &size, Context);

    if (Context->CurrentOperation.EndOfUsedTape != 0) {

        //
        // This is an extraneous read by a command line.
        //

        return(ret);

    }

    if (ret==RdncUnsc) {

        //
        // Assume that there was a valid entry here.  This assumption affects StartBack().
        //

        Context->ActiveVolumeNumber++;

        //
        // Will not define the 'CurrentTape.LastUsedSegment' unless we look at a good block.
        //

        Context->CurrentTape.LastUsedSegment=0;

    } else {

        if (ret==NoErr) {

            if (VolumeEntry->Signature != VolumeTableSig) {

                Context->CurrentOperation.EndOfUsedTape = Context->CurrentTape.LastUsedSegment;
                ret = EndOfVol;

            } else {

                Context->CurrentTape.LastUsedSegment = VolumeEntry->EndingSegment;
                Context->ActiveVolumeNumber++;

                //
                // A certain vendor who shall remain anonymous, but whose
                // initials are S.C.O, puts into its volume headers a starting
                // and ending segment, but not a data size. If we detect this
                // condition, we will attempt to fake it by adding up the
                // valid sectors & and stuffing the result into DataSize.
                //

                if (!VolumeEntry->DataSize) {

                    q117FakeDataSize(VolumeEntry, Context);

                }

            }

        } else {

            if (ret == EndOfVol) {

                Context->CurrentOperation.EndOfUsedTape = Context->CurrentTape.LastUsedSegment;

            }
        }
    }

    //
    // if we have read the last volume entry then set the tape statistics
    //

    if (Context->CurrentOperation.EndOfUsedTape) {

        q117SetTpSt(Context);

    }
    return(ret);
}


VOID
q117FakeDataSize(
    IN OUT PVOLUME_TABLE_ENTRY TheVolumeTable,
    IN PQ117_CONTEXT Context
    )

/*++

Routine Description:

    This routine will fake the volume's data size by calculating the total
    amount of data contained in the segments between (inclusive) the starting
    and ending segments as given in the volume table entry.
    It assumes that the bad sector map is accurate.
    Called from q117ReadVolumeEntry() only.

Arguments:

    TheVolumeTable -

    Context -

Return Value:

    None

--*/

{
    SEGMENT segment;                      // Segment we are looking at
    ULONG datasize = (LONG)0;     // accumulator

    for(segment = TheVolumeTable->StartSegment;
        segment <= TheVolumeTable->EndingSegment ; ++segment) {

        //
        // count good data in each segment.
        //

        datasize += (ULONG)q117GoodDataBytes(segment,Context);

    }

    //
    // give back the results
    //

    TheVolumeTable->DataSize = datasize;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.