changed: mount points

mount type and mount fs are of type 'int' now
they can be added by plugins


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@652 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-09-12 23:33:27 +00:00
parent f48f08a98b
commit 23aedd68b0
36 changed files with 979 additions and 730 deletions

View File

@@ -12,12 +12,40 @@
#include "misc.h"
MountParser::MountParser()
{
dirs = 0;
mount_type_tab = 0;
mount_fs_tab = 0;
mount_par_tab = 0;
}
void MountParser::SetDirs(Dirs * pdirs)
{
dirs = pdirs;
}
void MountParser::SetMountTypeTab(const std::vector<std::string> & tab)
{
mount_type_tab = &tab;
}
void MountParser::SetMountFsTab(const std::vector<std::string> & tab)
{
mount_fs_tab = &tab;
}
void MountParser::SetMountParTab(const std::vector<std::string> & tab)
{
mount_par_tab = &tab;
}
bool MountParser::IsWhite(int c)
{
if( c==' ' || c=='\t' || c==13 || c==160 )
@@ -122,7 +150,7 @@ void MountParser::ReadWord(std::string & res, bool comma_bracket_separator)
void MountParser::ReadParamArgsLoop(Mount::ParamArg & args)
void MountParser::ReadParamArgsLoop(Mount::ParamRow::ParamArg & args)
{
SkipWhite();
@@ -139,7 +167,7 @@ void MountParser::ReadParamArgsLoop(Mount::ParamArg & args)
}
void MountParser::ReadParamArgs(Mount::ParamArg & args)
void MountParser::ReadParamArgs(Mount::ParamRow::ParamArg & args)
{
SkipWhite();
args.clear();
@@ -177,7 +205,7 @@ void MountParser::ReadParamName(std::string & res)
}
void MountParser::ReadParam(std::string & res, Mount::ParamArg & args)
void MountParser::ReadParam(std::string & res, Mount::ParamRow::ParamArg & args)
{
ReadParamName(res);
@@ -193,6 +221,17 @@ void MountParser::ReadParam(std::string & res, Mount::ParamArg & args)
}
int MountParser::FindIndex(const std::vector<std::string> * tab, const std::string & value)
{
for(size_t i=0 ; i < tab->size() ; ++i)
{
if( (*tab)[i] == value )
return static_cast<int>(i);
}
return -1;
}
void MountParser::ReadMountType()
{
@@ -202,24 +241,14 @@ void MountParser::ReadMountType()
{
// an empty line (some white characters only)
err = WINIX_ERR_EMPTY;
return;
}
else
if( temp == "cms" )
mount.type = FindIndex(mount_type_tab, temp);
if( mount.type != -1 )
{
mount.type = Mount::cms;
log << log3 << "MP: mount type: cms" << logend;
}
else
if( temp == "thread" )
{
mount.type = Mount::thread;
log << log3 << "MP: mount type: thread" << logend;
}
else
if( temp == "ticket" )
{
mount.type = Mount::ticket;
log << log3 << "MP: mount type: ticket" << logend;
log << log3 << "MP: mount type: " << (*mount_type_tab)[mount.type] << logend;
}
else
{
@@ -239,12 +268,12 @@ void MountParser::ReadMountPoint()
if( pdir )
{
mount.dir_id = pdir->id;
log << log3 << "MP: mount point: " << temp << logend;
log << log3 << "MP: mount point (directory): " << temp << logend;
}
else
{
err = WINIX_ERR_NO_MOUNTPOINT;
log << log1 << "MP: there is no such a mount point: " << temp << logend;
log << log1 << "MP: there is no such a mount point (directory): " << temp << logend;
}
}
@@ -253,17 +282,11 @@ void MountParser::ReadMountPoint()
void MountParser::ReadFs()
{
ReadWord(temp);
mount.fs = FindIndex(mount_fs_tab, temp);
if( temp == "simplefs" )
if( mount.fs != -1 )
{
mount.fs = Mount::simplefs;
log << log1 << "MP: file system: simplefs" << logend;
}
else
if( temp == "hashfs" )
{
mount.fs = Mount::hashfs;
log << log1 << "MP: file system: hashfs" << logend;
log << log1 << "MP: file system: " << (*mount_fs_tab)[mount.fs] << logend;
}
else
{
@@ -299,12 +322,12 @@ void MountParser::ReadMountParams()
for( ReadParam(temp, param_args) ; !temp.empty() ; ReadParam(temp, param_args) )
{
Mount::ParamCode p = Mount::ParseParam(temp.c_str());
int code = FindIndex(mount_par_tab, temp);
if( p != Mount::par_none )
if( code != -1 )
{
mount.param[p].defined = true;
mount.param[p].arg = param_args;
mount.param[code].defined = true;
mount.param[code].arg = param_args;
LogMountParams();
}
else
@@ -352,8 +375,23 @@ void MountParser::ReadRow(std::map<long, Mount> & output)
Error MountParser::Parse(const std::string & input, std::map<long, Mount> & output)
{
if( !dirs || !mount_type_tab || !mount_fs_tab || !mount_par_tab )
{
log << log1 << "pdir: " << pdir << logend;
log << log1 << "type: " << mount_type_tab << logend;
log << log1 << "fs: " << mount_fs_tab << logend;
log << log1 << "par: " << mount_par_tab << logend;
log << log1 << "MP: input tables not set" << logend;
return WINIX_NOTHING_TO_DO; // !! may a better code?
}
pinput = input.c_str();
err = WINIX_ERR_OK;
mount.param.resize(mount_par_tab->size());
mount.ClearParams();
output.clear();
while( *pinput && err == WINIX_ERR_OK )