Author: mpatelcz Date: Fri Nov 6 16:42:24 2009 New Revision: 59383 URL: http://svn.opensuse.org/viewcvs/yast?rev=59383&view=rev Log: Rework after review continued. Detection of MD RAIDs changed. Modified: branches/tmp/mpatelcz/SP1-md/libstorage/src/MdPartCo.cc branches/tmp/mpatelcz/SP1-md/libstorage/src/MdPartCo.h branches/tmp/mpatelcz/SP1-md/libstorage/src/Storage.cc branches/tmp/mpatelcz/SP1-md/libstorage/src/Storage.h Modified: branches/tmp/mpatelcz/SP1-md/libstorage/src/MdPartCo.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mpatelcz/SP1-md/libstorage/src/MdPartCo.cc?rev=59383&r1=59382&r2=59383&view=diff ============================================================================== --- branches/tmp/mpatelcz/SP1-md/libstorage/src/MdPartCo.cc (original) +++ branches/tmp/mpatelcz/SP1-md/libstorage/src/MdPartCo.cc Fri Nov 6 16:42:24 2009 @@ -1993,6 +1993,35 @@ } } +int MdPartCo::scanForRaid(list<string>& raidNames) +{ + int ret = -1; + SystemCmd c(MDADMBIN " -Es "); + raidNames.clear(); + + if( c.retcode() == 0 ) + { + raidNames.clear(); + for(unsigned i = 0; i < c.numLines(false); i++ ) + { + //Example: + //ARRAY metadata=imsm UUID=b...5 + //ARRAY /dev/md/Vol_r5 container=b...5 member=0 UUID=0...c + //ARRAY metadata=imsm UUID=8...b + //ARRAY /dev/md/Vol0 container=8...b member=0 UUID=7...9 + string line = *c.getLine(i); + string dev_name = extractNthWord( 1, line ); + if( dev_name.find("/dev/md/") == 0 ) + { + dev_name.erase(0,8); + raidNames.push_back(dev_name); + } + } + ret = 0; + } + y2mil(" Detected list of MD RAIDs : " << raidNames); + return ret; +} string MdPartCo::md_names[] = { "unknown", "raid0", "raid1", "raid5", "raid6", "raid10", "multipath" }; Modified: branches/tmp/mpatelcz/SP1-md/libstorage/src/MdPartCo.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mpatelcz/SP1-md/libstorage/src/MdPartCo.h?rev=59383&r1=59382&r2=59383&view=diff ============================================================================== --- branches/tmp/mpatelcz/SP1-md/libstorage/src/MdPartCo.h (original) +++ branches/tmp/mpatelcz/SP1-md/libstorage/src/MdPartCo.h Fri Nov 6 16:42:24 2009 @@ -182,6 +182,10 @@ static bool matchRegex( const string& dev ); static bool mdStringNum( const string& name, unsigned& num ); + // This function will scann for MD RAIDs and will return + // list with detected RAID names. + static int scanForRaid(list<string>& raidNames); + protected: // iterators over partitions // protected typedefs for iterators over partitions Modified: branches/tmp/mpatelcz/SP1-md/libstorage/src/Storage.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mpatelcz/SP1-md/libstorage/src/Storage.cc?rev=59383&r1=59382&r2=59383&view=diff ============================================================================== --- branches/tmp/mpatelcz/SP1-md/libstorage/src/Storage.cc (original) +++ branches/tmp/mpatelcz/SP1-md/libstorage/src/Storage.cc Fri Nov 6 16:42:24 2009 @@ -206,7 +206,9 @@ { if( discoverMdPVols() == true ) { - MdPartCo::activate( false, tmpDir() ); + // if 'yes' then activate md prior to dm + MdPartCo::activate( true, tmpDir() ); + waitForDevice(); } //Note: //dmraid will not activate devices that were activated by @@ -398,31 +400,46 @@ list<string> -Storage::dispatchMdDevs(const list<string>& inList) const +Storage::dispatchMdDevs(const list<string>& inList, ProcPart& ppart ) const { y2mil(" called "); - list<string> mdpList; + list<string> mdpList; + for( list<string>::const_iterator i=inList.begin(); i!=inList.end(); ++i ) { - if( instsys() ) + string reg; + list <string> parts; + // Search /proc/partitions for partitions. + reg = *i + "p[1-9]+"; + parts.clear(); + parts = ppart.getMatchingEntries( reg ); + if( !parts.empty() ) { - // 1. With Partition Table - // 2. Without Partition Table and without FS on it. - // 3. this gives: No FS. - if (!MdPartCo::hasFileSystem(*i)) - { - mdpList.push_back(*i); - } + mdpList.push_back(*i); } else { - // In 'normal' mode ONLY volume with Partition Table. - if( MdPartCo::hasPartitionTable(*i)) + if( instsys() ) { - mdpList.push_back(*i); + // 1. With Partition Table + // 2. Without Partition Table and without FS on it. + // 3. this gives: No FS. + if (!MdPartCo::hasFileSystem(*i)) + { + mdpList.push_back(*i); + } + } + else + { + // In 'normal' mode ONLY volume with Partition Table. + // Partitions should be visible already so check it. + if( !parts.empty() || MdPartCo::hasPartitionTable(*i)) + { + mdpList.push_back(*i); + } } } - } + } // for y2mil("List of partitionable devs: " << mdpList); return mdpList; } @@ -444,7 +461,7 @@ else { const list<string> l = MdPartCo::getMdRaids(); - const list<string> mdpartlist = dispatchMdDevs(l); + const list<string> mdpartlist = dispatchMdDevs(l, ppart); // for( list<string>::const_iterator i = mdpartlist.begin(); i != mdpartlist.end(); @@ -485,80 +502,41 @@ return false; } string mdDevs = ""; - string partedDevs = ""; - string nonFSDevs = ""; bool ret = MdPartCo::isImsmPlatform(); if( ret == true ) { y2mil("Intel SW RAID Platform detected."); - MdPartCo::activate( true, tmpDir() ); - waitForDevice(); - list<string> l = MdPartCo::getMdRaids(); + list <string> l; + if( MdPartCo::scanForRaid(l) != 0 ) + { + MdPartCo::activate( true, tmpDir() ); + waitForDevice(); + l = MdPartCo::getMdRaids(); + MdPartCo::activate( false, "" ); + } if (!l.empty()) { // At least ONE Volume must be detected mdDevs.clear(); - partedDevs.clear(); - nonFSDevs.clear(); for( list<string>::const_iterator i=l.begin(); i!=l.end(); ++i ) { - if( MdPartCo::hasPartitionTable(*i) ) - { - //Has a PT - partedDevs += (" " + *i); - } - else if ( MdPartCo::hasFileSystem(*i) == false ) - { - // Doesn't have FS - nonFSDevs += (" " + *i); - } mdDevs += " " + *i; } y2mil(" md raids:" + mdDevs); - y2mil(" md raids with partition table :" + partedDevs); - y2mil(" md raids no partition table and no FS :" + nonFSDevs); if( !mdDevs.empty()) { - string s1; - string s2; - if( !partedDevs.empty() ) - { - // add string - s1 = sformat( - _("Devices:\n" - "%1$s\n" - "have partition table.\n"),partedDevs.c_str()); - } - else - { - s1.clear(); - } - if( !nonFSDevs.empty() ) - { - s2 = sformat( - _("Devices:\n" - "%1$s\n" - "don't have either Partition Table nor Filesystem.\n" - "You can create partition on them and install Operating\n" - "System on selected partitions.\n"),nonFSDevs.c_str()); - } - else - { - s2.clear(); - } - //FIXME: callback, info and decision. string txt = sformat( // popup text %1$s is replaced by disk name e.g. /dev/hda _("You are running on the Intel(R) Matrix Storage Manager compatible platform.\n" "\n" - "Following MD compatibible RAID devices were detected:\n" + "Following MD compatible RAID devices were detected:\n" "%1$s\n" - "%2$s" - "%3$s" - "\n" - "Do you want MD Partitionable subsystem to manage those partitions?" - ), mdDevs.c_str(),s1.c_str(),s2.c_str() ); + "If they are clean devices or contain partitions then you can choose to use\n" + "MD Partitionable RAID sysbsystem to handle them. In case of clean device you\n" + "will be able to install system on it and boot from such RAID.\n" + "Do you want MD Partitionable RAID subsystem to manage those partitions?" + ), mdDevs.c_str() ); if( yesnoPopupCb(txt) ) { @@ -567,7 +545,6 @@ } else { - MdPartCo::setHandlingDev(false); ret = false; } } @@ -582,9 +559,7 @@ /* No RAIDs at all */ ret = false; } - // Get RAIDs } - MdPartCo::activate( false, "" ); y2mil(" Exiting with status: " << ret); return ret; } Modified: branches/tmp/mpatelcz/SP1-md/libstorage/src/Storage.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mpatelcz/SP1-md/libstorage/src/Storage.h?rev=59383&r1=59382&r2=59383&view=diff ============================================================================== --- branches/tmp/mpatelcz/SP1-md/libstorage/src/Storage.h (original) +++ branches/tmp/mpatelcz/SP1-md/libstorage/src/Storage.h Fri Nov 6 16:42:24 2009 @@ -1825,7 +1825,7 @@ void detectMultipath(); void detectMds(); void detectMdParts(ProcPart& ppart); - list<string> dispatchMdDevs(const list<string>& inList) const; + list<string> dispatchMdDevs(const list<string>& inList, ProcPart& ppart) const; //Discovers that platfrom is IMSM and Partitionable RAID Volumes //can be on it bool discoverMdPVols(); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org