added: new winix function: mount

displaying all mount points
changed: struct Cur has now 'mount' pointer
         we should not use system->mounts.pmount now
         (it will be removed in the future)
changed: all mount point parameters are now propagated to childs mount points
         (if not defined there)



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@745 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2011-06-21 21:24:49 +00:00
parent 700a6fe643
commit 1d6ff73aad
22 changed files with 721 additions and 263 deletions

View File

@@ -360,7 +360,84 @@ void MountParser::ReadMountParams()
void MountParser::ReadRow(std::map<long, Mount> & output)
void MountParser::AddParams(Mount::Param & src, Mount::Param & dst)
{
if( src.size() != dst.size() )
{
log << log1 << "MP: addparams: incorrect sizes" << logend;
return;
}
for(size_t p=0 ; p < src.size() ; ++p)
{
if( src[p].defined && !dst[p].defined )
dst[p] = src[p];
}
}
bool MountParser::AddParamsBefore(long dir_id)
{
std::map<long, Mount>::iterator i = poutput->find(dir_id);
if( i == poutput->end() )
return false;
AddParams(i->second.param, mount_inserted.first->second.param);
return true;
}
/*
adding all non-existing parameters to this mount point from parents
*/
void MountParser::AddParamsBefore()
{
if( !pdir )
return;
Item * dir;
long dir_id = pdir->parent_id;
while( dir_id != -1 )
{
if( AddParamsBefore(dir_id) )
{
// we don't have to check others parents
// the parameters are already copied
break;
}
dir = dirs->GetDir(dir_id);
if( !dir )
break;
dir_id = dir->parent_id;
}
}
/*
adding all non-existing parameters to childs (childs to this mount point)
*/
void MountParser::AddParamsAfter()
{
std::map<long, Mount>::iterator i = poutput->begin();
for( ; i != poutput->end() ; ++i)
{
if( dirs->IsChild(mount_inserted.first->second.dir_id, i->first) )
AddParams(mount_inserted.first->second.param, i->second.param);
}
}
void MountParser::ReadRow()
{
if( ReadMountType() && ReadMountPoint() && ReadFs() )
{
@@ -373,13 +450,19 @@ void MountParser::ReadRow(std::map<long, Mount> & output)
}
else
{
std::pair<std::map<long, Mount>::iterator, bool> res = output.insert( std::make_pair(mount.dir_id, mount) );
if( !res.second )
mount_inserted = poutput->insert( std::make_pair(mount.dir_id, mount) );
if( mount_inserted.second )
{
AddParamsBefore();
AddParamsAfter();
}
else
{
log << log1 << "MP: this mount point exists (skipped)" << logend;
slog << logwarning << T("mount_exists") << ": " << last_dir << " (" << T("skipped") << ")" << logend;
}
}
}
@@ -397,13 +480,14 @@ void MountParser::Parse(const std::wstring & input, std::map<long, Mount> & outp
return;
}
pinput = input.c_str();
pinput = input.c_str();
poutput = &output;
mount.param.resize(mount_par_tab->size());
mount.ClearParams();
output.clear();
poutput->clear();
while( *pinput )
ReadRow(output);
ReadRow();
}