int ftape_activate_drive(vendor_struct * drive_type) { int result = 0; TRACE_FUN(ft_t_flow); /* If we already know the drive type, wake it up. * Else try to find out what kind of drive is attached. */ if (drive_type->wake_up != unknown_wake_up) { TRACE(ft_t_flow, "enabling tape drive and fdc"); result = ftape_wakeup_drive(drive_type->wake_up); if (result < 0) { TRACE(ft_t_err, "known wakeup method failed"); } } else { wake_up_types method; const ft_trace_t old_tracing = TRACE_LEVEL; if (TRACE_LEVEL < ft_t_flow) { SET_TRACE_LEVEL(ft_t_bug); } /* Try to awaken the drive using all known methods. * Lower tracing for a while. */ for (method=no_wake_up; method < NR_ITEMS(methods); ++method) { drive_type->wake_up = method; #ifdef CONFIG_FT_TWO_DRIVES /* Test setup for dual drive configuration. * /dev/rft2 uses mountain wakeup * /dev/rft3 uses colorado wakeup * Other systems will use the normal scheme. */ if ((ft_drive_sel < 2) || (ft_drive_sel == 2 && method == FT_WAKE_UP_1) || (ft_drive_sel == 3 && method == FT_WAKE_UP_2)) { result=ftape_wakeup_drive(drive_type->wake_up); } else { result = -EIO; } #else result = ftape_wakeup_drive(drive_type->wake_up); #endif if (result >= 0) { TRACE(ft_t_warn, "drive wakeup method: %s", methods[drive_type->wake_up].name); break; } } SET_TRACE_LEVEL(old_tracing); if (method >= NR_ITEMS(methods)) { /* no response at all, cannot open this drive */ drive_type->wake_up = unknown_wake_up; TRACE(ft_t_err, "no tape drive found !"); result = -ENODEV; } } TRACE_EXIT result; }
void CDNSChildWorker::TimeOutWork() { //检测和DCS的链接状态 if(m_DcsNodeFd.moNetStat == TCP_CLOSED) { TRACE(1, "CDNSChildWorker::TimeOutWork 和DCS链接断开了。"); } uint64 time_now = CTimeBase::get_current_time(); //发送存活 if(time_now > m_i64LastKeepLive + KEEP_LIVE_TIME_OUT * 1000) { KeepLive(); m_i64LastKeepLive = time_now; } //dump if(time_now > m_i64LastDumpTime + m_pDnsConfig->dump_info_time * 1000) { Dump(); m_i64LastDumpTime = time_now; } //log if(time_now > m_i64LastLogTime + m_pDnsConfig->log_file_update_time*1000) { unsigned int process_id = CCommon::GetProcessId(); char lszLogFileName[255]; memset(lszLogFileName, 0, 255); CFileStream::GetAppPath(lszLogFileName,255); //设置日志文件信息 SET_TRACE_LEVEL(5); unsigned liOptions = (CDebugTrace::Timestamp | CDebugTrace::LogLevel & ~CDebugTrace::FileAndLine | CDebugTrace::AppendToFile); SET_TRACE_OPTIONS(GET_TRACE_OPTIONS() | liOptions); strcpy(strrchr(lszLogFileName,'/'),"//DNS_log"); CFileStream::CreatePath(lszLogFileName); char lszFileDate[50]; memset(lszFileDate, 0, 50); time_t loSystemTime; time(&loSystemTime); struct tm* lptm = localtime(&loSystemTime); sprintf(lszFileDate, "//DNS-%u-%4d%02d%02d%02d%02d.log", process_id, 1900+lptm->tm_year,1+lptm->tm_mon,lptm->tm_mday, lptm->tm_hour, lptm->tm_min); strcat(lszLogFileName,lszFileDate); SET_LOG_FILENAME(lszLogFileName); m_i64LastLogTime = time_now; } if(time_now > m_i64LastCheckTimeOut + CRS_DNS_TIMEOUT * 1000) { CheckTimeOut(); //test(); m_i64LastCheckTimeOut = time_now; } }
NTSTATUS FileIoctl(__in BASE_FILE * File, __in PIRP Irp, __in PIO_STACK_LOCATION IrpStack) { PVOID Buffer = Irp->AssociatedIrp.SystemBuffer; ULONG IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode; ULONG InputBufferLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength; ULONG OutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength; INT32 Level = GET_TRACE_LEVEL(); NTSTATUS Status = STATUS_SUCCESS; PAGED_CODE(); switch (IoControlCode) { case IOCTL_SAMPDRV_GET_TRACE_LEVEL: if (OutputBufferLength != sizeof(INT32)) { TRACE_MSG(TRACE_LEVEL_ERROR, TRACE_FLAG_DEFAULT, "Invalid output buffer length=%u\n", OutputBufferLength); Status = STATUS_INVALID_BUFFER_SIZE; break; } TRACE_MSG(TRACE_LEVEL_INFO, TRACE_FLAG_DEFAULT, "Return trace level %d\n", Level); *(INT32 *) Buffer = Level; Irp->IoStatus.Information = sizeof(INT32); break; case IOCTL_SAMPDRV_SET_TRACE_LEVEL: if (InputBufferLength != sizeof(INT32)) { TRACE_MSG(TRACE_LEVEL_ERROR, TRACE_FLAG_DEFAULT, "Invalid input buffer length=%u\n", InputBufferLength); Status = STATUS_INVALID_BUFFER_SIZE; break; } SET_TRACE_LEVEL(*(INT32 *) Buffer); TRACE_MSG(TRACE_LEVEL_INFO, TRACE_FLAG_DEFAULT, "Trace level changed from %d to %d\n", Level, GET_TRACE_LEVEL()); break; case IOCTL_SAMPDRV_DUMP_DATA: DumpBufferList(File); break; default: TRACE_MSG(TRACE_LEVEL_ERROR, TRACE_FLAG_DEFAULT, "Unsupported I/O control 0x%X\n", IoControlCode); Status = STATUS_INVALID_DEVICE_REQUEST; break; } return BaseFileCompleteRequest(File, Irp, Status); }
void test_proc(void) { UINT32 x, y, flags; for (x = TRACE_LEVEL_ERROR; x <= TRACE_LEVEL_VERBOSE; x++) { xpcf_print("*** Set trace level to %u ***\n", x); SET_TRACE_LEVEL(x); for (y = TRACE_LEVEL_ERROR; y <= TRACE_LEVEL_VERBOSE; y++) { TRACE_MSG(y, TRACE_FLAG_DEFAULT, "Trace level = %u\n", y); } } for (x = 0; x < 32; x++) { flags = TRACE_FLAG(x); xpcf_print("*** Set trace level to %08X ***\n", flags); SET_TRACE_FLAGS(flags); for (y = 0; y < 32; y++) { flags = TRACE_FLAG(y); TRACE_MSG(TRACE_LEVEL_INFO, flags, "Trace flags = 0x%08X\n", flags); } } }
int ftape_get_drive_status(void) { int result; int status; TRACE_FUN(ft_t_flow); ft_no_tape = ft_write_protected = 0; /* Tape drive is activated now. * First clear error status if present. */ do { result = ftape_ready_wait(ftape_timeout.reset, &status); if (result < 0) { if (result == -ETIME) { TRACE(ft_t_err, "ftape_ready_wait timeout"); } else if (result == -EINTR) { TRACE(ft_t_err, "ftape_ready_wait aborted"); } else { TRACE(ft_t_err, "ftape_ready_wait failed"); } TRACE_EXIT -EIO; } /* Clear error condition (drive is ready !) */ if (status & QIC_STATUS_ERROR) { unsigned int error; qic117_cmd_t command; TRACE(ft_t_err, "error status set"); result = ftape_report_error(&error, &command, 1); if (result < 0) { TRACE(ft_t_err, "report_error_code failed: %d", result); /* hope it's working next time */ ftape_reset_drive(); TRACE_EXIT -EIO; } else if (error != 0) { TRACE(ft_t_noise, "error code : %d", error); TRACE(ft_t_noise, "error command: %d", command); } } if (status & QIC_STATUS_NEW_CARTRIDGE) { unsigned int error; qic117_cmd_t command; const ft_trace_t old_tracing = TRACE_LEVEL; SET_TRACE_LEVEL(ft_t_bug); /* Undocumented feature: Must clear (not present!) * error here or we'll fail later. */ ftape_report_error(&error, &command, 1); SET_TRACE_LEVEL(old_tracing); TRACE(ft_t_info, "status: new cartridge"); ft_new_tape = 1; } else { ft_new_tape = 0; } FT_SIGNAL_EXIT(_DONT_BLOCK); } while (status & QIC_STATUS_ERROR); ft_no_tape = !(status & QIC_STATUS_CARTRIDGE_PRESENT); ft_write_protected = (status & QIC_STATUS_WRITE_PROTECT) != 0; if (ft_no_tape) { TRACE(ft_t_warn, "no cartridge present"); } else { if (ft_write_protected) { TRACE(ft_t_noise, "Write protected cartridge"); } } TRACE_EXIT 0; }
int main(int argc, char* argv[]) { if(argc > 1 && strcmp(argv[1], "-v") == 0) { cout<<"SinaShow DCS Version Infomation:"<<endl; cout<<"CrsTrans Version: "<<gstrDCSWorkerVersion.c_str()<<endl; cout<<"Copyright (C) Beijing Sina Information Technology Co.,Ltd 2003-2009"<<endl; return 0; } if(argc > 1 && strcmp(argv[1], "-h") == 0) { help_info(); return 0; } if(argc > 1 && strcmp(argv[1], "-f") != 0) { help_info(); return 0; } string lstrConfigName = ""; if(argc > 1 && strcmp(argv[1], "-f") == 0) { lstrConfigName = argv[2]; if(lstrConfigName.empty()) { help_info(); return 0; } } char lszLogFileName[255]; memset(lszLogFileName, 0, 255); CFileStream::GetAppPath(lszLogFileName,255); string lstrAppPath = lszLogFileName; string lstrApp = lstrAppPath.substr(0, lstrAppPath.find_last_of('/')); if (chdir(lstrApp.c_str())) { cout<<"crs_trans error: chdir error."<<lszLogFileName<<endl; return 0; } goDebugTrace = new CDebugTrace; unsigned int process_id = CCommon::GetProcessId(); //设置日志文件信息 SET_TRACE_LEVEL(5); unsigned liOptions = (CDebugTrace::Timestamp | CDebugTrace::LogLevel & ~CDebugTrace::FileAndLine | CDebugTrace::AppendToFile); SET_TRACE_OPTIONS(GET_TRACE_OPTIONS() | liOptions); strcpy(strrchr(lszLogFileName,'/'),"//DCS_log"); CFileStream::CreatePath(lszLogFileName); char lszFileDate[50]; memset(lszFileDate, 0, 50); sprintf(lszFileDate, "//DCS-%u", process_id); strcat(lszLogFileName,lszFileDate); SET_LOG_FILENAME(lszLogFileName); TRACE(1,"\n\n*******************DCS调试日志VERSION:" << gstrDCSWorkerVersion.c_str() << "*******************"); TRACE(1, "配置文件信息: "<<lstrConfigName.c_str()); //加载配置文件 CDCSConfig loDCSConfig; loDCSConfig.set_conf_file_name(lstrConfigName.c_str()); bool bRet = loDCSConfig.load(); if(!bRet) { TRACE(1, "ERROR: 加载配置文件失败。"); return 0; } CDCSWorker worker; worker.SetConfig(&loDCSConfig); worker.Run(); return 0; }