📄 scsicmds.cpp
字号:
memset(tBuf, 0, sizeof(tBuf)); if ((err = scsiLogSense(device, TEMPERATURE_LPAGE, 0, tBuf, sizeof(tBuf), 0))) { *currenttemp = 0; *triptemp = 0; pout("Log Sense for temperature failed [%s]\n", scsiErrString(err)); return err; } *currenttemp = tBuf[9]; *triptemp = tBuf[15]; return 0;}/* Read informational exception log page or Request Sense response. * Fetching asc/ascq code potentially flagging an exception or warning. * Returns 0 if ok, else error number. A current temperature of 255 * (Celsius) implies that the temperature not available. */int scsiCheckIE(int device, int hasIELogPage, int hasTempLogPage, UINT8 *asc, UINT8 *ascq, UINT8 *currenttemp, UINT8 *triptemp){ UINT8 tBuf[252]; struct scsi_sense_disect sense_info; int err; int temperatureSet = 0; unsigned short pagesize; UINT8 currTemp, trTemp; *asc = 0; *ascq = 0; *currenttemp = 0; *triptemp = 0; memset(tBuf,0,sizeof(tBuf)); // need to clear stack space of junk memset(&sense_info, 0, sizeof(sense_info)); if (hasIELogPage) { if ((err = scsiLogSense(device, IE_LPAGE, 0, tBuf, sizeof(tBuf), 0))) { pout("Log Sense failed, IE page [%s]\n", scsiErrString(err)); return err; } // pull out page size from response, don't forget to add 4 pagesize = (unsigned short) ((tBuf[2] << 8) | tBuf[3]) + 4; if ((pagesize < 4) || tBuf[4] || tBuf[5]) { pout("Log Sense failed, IE page, bad parameter code or length\n"); return SIMPLE_ERR_BAD_PARAM; } if (tBuf[7] > 1) { sense_info.asc = tBuf[8]; sense_info.ascq = tBuf[9]; if (! hasTempLogPage) { if (tBuf[7] > 2) *currenttemp = tBuf[10]; if (tBuf[7] > 3) /* IBM extension in SMART (IE) lpage */ *triptemp = tBuf[11]; } } } if (0 == sense_info.asc) { /* ties in with MRIE field of 6 in IEC mode page (0x1c) */ if ((err = scsiRequestSense(device, &sense_info))) { pout("Request Sense failed, [%s]\n", scsiErrString(err)); return err; } } *asc = sense_info.asc; *ascq = sense_info.ascq; if ((! temperatureSet) && hasTempLogPage) { if (0 == scsiGetTemp(device, &currTemp, &trTemp)) { *currenttemp = currTemp; *triptemp = trTemp; } } return 0;}// The first character (W, C, I) tells the severitystatic const char * TapeAlertsMessageTable[]= { " ", /* 0x01 */ "W: The tape drive is having problems reading data. No data has been lost,\n" " but there has been a reduction in the performance of the tape.", /* 0x02 */ "W: The tape drive is having problems writing data. No data has been lost,\n" " but there has been a reduction in the capacity of the tape.", /* 0x03 */ "W: The operation has stopped because an error has occurred while reading\n" " or writing data that the drive cannot correct.", /* 0x04 */ "C: Your data is at risk:\n" " 1. Copy any data you require from this tape. \n" " 2. Do not use this tape again.\n" " 3. Restart the operation with a different tape.", /* 0x05 */ "C: The tape is damaged or the drive is faulty. Call the tape drive\n" " supplier helpline.", /* 0x06 */ "C: The tape is from a faulty batch or the tape drive is faulty:\n" " 1. Use a good tape to test the drive.\n" " 2. If problem persists, call the tape drive supplier helpline.", /* 0x07 */ "W: The tape cartridge has reached the end of its calculated useful life:\n" " 1. Copy data you need to another tape.\n" " 2. Discard the old tape.", /* 0x08 */ "W: The tape cartridge is not data-grade. Any data you back up to the tape\n" " is at risk. Replace the cartridge with a data-grade tape.", /* 0x09 */ "C: You are trying to write to a write-protected cartridge. Remove the\n" " write-protection or use another tape.", /* 0x0a */ "I: You cannot eject the cartridge because the tape drive is in use. Wait\n" " until the operation is complete before ejecting the cartridge.", /* 0x0b */ "I: The tape in the drive is a cleaning cartridge.", /* 0x0c */ "I: You have tried to load a cartridge of a type which is not supported\n" " by this drive.", /* 0x0d */ "C: The operation has failed because the tape in the drive has experienced\n" " a mechanical failure:\n" " 1. Discard the old tape.\n" " 2. Restart the operation with a different tape.", /* 0x0e */ "C: The operation has failed because the tape in the drive has experienced\n" " a mechanical failure:\n" " 1. Do not attempt to extract the tape cartridge\n" " 2. Call the tape drive supplier helpline.", /* 0x0f */ "W: The memory in the tape cartridge has failed, which reduces\n" " performance. Do not use the cartridge for further write operations.", /* 0x10 */ "C: The operation has failed because the tape cartridge was manually\n" " de-mounted while the tape drive was actively writing or reading.", /* 0x11 */ "W: You have loaded a cartridge of a type that is read-only in this drive.\n" " The cartridge will appear as write-protected.", /* 0x12 */ "W: The tape directory on the tape cartridge has been corrupted. File\n" " search performance will be degraded. The tape directory can be rebuilt\n" " by reading all the data on the cartridge.", /* 0x13 */ "I: The tape cartridge is nearing the end of its calculated life. It is\n" " recommended that you:\n" " 1. Use another tape cartridge for your next backup.\n" " 2. Store this tape in a safe place in case you need to restore " " data from it.", /* 0x14 */ "C: The tape drive needs cleaning:\n" " 1. If the operation has stopped, eject the tape and clean the drive.\n" " 2. If the operation has not stopped, wait for it to finish and then\n" " clean the drive.\n" " Check the tape drive users manual for device specific cleaning instructions.", /* 0x15 */ "W: The tape drive is due for routine cleaning:\n" " 1. Wait for the current operation to finish.\n" " 2. The use a cleaning cartridge.\n" " Check the tape drive users manual for device specific cleaning instructions.", /* 0x16 */ "C: The last cleaning cartridge used in the tape drive has worn out:\n" " 1. Discard the worn out cleaning cartridge.\n" " 2. Wait for the current operation to finish.\n" " 3. Then use a new cleaning cartridge.", /* 0x17 */ "C: The last cleaning cartridge used in the tape drive was an invalid\n" " type:\n" " 1. Do not use this cleaning cartridge in this drive.\n" " 2. Wait for the current operation to finish.\n" " 3. Then use a new cleaning cartridge.", /* 0x18 */ "W: The tape drive has requested a retention operation", /* 0x19 */ "W: A redundant interface port on the tape drive has failed", /* 0x1a */ "W: A tape drive cooling fan has failed", /* 0x1b */ "W: A redundant power supply has failed inside the tape drive enclosure.\n" " Check the enclosure users manual for instructions on replacing the\n" " failed power supply.", /* 0x1c */ "W: The tape drive power consumption is outside the specified range.", /* 0x1d */ "W: Preventive maintenance of the tape drive is required. Check the tape\n" " drive users manual for device specific preventive maintenance\n" " tasks or call the tape drive supplier helpline.", /* 0x1e */ "C: The tape drive has a hardware fault:\n" " 1. Eject the tape or magazine.\n" " 2. Reset the drive.\n" " 3. Restart the operation.", /* 0x1f */ "C: The tape drive has a hardware fault:\n" " 1. Turn the tape drive off and then on again.\n" " 2. Restart the operation.\n" " 3. If the problem persists, call the tape drive supplier helpline.", /* 0x20 */ "W: The tape drive has a problem with the application client interface:\n" " 1. Check the cables and cable connections.\n" " 2. Restart the operation.", /* 0x21 */ "C: The operation has failed:\n" " 1. Eject the tape or magazine.\n" " 2. Insert the tape or magazine again.\n" " 3. Restart the operation.", /* 0x22 */ "W: The firmware download has failed because you have tried to use the\n" " incorrect firmware for this tape drive. Obtain the correct\n" " firmware and try again.", /* 0x23 */ "W: Environmental conditions inside the tape drive are outside the\n" " specified humidity range.", /* 0x24 */ "W: Environmental conditions inside the tape drive are outside the\n" " specified temperature range.", /* 0x25 */ "W: The voltage supply to the tape drive is outside the specified range.", /* 0x26 */ "C: A hardware failure of the tape drive is predicted. Call the tape\n" " drive supplier helpline.", /* 0x27 */ "W: The tape drive may have a hardware fault. Run extended diagnostics to\n" " verify and diagnose the problem. Check the tape drive users manual for\n" " device specific instructions on running extended diagnostic tests.", /* 0x28 */ "C: The changer mechanism is having difficulty communicating with the tape\n" " drive:\n" " 1. Turn the autoloader off then on.\n" " 2. Restart the operation.\n" " 3. If problem persists, call the tape drive supplier helpline.", /* 0x29 */ "C: A tape has been left in the autoloader by a previous hardware fault:\n" " 1. Insert an empty magazine to clear the fault.\n" " 2. If the fault does not clear, turn the autoloader off and then\n" " on again.\n" " 3. If the problem persists, call the tape drive supplier helpline.", /* 0x2a */ "W: There is a problem with the autoloader mechanism.", /* 0x2b */ "C: The operation has failed because the autoloader door is open:\n" " 1. Clear any obstructions from the autoloader door.\n" " 2. Eject the magazine and then insert it again.\n" " 3. If the fault does not clear, turn the autoloader off and then\n" " on again.\n" " 4. If the problem persists, call the tape drive supplier helpline.", /* 0x2c */ "C: The autoloader has a hardware fault:\n" " 1. Turn the autoloader off and then on again.\n" " 2. Restart the operation.\n" " 3. If the problem persists, call the tape drive supplier helpline.\n" " Check the autoloader users manual for device specific instructions\n" " on turning the device power on and off.", /* 0x2d */ "C: The autoloader cannot operate without the magazine,\n" " 1. Insert the magazine into the autoloader.\n" " 2. Restart the operation.", /* 0x2e */ "W: A hardware failure of the changer mechanism is predicted. Call the\n" " tape drive supplier helpline.", /* 0x2f */ "I: Reserved.", /* 0x30 */ "I: Reserved.", /* 0x31 */ "I: Reserved.", /* 0x32 */ "W: Media statistics have been lost at some time in the past", /* 0x33 */ "W: The tape directory on the tape cartridge just unloaded has been\n" " corrupted. File search performance will be degraded. The tape\n" " directory can be rebuilt by reading all the data.", /* 0x34 */ "C: The tape just unloaded could not write its system area successfully:\n" " 1. Copy data to another tape cartridge.\n" " 2. Discard the old cartridge.", /* 0x35 */ "C: The tape system are could not be read successfully at load time:\n" " 1. Copy data to another tape cartridge.\n", /* 0x36 */ "C: The start or data could not be found on the tape:\n" " 1. Check you are using the correct format tape.\n" " 2. Discard the tape or return the tape to your supplier", /* 0x37 */ "C: The operation has failed because the media cannot be loaded\n" " and threaded.\n" " 1. Remove the cartridge, inspect it as specified in the product\n" " manual, and retry the operation.\n" " 2. If the problem persists, call the tape drive supplier help line.", /* 0x38 */ "C: The operation has failed because the medium cannot be unloaded:\n" " 1. Do not attempt to extract the tape cartridge.\n" " 2. Call the tape driver supplier help line.", /* 0x39 */ "C: The tape drive has a problem with the automation interface:\n" " 1. Check the power to the automation system.\n" " 2. Check the cables and cable connections.\n" " 3. Call the supplier help line if problem persists.", /* 0x3a */ "W: The tape drive has reset itself due to a detected firmware\n" " fault. If problem persists, call the supplier help line.", };const char * scsiTapeAlertsTapeDevice(unsigned short code){ const int num = sizeof(TapeAlertsMessageTable) / sizeof(TapeAlertsMessageTable[0]); return (code < num) ? TapeAlertsMessageTable[code] : "Unknown Alert"; }// The first character (W, C, I) tells the severitystatic const char * ChangerTapeAlertsMessageTable[]= { " ", /* 0x01 */ "C: The library mechanism is having difficulty communicating with the\n" " drive:\n" " 1. Turn the library off then on.\n" " 2. Restart the operation.\n" " 3. If the problem persists, call the library supplier help line.", /* 0x02 */ "W: There is a problem with the library mechanism. If problem persists,\n" " call the library supplier help line.", /* 0x03 */ "C: The library has a hardware fault:\n" " 1. Reset the library.\n" " 2. Restart the operation.\n" " Check the library users manual for device specific instructions on resetting\n" " the device.", /* 0x04 */ "C: The library has a hardware fault:\n" " 1. Turn the library off then on again.\n" " 2. Restart the operation.\n" " 3. If the problem persists, call the library supplier help line.\n" " Check the library users manual for device specific instructions on turning the\n" " device power on and off.", /* 0x05 */ "W: The library mechanism may have a hardware fault.\n" " Run extended diagnostics to verify and diagnose the problem. Check the library\n" " users manual for device specific instructions on running extended diagnostic\n" " tests.", /* 0x06 */ "C: The library has a problem with the host interface:\n" " 1. Check the cables and connections.\n" " 2. Restart the operation.", /* 0x07 */ "W: A hardware failure of the library is predicted. Call the library\n"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -