File:  [WindowsNT SDKs] / ntddk / src / scsi / qic117 / appvoltd.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:

    appvoltd.c

Abstract:

    appends a volume entry to the qic-40 volume table

Revision History:




--*/

//
// include files
//

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


STATUS
q117AppVolTD(
    IN OUT PVOLUME_TABLE_ENTRY TheVolumeTable,
    IN OUT PQ117_CONTEXT Context
    )

/*++

Routine Description:

    Appends the VolDir to the tape directory.

Arguments:

    TheVolumeTable - pointer to the volume directory to be added

    Context -

Return Value:

    NoErr, any driver error

--*/

{
    LONG ret,i;
    LONG tmpseqnum;
    PIO_REQUEST ioreq;
    VOLUME_TABLE_ENTRY scrvol;
    PSEGMENT_BUFFER bufferInfo;

    ret =0;

    //
    // Now compute the VolDir's checksum.
    //

    TheVolumeTable->Signature=VolumeTableSig;

    //
    // If we are updating a specific volume entry
    //

    if (Context->ActiveVolumeNumber) {

        //
        // must use temporary var because ReadVolumeEntry() updates
        // ActiveVolumeNumber
        //

        tmpseqnum = Context->ActiveVolumeNumber;
        ret = q117SelectTD(Context);

        if (ret) {

            return(ret);

        }

        for (i=0;i<tmpseqnum;++i) {

            ret = q117ReadVolumeEntry(&scrvol,Context);
            if (ret)  {

                return(ret);

            }

        }

        //
        // add in this volume table
        //

        RtlMoveMemory(Context->CurrentOperation.SegmentPointer,TheVolumeTable,sizeof(*TheVolumeTable));
        Context->CurrentOperation.SegmentPointer=q117GetLastBuffer(Context);

    } else {

        if (!ret ) {

            Context->CurrentOperation.SegmentPointer=q117GetFreeBuffer(&bufferInfo,Context);
            RtlZeroMemory(
               Context->CurrentOperation.SegmentPointer,
               q117GoodDataBytes(Context->CurrentTape.VolumeSegment,Context));

            //
            // add in this volume table
            //

            RtlMoveMemory(Context->CurrentOperation.SegmentPointer,TheVolumeTable,sizeof(*TheVolumeTable));

        }
    }

    if (!ret) {

        //
        // write out volume directory block
        //

        if (!(ret = q117IssIOReq(
                        Context->CurrentOperation.SegmentPointer,
                        DWrite,
                        (LONG)Context->CurrentTape.VolumeSegment * BLOCKS_PER_SEGMENT,
                        bufferInfo,
                        Context))) {

            ioreq=q117Dequeue(WaitForItem, Context);
            ret = ioreq->Status;

        }
    }

    if (!ret) {

        ++Context->ActiveVolumeNumber;

    }

    return(ret);
}

unix.superglobalmegacorp.com

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