diff -ur deborig-0.0.6-3.2/raidutils-0.0.6/raideng/osd_unix.cpp deblocal-0.0.6-4ontko1_cleaned/raidutils-0.0.6/raideng/osd_unix.cpp --- deborig-0.0.6-3.2/raidutils-0.0.6/raideng/osd_unix.cpp 2008-01-28 14:28:45.000000000 -0500 +++ deblocal-0.0.6-4ontko1_cleaned/raidutils-0.0.6/raideng/osd_unix.cpp 2008-02-07 00:49:38.780586661 -0500 @@ -378,32 +378,50 @@ if(ioMethod==DPT_IO_PASS_THRU) { - - /* Try To Open The First Adapter Device */ - - for(Index = 0; Index < 20; ++Index) + // make sure the device entry represents an active device and + // not just a device file that was probed unsuccessfully (so we + // don't wait 20 seconds trying to connect to it in the "for" + // loop... and so we don't generate a "could not be opened" + // error message mentioning the name of this probed-but-not-found + // device file, given that we wouldn't expect to be able to + // open it anyway). + if(DefaultHbaDev->Flags == 0 ) { - FileID = open(DefaultHbaDev->NodeName,O_RDONLY); - if((FileID == -1)&&(errno == ENOENT)) - { - sleep(1); - } - else { - break; - } + // this entry was NOT initialized, so print an error message + // (and bypass any attempts to open the file; we simply return + // MSG_RTN_FAILED to the caller) + FormatTimeString(TimeString,time(0)); + printf("\nosdIDrequest : %s Fatal error, DefaultHbaDev does not point to an active controller.\n", TimeString); + fflush(stdout); } + else { + + /* Try To Open The First Adapter Device */ + + for(Index = 0; Index < 20; ++Index) + { + FileID = open(DefaultHbaDev->NodeName,O_RDONLY); + if((FileID == -1)&&(errno == ENOENT)) + { + sleep(1); + } + else { + break; + } + } #ifdef _SINIX_ADDON - if (DemoMode) - FileID = 99; + if (DemoMode) + FileID = 99; #endif - if(FileID != -1) - { - retVal = MSG_RTN_COMPLETED; - close(FileID); - } - else printf("\nosdIOrequest : File %s Could Not Be Opened", - DefaultHbaDev->NodeName); + if(FileID != -1) + { + retVal = MSG_RTN_COMPLETED; + close(FileID); + } + else printf("\nosdIOrequest : File %s Could Not Be Opened", + DefaultHbaDev->NodeName); + } } if(Verbose) printf("\nosdIOrequest : Return = %x",retVal); @@ -505,6 +523,15 @@ retVal = MSG_RTN_COMPLETED; NumHBAs = BuildNodeNameList(); + // If there are no HBAs found, abort with an explict error message. + if(NumHBAs == 0) + { + FormatTimeString(TimeString,time(0)); + printf("\nosdOpenEngine : %s Fatal error, no active controller device files found.\n", TimeString); + retVal = MSG_RTN_FAILED; + fflush(stdout); + } + if(Verbose) { FormatTimeString(TimeString,time(0)); @@ -3747,16 +3774,56 @@ NumEntries = 0; # if (defined(_DPT_LINUX_I2O)) + uCHAR LinuxI2ODataBuff[MAX_I2O_CONTROLLERS]; + memset(&pkt, 0, sizeof(EATA_CP)); HbaDevs[NumEntries].Flags = 0; strcpy(HbaDevs[NumEntries].NodeName, DEV_CTL); - IoctlRtn = osdSendIoctl(&HbaDevs[NumEntries], I2OGETIOPS, (uCHAR *)&NumEntries, &pkt); + IoctlRtn = osdSendIoctl(&HbaDevs[NumEntries], I2OGETIOPS, LinuxI2ODataBuff, &pkt); if(!IoctlRtn) { - for(i = 0; i < NumEntries; i ++) { - HbaDevs[i].Flags = NODE_FILE_VALID_HBA_B | NODE_FILE_I2O_HBA_B; - HbaDevs[i].IoAddress = UINTPTR_MAX; - strcpy(HbaDevs[i].NodeName, DEV_CTL); - } + // step through the returned data buffer and look for the + // non-zero entries, which indicate an active IOP. For each + // one we find, add a corresponding entry in HbaDevs. + for(i = 0; i < MAX_I2O_CONTROLLERS; i ++) { + if ( LinuxI2ODataBuff[i] != 0 ) + { + if(NumEntries >= MAX_HAS) + { + FormatTimeString(TimeString,time(0)); + + printf("\nBuildNodeNameList : %s Warning: Found more than %d Linux I2O Controlers; ignoring those that won't fit in the HbaDevs array.", + TimeString, MAX_HAS); + + fflush(stdout); + break; + } + if(Verbose) + { + FormatTimeString(TimeString,time(0)); + + printf("\nBuildNodeNameList : %s Found Linux I2O Controler, using %s device file for utility-relative controller number %d.", + TimeString, DEV_CTL, NumEntries); + + fflush(stdout); + } + + HbaDevs[NumEntries].Flags = NODE_FILE_VALID_HBA_B | NODE_FILE_I2O_HBA_B; + HbaDevs[NumEntries].IoAddress = UINTPTR_MAX; + strcpy(HbaDevs[NumEntries].NodeName, DEV_CTL); + + ++NumEntries; + } + else { + // for now, we'll assume that all the active IOP entries + // are at the front of the returned buffer. In order to + // support "gaps", we'd need to record the IOP index in the + // NodeFiles_S structure and use that instead of HbaNum when + // we call the I2OPASSTHRU ioctl (or make sure that + // everything that looks at HbaDevs can handle inactive + // entries in the middle of the array). + break; + } + } // for(i = 0; i < MAX_I2O_CONTROLLERS; i ++) } # endif diff -ur deborig-0.0.6-3.2/raidutils-0.0.6/raidutil/parser.cpp deblocal-0.0.6-4ontko1_cleaned/raidutils-0.0.6/raidutil/parser.cpp --- deborig-0.0.6-3.2/raidutils-0.0.6/raidutil/parser.cpp 2004-04-29 05:20:12.000000000 -0500 +++ deblocal-0.0.6-4ontko1_cleaned/raidutils-0.0.6/raidutil/parser.cpp 2008-02-07 00:24:56.515710411 -0500 @@ -730,6 +730,7 @@ { EventLog *temp = new EventLog (components, eventLogOpts); cmd_List->add_Item (*temp); + delete temp; } else Error_in_Parsing(EventStrings[STR_PARSE_ERR_MUST_SPECIFY_ADDRESS], this_Commands_Text); @@ -1645,7 +1646,7 @@ temp = new NvramBit (Cache_Stale, params.hba_Num, temp_set); else temp = new NvramBit (Cache_Stale, -1, temp_set); - cmd_List->add_Item (*temp); + cmd_List->add_Item (*temp); delete temp; } else if (!strncmp(command_Line, "+cluster", strlen("cluster")))