Author: aschnell
Date: Thu Apr 16 18:57:18 2009
New Revision: 56825
URL: http://svn.opensuse.org/viewcvs/yast?rev=56825&view=rev
Log:
- some cleanup
Modified:
trunk/storage/libstorage/src/AppUtil.cc
trunk/storage/libstorage/src/AppUtil.h
trunk/storage/libstorage/src/Disk.cc
trunk/storage/libstorage/src/Storage.cc
Modified: trunk/storage/libstorage/src/AppUtil.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/AppUtil.cc?rev=56825&r1=56824&r2=56825&view=diff
==============================================================================
--- trunk/storage/libstorage/src/AppUtil.cc (original)
+++ trunk/storage/libstorage/src/AppUtil.cc Thu Apr 16 18:57:18 2009
@@ -351,15 +351,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;
}
@@ -380,7 +379,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: trunk/storage/libstorage/src/AppUtil.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/AppUtil.h?rev=56825&r1=56824&r2=56825&view=diff
==============================================================================
--- trunk/storage/libstorage/src/AppUtil.h (original)
+++ trunk/storage/libstorage/src/AppUtil.h Thu Apr 16 18:57:18 2009
@@ -28,6 +28,8 @@
const string& delim = "=",
const string& removeSur = " \t\n" );
+ bool readlink(const string& path, string& buf);
+
map getUdevMap(const char* path);
map getRevUdevMap(const char* path);
Modified: trunk/storage/libstorage/src/Disk.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Disk.cc?rev=56825&r1=56824&r2=56825&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Disk.cc (original)
+++ trunk/storage/libstorage/src/Disk.cc Thu Apr 16 18:57:18 2009
@@ -291,12 +291,9 @@
ret = false;
}
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 )
+ string lname;
+ if (access(SysfsFile.c_str(), R_OK) == 0 && readlink(SysfsFile, lname))
{
- string lname( lbuf, count );
if( lname.find( "/session" )!=string::npos )
iscsi = true;
y2mil("lname:" << lname);
Modified: trunk/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.cc?rev=56825&r1=56824&r2=56825&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.cc (original)
+++ trunk/storage/libstorage/src/Storage.cc Thu Apr 16 18:57:18 2009
@@ -368,9 +368,7 @@
if( test() )
{
glob_t globbuf;
-
- if( glob( (testdir+"/disk_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
- &globbuf) == 0)
+ if( glob( (testdir+"/disk_*[!~0-9]").c_str(), GLOB_NOSORT, 0, &globbuf) == 0)
{
for (char** p = globbuf.gl_pathv; *p != 0; *p++)
addToList( new Disk( this, *p ) );
@@ -450,8 +448,7 @@
if( test() )
{
glob_t globbuf;
- if( glob( (testdir+"/lvm_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
- &globbuf) == 0)
+ if( glob( (testdir+"/lvm_*[!~0-9]").c_str(), GLOB_NOSORT, 0, &globbuf) == 0)
{
for (char** p = globbuf.gl_pathv; *p != 0; *p++)
addToList( new LvmVg( this, *p, true ) );
@@ -487,8 +484,7 @@
if( test() )
{
glob_t globbuf;
- if( glob( (testdir+"/dmraid_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
- &globbuf) == 0)
+ if( glob( (testdir+"/dmraid_*[!~0-9]").c_str(), GLOB_NOSORT, 0, &globbuf) == 0)
{
// TODO: load test data
}
@@ -529,8 +525,7 @@
if( test() )
{
glob_t globbuf;
- if( glob( (testdir+"/dmmultipath_*[!~0-9]").c_str(), GLOB_NOSORT, 0,
- &globbuf) == 0)
+ if( glob( (testdir+"/dmmultipath_*[!~0-9]").c_str(), GLOB_NOSORT, 0, &globbuf) == 0)
{
// TODO: load test data
}
@@ -707,12 +702,10 @@
{
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 )
+ string lname;
+ if (access(SysfsFile.c_str(), R_OK) == 0 && readlink(SysfsFile, lname))
{
- devname.append( lbuf, ret );
+ devname.append(lname);
y2mil( "devname:" << devname );
}
if( devname.find( "/xen/vbd" )!=string::npos &&
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org