|
|
1.1 ! root 1: /*++ ! 2: ! 3: Copyright (c) 1993 - Colorado Memory Systems, Inc. ! 4: All Rights Reserved ! 5: ! 6: Module Name: ! 7: ! 8: settpst.c ! 9: ! 10: Abstract: ! 11: ! 12: Calculates the number of bytes of data available on the tape (accounting ! 13: for bad sectors) ! 14: ! 15: Revision History: ! 16: ! 17: ! 18: ! 19: ! 20: --*/ ! 21: ! 22: ! 23: // ! 24: // include files ! 25: // ! 26: ! 27: #include <ntddk.h> ! 28: #include <ntddtape.h> ! 29: #include "common.h" ! 30: #include "q117.h" ! 31: #include "protos.h" ! 32: ! 33: ! 34: VOID ! 35: q117SetTpSt( ! 36: PQ117_CONTEXT Context ! 37: ) ! 38: ! 39: /*++ ! 40: ! 41: Routine Description: ! 42: ! 43: Uses the globals CurrentOperation.EndOfUsedTape, ! 44: and CurrentTape.BadSectors to set the ! 45: Media Parameters. ! 46: ! 47: Arguments: ! 48: ! 49: Context - ! 50: ! 51: Return Value: ! 52: ! 53: None ! 54: ! 55: --*/ ! 56: ! 57: { ! 58: ULONG numgood,numbad; ! 59: SEGMENT segmentIndex; ! 60: SEGMENT lastSegment; ! 61: ULONG BytesUsed; ! 62: ! 63: // ! 64: // If we have read to the end of the volume segment ! 65: // ! 66: ! 67: if (Context->CurrentOperation.EndOfUsedTape) { ! 68: ! 69: // ! 70: // Count the number of used sectors ! 71: // ! 72: ! 73: lastSegment = Context->CurrentOperation.EndOfUsedTape; ! 74: ! 75: numgood = 0; ! 76: ! 77: for (segmentIndex = 0 ; segmentIndex <= lastSegment ; ++segmentIndex) { ! 78: ! 79: numbad = q117CountBits(Context, segmentIndex, 0l); ! 80: ! 81: if (BLOCKS_PER_SEGMENT-ECC_BLOCKS_PER_SEGMENT-numbad > 0 && ! 82: segmentIndex > Context->CurrentTape.VolumeSegment) { ! 83: ! 84: numgood += BLOCKS_PER_SEGMENT-ECC_BLOCKS_PER_SEGMENT-numbad; ! 85: ! 86: } ! 87: } ! 88: ! 89: BytesUsed = numgood * BYTES_PER_SECTOR; ! 90: ! 91: numgood = 0; ! 92: ! 93: lastSegment = Context->CurrentTape.LastSegment; ! 94: ! 95: for (;segmentIndex<=lastSegment;++segmentIndex) { ! 96: ! 97: numbad = q117CountBits(Context, segmentIndex, 0l); ! 98: ! 99: if (BLOCKS_PER_SEGMENT-ECC_BLOCKS_PER_SEGMENT-numbad > 0) { ! 100: ! 101: numgood += BLOCKS_PER_SEGMENT-ECC_BLOCKS_PER_SEGMENT-numbad; ! 102: ! 103: } ! 104: } ! 105: ! 106: Context->CurrentTape.MediaInfo->Remaining.LowPart = ! 107: numgood * BYTES_PER_SECTOR; ! 108: ! 109: Context->CurrentTape.MediaInfo->Remaining.HighPart = 0; ! 110: ! 111: Context->CurrentTape.MediaInfo->Capacity.LowPart = ! 112: Context->CurrentTape.MediaInfo->Remaining.LowPart + BytesUsed; ! 113: ! 114: Context->CurrentTape.MediaInfo->Capacity.HighPart = 0; ! 115: Context->CurrentTape.MediaInfo->BlockSize = BYTES_PER_SECTOR; ! 116: Context->CurrentTape.MediaInfo->PartitionCount = 0; ! 117: ! 118: } else { ! 119: ! 120: CheckedDump(QIC117INFO,("q117SetTpSt: endblock not set\n")); ! 121: ! 122: } ! 123: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.