Author: aschnell
Date: Fri Sep 25 14:12:29 2009
New Revision: 58773
URL: http://svn.opensuse.org/viewcvs/yast?rev=58773&view=rev
Log:
- work on extended block devt (fate #305584)
Modified:
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/AppUtil.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/AppUtil.h
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.cc
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.h
branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.cc
branches/SuSE-Code-11-SP1-Branch/storage/package/yast2-storage.changes
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/AppUtil.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/AppUtil.cc?rev=58773&r1=58772&r2=58773&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/AppUtil.cc (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/AppUtil.cc Fri Sep 25 14:12:29 2009
@@ -447,15 +447,14 @@
}
-int
-readlink(const char* path, string& buf)
+bool
+readlink(const string& path, string& buf)
{
- const int size = 1024;
- char tmp[size];
- int ret = ::readlink(path, tmp, size);
- if (ret >= 0)
- buf = string(tmp, ret);
- return ret;
+ char tmp[1024];
+ int count = ::readlink(path.c_str(), tmp, sizeof(tmp));
+ if (count >= 0)
+ buf = string(tmp, count);
+ return count != -1;
}
@@ -476,7 +475,7 @@
string full = string(path) + "/" + entry->d_name;
string tmp;
- if (readlink(full.c_str(), tmp) != -1)
+ if (readlink(full, tmp))
{
string::size_type pos = tmp.find_first_not_of("./");
if (pos != string::npos)
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/AppUtil.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/AppUtil.h?rev=58773&r1=58772&r2=58773&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/AppUtil.h (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/AppUtil.h Fri Sep 25 14:12:29 2009
@@ -37,6 +37,8 @@
const string& delim = "=",
const string& removeSur = " \t\n" );
+ bool readlink(const string& path, string& buf);
+
void getUdevMap(const char* path, std::map& m);
void getRevUdevMap(const char* path, std::map& m);
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.cc?rev=58773&r1=58772&r2=58773&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.cc (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.cc Fri Sep 25 14:12:29 2009
@@ -281,53 +281,105 @@
return( ret );
}
-bool Disk::getSysfsInfo( const string& SysfsDir )
+
+ bool
+ Disk::getSysfsInfo(const string& sysfsdir, SysfsInfo& sysfsinfo)
{
- bool ret = true;
- sysfs_dir = SysfsDir;
- y2mil( "sysfs_dir:" << sysfs_dir );
- string SysfsFile = sysfs_dir+"/range";
- if( access( SysfsFile.c_str(), R_OK )==0 )
+ string sysfsfile = sysfsdir + "/dev";
+ if (access(sysfsfile.c_str(), R_OK) == 0)
{
- ifstream File( SysfsFile.c_str() );
- classic(File);
- File >> range;
- if( range<=1 ) ret = false;
+ ifstream file(sysfsfile.c_str());
+ classic(file);
+ char c;
+ file >> sysfsinfo.mjr >> c >> sysfsinfo.mnr;
}
- else
+ else
{
- ret = false;
+ y2war("reading " << sysfsfile << " failed");
+ return false;
}
- SysfsFile = sysfs_dir+"/dev";
- if( access( SysfsFile.c_str(), R_OK )==0 )
+
+ sysfsfile = sysfsdir + "/device";
+ if (!readlink(sysfsfile, sysfsinfo.device))
{
- ifstream File( SysfsFile.c_str() );
- classic(File);
- char c;
- File >> mjr;
- File >> c;
- File >> mnr;
+ // not always available so no error
+ sysfsinfo.device.clear();
}
- else
+
+ sysfsfile = sysfsdir + "/range";
+ if (access(sysfsfile.c_str(), R_OK) == 0)
{
- ret = false;
+ ifstream file(sysfsfile.c_str());
+ classic(file);
+ file >> sysfsinfo.range;
}
- SysfsFile = sysfs_dir+"/device";
- char lbuf[1024+1];
- int count;
- if( access( SysfsFile.c_str(), R_OK )==0 &&
- (count=readlink( SysfsFile.c_str(), lbuf, sizeof(lbuf) ))>0 )
+ else
{
- string lname( lbuf, count );
- if( lname.find( "/session" )!=string::npos )
- iscsi = true;
- y2mil( "lname:" << lname );
+ y2war("reading " << sysfsfile << " failed");
+ return false;
}
- y2milestone( "Ret:%d Range:%ld Major:%ld Minor:%ld iSCSI:%d",
- ret, range, mjr, mnr, iscsi );
- return( ret );
+
+ sysfsfile = sysfsdir + "/ext_range";
+ if (access(sysfsfile.c_str(), R_OK) == 0)
+ {
+ ifstream file(sysfsfile.c_str());
+ classic(file);
+ file >> sysfsinfo.range;
+ }
+
+ sysfsfile = sysfsdir + "/size";
+ if (access(sysfsfile.c_str(), R_OK) == 0)
+ {
+ ifstream file(sysfsfile.c_str());
+ classic(file);
+ file >> sysfsinfo.size;
+ }
+ else
+ {
+ y2war("reading " << sysfsfile << " failed");
+ return false;
+ }
+
+ y2mil("sysfsdir:" << sysfsdir << " mjr:" << sysfsinfo.mjr << " mnr:" << sysfsinfo.mnr <<
+ " device:" << sysfsinfo.device << " range:" << sysfsinfo.range << " size:" <<
+ sysfsinfo.size);
+
+ return true;
+ }
+
+
+ bool
+ Disk::getSysfsInfo(const string& SysfsDir)
+ {
+ bool ret = true;
+ sysfs_dir = SysfsDir;
+ y2mil("sysfs_dir:" << sysfs_dir);
+
+ SysfsInfo sysfsinfo;
+ if (getSysfsInfo(sysfs_dir, sysfsinfo))
+ {
+ range = sysfsinfo.range;
+ if (range <= 1)
+ ret = false;
+
+ mjr = sysfsinfo.mjr;
+ mnr = sysfsinfo.mnr;
+
+ if (boost::contains(sysfsinfo.device, "/session"))
+ iscsi = true;
+ }
+ else
+ {
+ ret = false;
+ }
+
+ y2mil("ret:" << ret << " range:" << range << " major:" << mjr << " minor:" << mnr <<
+ " iscsi:" << iscsi);
+
+ return ret;
}
+
void Disk::getGeometry( const string& line, unsigned long& c, unsigned& h,
unsigned& s )
{
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.h?rev=58773&r1=58772&r2=58773&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.h (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Disk.h Fri Sep 25 14:12:29 2009
@@ -108,6 +108,17 @@
static std::pair getDiskPartition( const string& dev );
static unsigned long long maxSizeLabelK( const string& label );
+ struct SysfsInfo
+ {
+ unsigned long mjr;
+ unsigned long mnr;
+ string device;
+ unsigned long range;
+ unsigned long long size;
+ };
+
+ static bool getSysfsInfo(const string& sysfsdir, SysfsInfo& sysfsinfo);
+
protected:
// iterators over partitions
Modified: branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.cc?rev=58773&r1=58772&r2=58773&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.cc (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/libstorage/src/Storage.cc Fri Sep 25 14:12:29 2009
@@ -666,8 +666,9 @@
}
}
+
void
-Storage::autodetectDisks( ProcPart& ppart )
+ Storage::autodetectDisks(ProcPart& parts)
{
DIR *Dir;
struct dirent *Entry;
@@ -679,68 +680,51 @@
getUdevMap("/dev/disk/by-id", by_id);
list<DiskData> dl;
while( (Entry=readdir( Dir ))!=NULL )
- {
- int Range=0;
- unsigned long long Size = 0;
- string SysfsDir = string(SYSFSDIR "/") + Entry->d_name;
- string SysfsFile = SysfsDir + "/range";
- y2mil("autodetectDisks sysfsdir:" << SysfsDir);
- y2mil("autodetectDisks Range access:" << access(SysfsFile.c_str(), R_OK));
- if( access( SysfsFile.c_str(), R_OK )==0 )
- {
- ifstream File( SysfsFile.c_str() );
- classic(File);
- File >> Range;
- }
- SysfsFile = SysfsDir+"/size";
- if( access( SysfsFile.c_str(), R_OK )==0 )
- {
- ifstream File( SysfsFile.c_str() );
- classic(File);
- File >> Size;
- }
+ {
string dn = Entry->d_name;
- y2mil( "autodetectDisks Range:" << Range << " Size:" << Size );
- if( Range>1 && (Size>0||dn.find( "dasd" )==0) )
+
+ if (dn == "." || dn == "..")
+ continue;
+
+ Disk::SysfsInfo sysfsinfo;
+ if (!Disk::getSysfsInfo(SYSFSDIR "/" + dn, sysfsinfo))
+ continue;
+
+ if (sysfsinfo.range > 1 && (sysfsinfo.size > 0 || dn.find("dasd") == 0))
+ {
+ DiskData::DTyp t = (dn.find("dasd") == 0) ? DiskData::DASD : DiskData::DISK;
+ dl.push_back(DiskData(dn, t, sysfsinfo.size / 2));
+ }
+ else if (sysfsinfo.range == 1 && sysfsinfo.size > 0)
+ {
+ if (sysfsinfo.device.find( "/xen/vbd" ) != string::npos && isdigit(dn[dn.size() - 1]))
{
- DiskData::DTyp t = (dn.find( "dasd" )==0)?DiskData::DASD
- :DiskData::DISK;
- dl.push_back( DiskData( dn, t, Size/2 ) );
- }
- else if( Range==1 && Size>0 )
- {
- SysfsFile = SysfsDir+"/device";
- string devname;
- int ret;
- char lbuf[1024+1];
- if( access( SysfsFile.c_str(), R_OK )==0 &&
- (ret=readlink( SysfsFile.c_str(), lbuf, sizeof(lbuf) ))>0 )
- {
- devname.append( lbuf, ret );
- y2mil( "devname:" << devname );
- }
- if( devname.find( "/xen/vbd" )!=string::npos &&
- isdigit(dn[dn.size()-1]) )
- {
- dl.push_back( DiskData( dn, DiskData::XEN, Size/2 ) );
- }
+ dl.push_back(DiskData(dn, DiskData::XEN, sysfsinfo.size / 2));
}
}
+ }
closedir( Dir );
y2mil( "dl: " << dl );
for( list<DiskData>::iterator i = dl.begin(); i!=dl.end(); ++i )
{
- initDisk( *i, ppart );
+ initDisk(*i, parts);
}
y2mil( "dl: " << dl );
- for( list<DiskData>::iterator i = dl.begin(); i!=dl.end(); ++i )
+ for( list<DiskData>::const_iterator i = dl.begin(); i!=dl.end(); ++i )
{
if( i->d )
{
- string tmp;
- if (!by_path[i->dev].empty())
- tmp = by_path[i->dev].front();
- i->d->setUdevData(tmp, by_id[i->dev]);
+ string tmp1;
+ map::const_iterator it1 = by_path.find(i->dev);
+ if (it1 != by_path.end())
+ tmp1 = it1->second.front();
+
+ list<string> tmp2;
+ map::const_iterator it2 = by_id.find(i->dev);
+ if (it2 != by_id.end())
+ tmp2 = it2->second;
+
+ i->d->setUdevData(tmp1, tmp2);
addToList( i->d );
}
}
@@ -751,6 +735,7 @@
}
}
+
void
Storage::detectFsData( const VolIterator& begin, const VolIterator& end,
ProcMounts& mounts )
Modified: branches/SuSE-Code-11-SP1-Branch/storage/package/yast2-storage.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/storage/package/yast2-storage.changes?rev=58773&r1=58772&r2=58773&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP1-Branch/storage/package/yast2-storage.changes (original)
+++ branches/SuSE-Code-11-SP1-Branch/storage/package/yast2-storage.changes Fri Sep 25 14:12:29 2009
@@ -1,4 +1,9 @@
-------------------------------------------------------------------
+Fri Sep 25 13:57:59 CEST 2009 - aschnell@suse.de
+
+- work on extended block devt (fate #305584)
+
+-------------------------------------------------------------------
Fri Sep 25 12:04:20 CEST 2009 - aschnell@suse.de
- added environment parameter to Storage constructor and factories
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org