Author: mpatelcz
Date: Wed Sep 23 18:36:19 2009
New Revision: 58727
URL: http://svn.opensuse.org/viewcvs/yast?rev=58727&view=rev
Log:
Moved md initialization ahead of disks initialization.
Modified:
branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/Md.cc
branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/Md.h
branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/MdCo.cc
branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/MdCo.h
branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/Storage.cc
Modified: branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/Md.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/Md.cc?rev=58727&r1=58726&r2=58727&view=diff
==============================================================================
--- branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/Md.cc (original)
+++ branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/Md.cc Wed Sep 23 18:36:19 2009
@@ -860,27 +860,55 @@
}
+/* For now it only understand 'external:' */
+void
+Md::getParent(string& par)
+{
+ string ret;
+ string con = sb_ver;
+ string::size_type pos1;
+ string::size_type pos2;
+ if( con.find("external:")==0 )
+ {
+ if( (pos1=con.find_first_of("/")) != string::npos )
+ {
+ if( (pos2=con.find_last_of("/")) != string::npos)
+ {
+ if( pos1 != pos2)
+ {
+ par.clear();
+ par = con.substr(pos1+1,pos2-pos1-1);
+ }
+ }
+ }
+ else
+ {
+ // Container
+ par.clear();
+ }
+ }
+}
bool Md::readProp(enum MdProperty prop, string& val)
{
string path = sysfs_path + nm + "/md/" + md_props[prop];
y2mil("Path : " << path);
- std::ifstream file( path.c_str() );
- classic(file);
- if( file.good() )
+ if( access( path.c_str(), R_OK )==0 )
{
- getline(file,val);
+ std::ifstream file( path.c_str() );
+ classic(file);
+ file >> val;
+ file.close();
+ file.clear();
}
else
{
y2mil("File: " << sysfs_path << md_props[prop] << " = FAILED");
return false;
}
- file.close();
- file.clear();
y2mil("File: " << sysfs_path << md_props[prop] << " = " << val);
return true;
}
@@ -903,10 +931,10 @@
y2mil("Entry : " << tmpS);
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
continue;
+
y2mil("Adding disk : " << tmpS);
devs.push_back( ("/dev/"+tmpS) );
- /* Get disk and mark it as used by MD. */
}
closedir(dir);
}
Modified: branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/Md.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/Md.h?rev=58727&r1=58726&r2=58727&view=diff
==============================================================================
--- branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/Md.h (original)
+++ branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/Md.h Wed Sep 23 18:36:19 2009
@@ -29,6 +29,9 @@
void setArrayState( storage::MdArrayState val ) { md_state = val; }
/* */
+ /* If this is volume it will return parent container. */
+ void getParent(string& par);
+
unsigned long chunkSize() const { return chunk; }
void setChunkSize( unsigned long val ) { chunk=val; }
void setMdUuid( const string&val ) { md_uuid=val; }
Modified: branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/MdCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/MdCo.cc?rev=58727&r1=58726&r2=58727&view=diff
==============================================================================
--- branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/MdCo.cc (original)
+++ branches/tmp/mpatelcz/SLE-11-SP1-Stash/libstorage/src/MdCo.cc Wed Sep 23 18:36:19 2009
@@ -81,10 +81,22 @@
}
}
+
+/* Call after parsing '/proc/mdstat'.
+ * It will connect any md volume with proper container.
+ * Each volume will be set as 'used by'
+ */
+void
+MdCo::ConnectMdDevs()
+{
+ //
+}
+
+
void
MdCo::getMdData()
{
- y2milestone( "begin" );
+ y2milestone( "Gathering data begins..." );
string line;
string dev_name;
std::ifstream file( "/proc/mdstat" );
@@ -110,6 +122,7 @@
}
file.close();
file.clear();
+ /* */
file.open( (getStorage()->root()+"/etc/raidtab").c_str() );
MdIter i;
getline( file, line );
@@ -147,15 +160,31 @@
}
getline( file, line );
}
+
+ /* Used by! Activate here disks? */
+ /* TBD: Disk is used by container and volume: We choose container. */
MdPair p=mdPair(Md::notDeleted);
for( MdIter i=p.begin(); i!=p.end(); ++i )
- {
- string num = "md"+decString(i->nr());
- list<string> devs;
- i->getDevs( devs );
- for( list<string>::iterator s=devs.begin(); s!=devs.end(); ++s )
- getStorage()->setUsedBy( *s, UB_MD, num );
- }
+ {
+ if( i->personality() == storage::CONTAINER )
+ {
+ y2mil("MD device is a container.");
+ string num = "md"+decString(i->nr());
+ list<string> devs;
+ i->getDevs( devs );
+ y2mil("MdDev : " << num << " with devs : " << devs);
+ for( list<string>::iterator s=devs.begin(); s!=devs.end(); ++s )
+ {
+ y2mil("Setting device : " << *s << " as used by UB_MD " << num);
+ getStorage()->setUsedBy( *s, UB_MD, num );
+ }
+ }
+ else
+ {
+ y2mil("MD device is not a container. It will be used by other MD");
+ /* Get Parent container and mark as used by. */
+ }
+ }
}
void
@@ -182,11 +211,46 @@
}
}
+/* FIXME: md not volume in list.. :( */
+void
+MdCo::connectMd(Md* m)
+{
+ list