Author: aschnell
Date: Thu May 14 12:37:41 2009
New Revision: 57162
URL: http://svn.opensuse.org/viewcvs/yast?rev=57162&view=rev
Log:
- use multimap inside ProcMounts
Modified:
trunk/storage/libstorage/src/NfsCo.cc
trunk/storage/libstorage/src/ProcMounts.cc
trunk/storage/libstorage/src/ProcMounts.h
Modified: trunk/storage/libstorage/src/NfsCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/NfsCo.cc?rev=57162&r1=57161&r2=57162&view=diff
==============================================================================
--- trunk/storage/libstorage/src/NfsCo.cc (original)
+++ trunk/storage/libstorage/src/NfsCo.cc Thu May 14 12:37:41 2009
@@ -136,8 +136,7 @@
addToList( n );
}
}
- l.clear();
- mounts.getEntries(l);
+ l = mounts.getEntries();
const char * ign_opt[] = { "hard", "rw", "v3", "v2", "lock" };
const char * ign_beg[] = { "proto=", "addr=", "vers=" };
for( list<FstabEntry>::iterator i=l.begin(); i!=l.end(); ++i )
Modified: trunk/storage/libstorage/src/ProcMounts.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/ProcMounts.cc?rev=57162&r1=57161&r2=57162&view=diff
==============================================================================
--- trunk/storage/libstorage/src/ProcMounts.cc (original)
+++ trunk/storage/libstorage/src/ProcMounts.cc Thu May 14 12:37:41 2009
@@ -3,7 +3,6 @@
Textdomain "storage"
*/
-#include <fstream>
#include "y2storage/AppUtil.h"
#include "y2storage/SystemCmd.h"
@@ -64,10 +63,12 @@
}
else
{
- co[dev].device = dev;
- co[dev].mount = dir;
- co[dev].fs = extractNthWord(2, *it);
- co[dev].opts = splitString(extractNthWord(3, *it), ",");
+ FstabEntry entry;
+ entry.device = dev;
+ entry.mount = dir;
+ entry.fs = extractNthWord(2, *it);
+ entry.opts = splitString(extractNthWord(3, *it), ",");
+ data.insert(make_pair(dev, entry));
}
}
@@ -97,13 +98,15 @@
if (pos != string::npos)
dev.erase(pos);
- co[dev].device = dev;
- co[dev].mount = "swap";
- co[dev].fs = "swap";
+ FstabEntry entry;
+ entry.device = dev;
+ entry.mount = "swap";
+ entry.fs = "swap";
+ data.insert(make_pair(dev, entry));
}
- for (map::const_iterator it = co.begin(); it != co.end(); ++it)
- y2mil("co:[" << it->first << "]-->" << it->second);
+ for (const_iterator it = data.begin(); it != data.end(); ++it)
+ y2mil("data[" << it->first << "] -> " << it->second);
}
@@ -144,46 +147,73 @@
string
-ProcMounts::getMount( const string& dev ) const
+ProcMounts::getMount(const string& device) const
{
string ret;
- map::const_iterator i = co.find( dev );
- if( i!=co.end() )
+ const_iterator i = data.find(device);
+ if (i != data.end())
ret = i->second.mount;
- return( ret );
+ return ret;
}
string
-ProcMounts::getMount( const list<string>& dl ) const
+ProcMounts::getMount(const list<string>& devices) const
{
string ret;
- list<string>::const_iterator i = dl.begin();
- while( ret.empty() && i!=dl.end() )
+ list<string>::const_iterator i = devices.begin();
+ while (ret.empty() && i != devices.end())
{
ret = getMount( *i );
++i;
}
- return( ret );
+ return ret;
+ }
+
+
+ list<string>
+ ProcMounts::getAllMounts(const string& device) const
+ {
+ list<string> ret;
+
+ pair range = data.equal_range(device);
+ for (const_iterator i = range.first; i != range.second; ++i)
+ ret.push_back(i->second.mount);
+
+ return ret;
+ }
+
+
+ list<string>
+ ProcMounts::getAllMounts(const list<string>& devices) const
+ {
+ list<string> ret;
+
+ for (list<string>::const_iterator i = devices.begin(); i != devices.end(); ++i)
+ ret.splice(ret.end(), getAllMounts(*i));
+
+ return ret;
}
-map
+
+map
ProcMounts::allMounts() const
{
- map ret;
- for( map::const_iterator i = co.begin(); i!=co.end(); ++i )
+ map ret;
+ for (const_iterator i = data.begin(); i != data.end(); ++i)
{
ret[i->second.mount] = i->first;
}
- return( ret );
+ return ret;
}
-void ProcMounts::getEntries( list<FstabEntry>& l ) const
+
+ list<FstabEntry>
+ ProcMounts::getEntries() const
{
- l.clear();
- for( map::const_iterator i = co.begin(); i!=co.end(); ++i )
- {
- l.push_back( i->second );
- }
+ list<FstabEntry> ret;
+ for (const_iterator i = data.begin(); i != data.end(); ++i)
+ ret.push_back(i->second);
+ return ret;
}
}
Modified: trunk/storage/libstorage/src/ProcMounts.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/ProcMounts.h?rev=57162&r1=57161&r2=57162&view=diff
==============================================================================
--- trunk/storage/libstorage/src/ProcMounts.h (original)
+++ trunk/storage/libstorage/src/ProcMounts.h Thu May 14 12:37:41 2009
@@ -9,25 +9,37 @@
namespace storage
{
+ using std::list;
+ using std::map;
+ using std::multimap;
+
class Storage;
class SystemCmd;
class ProcMounts
{
public:
+
ProcMounts( Storage * const s );
- string getMount( const string& Dev ) const;
- string getMount( const std::list<string>& dl ) const;
- std::map allMounts() const;
- void getEntries( std::list<FstabEntry>& l ) const;
- protected:
- std::map co;
+ string getMount(const string& device) const;
+ string getMount(const list<string>& devices) const;
+
+ list<string> getAllMounts(const string& device) const;
+ list<string> getAllMounts(const list<string>& devices) const;
+
+ map allMounts() const;
- private:
+ list<FstabEntry> getEntries() const;
+
+ protected:
bool isBind(SystemCmd& mt, const string& dir) const;
+ typedef multimap::const_iterator const_iterator;
+
+ multimap data;
+
};
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org