added: mount points are read from db: /etc/fstab
changed: mount points parser allows empty lines (with some white characters) git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@518 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
378cfc0c3d
commit
9129f1b82a
|
@ -16,7 +16,8 @@ content.o: ../core/error.h ../core/db.h ../core/group.h
|
|||
content.o: ../core/dircontainer.h ../core/ugcontainer.h ../core/data.h
|
||||
content.o: ../core/dirs.h ../core/users.h ../core/groups.h
|
||||
content.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
|
||||
content.o: ../core/mount.h ../core/misc.h
|
||||
content.o: ../core/mount.h ../core/misc.h ../core/plugin.h ../core/request.h
|
||||
content.o: ../core/data.h ../core/pluginmsg.h
|
||||
createthread.o: content.h ../core/item.h ../templates/templates.h
|
||||
createthread.o: ../templates/patterncacher.h ../core/thread.h
|
||||
createthread.o: ../core/request.h ../core/requesttypes.h ../core/session.h
|
||||
|
|
|
@ -24,7 +24,7 @@ class Content
|
|||
{
|
||||
Templates templates;
|
||||
|
||||
|
||||
void CheckSpecialFile();
|
||||
|
||||
void PrepareUrl(Item & item);
|
||||
|
||||
|
|
|
@ -16,6 +16,24 @@
|
|||
|
||||
|
||||
|
||||
void Content::CheckSpecialFile()
|
||||
{
|
||||
static std::string fstab = "fstab";
|
||||
|
||||
Item * etc = data.dirs.GetEtcDir();
|
||||
|
||||
if( !etc )
|
||||
return;
|
||||
|
||||
if( request.item.parent_id != etc->id )
|
||||
return;
|
||||
|
||||
if( request.item.url == fstab )
|
||||
{
|
||||
log << log3 << "Content: reloading mount points" << logend;
|
||||
data.mounts.ReadMounts(request.item.content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -118,6 +136,7 @@ bool adding = true;
|
|||
else
|
||||
PostFunEmacsEdit(with_url);
|
||||
|
||||
CheckSpecialFile();
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ mounts.o: mounts.h mount.h data.h dirs.h item.h dircontainer.h users.h user.h
|
|||
mounts.o: ugcontainer.h log.h groups.h group.h functions.h function.h
|
||||
mounts.o: lastcontainer.h request.h requesttypes.h session.h done.h error.h
|
||||
mounts.o: thread.h compress.h acceptencodingparser.h acceptbaseparser.h
|
||||
mounts.o: mountparser.h
|
||||
mounts.o: mountparser.h db.h
|
||||
notify.o: log.h notify.h ../templatesnotify/templatesnotify.h ../core/mount.h
|
||||
notify.o: data.h dirs.h item.h dircontainer.h users.h user.h ugcontainer.h
|
||||
notify.o: groups.h group.h functions.h function.h lastcontainer.h mounts.h
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
DirContainer::DirContainer()
|
||||
{
|
||||
is_root = false;
|
||||
is_etc = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,6 +28,14 @@ return root_iter;
|
|||
}
|
||||
|
||||
|
||||
DirContainer::Iterator DirContainer::GetEtc()
|
||||
{
|
||||
if( !is_etc )
|
||||
return table.end();
|
||||
|
||||
return etc_iter;
|
||||
}
|
||||
|
||||
|
||||
DirContainer::Iterator DirContainer::Begin()
|
||||
{
|
||||
|
@ -51,6 +60,30 @@ bool DirContainer::Empty()
|
|||
}
|
||||
|
||||
|
||||
// looking for '/etc'
|
||||
// 'root' is found beforehand
|
||||
void DirContainer::FindSpecialFolders()
|
||||
{
|
||||
static std::string etc = "etc";
|
||||
|
||||
is_etc = false;
|
||||
|
||||
if( !is_root )
|
||||
return;
|
||||
|
||||
DirContainer::ParentIterator i = FindFirstParent(root_iter->id);
|
||||
|
||||
for( ; i!=ParentEnd() ; i = NextParent(i) )
|
||||
{
|
||||
if( i->second->url == etc )
|
||||
{
|
||||
is_etc = true;
|
||||
etc_iter = i->second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DirContainer::Iterator DirContainer::PushBack(const Item & item)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
DirContainer();
|
||||
|
||||
Iterator GetRoot();
|
||||
Iterator GetEtc();
|
||||
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
|
@ -52,6 +53,7 @@ public:
|
|||
ParentIterator FindFirstParent(long parent);
|
||||
ParentIterator NextParent(ParentIterator pi);
|
||||
|
||||
void FindSpecialFolders();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -64,6 +66,12 @@ private:
|
|||
// root
|
||||
Iterator root_iter;
|
||||
|
||||
// true if there is a etc dir in the table
|
||||
bool is_etc;
|
||||
|
||||
// etc
|
||||
Iterator etc_iter;
|
||||
|
||||
// indexes
|
||||
TableId table_id;
|
||||
TableParent table_parent;
|
||||
|
|
|
@ -56,6 +56,7 @@ void Dirs::ReadDirs()
|
|||
|
||||
db.GetDirs(dir_table);
|
||||
CheckRootDir();
|
||||
dir_table.FindSpecialFolders();
|
||||
}
|
||||
|
||||
|
||||
|
@ -294,6 +295,17 @@ return &(*root);
|
|||
}
|
||||
|
||||
|
||||
Item * Dirs::GetEtcDir()
|
||||
{
|
||||
DirContainer::Iterator etc = dir_table.GetEtc();
|
||||
|
||||
if( etc == dir_table.End() )
|
||||
return 0;
|
||||
|
||||
return &(*etc);
|
||||
}
|
||||
|
||||
|
||||
Item * Dirs::GetDir(const std::string & name, long parent)
|
||||
{
|
||||
DirContainer::ParentIterator i = dir_table.FindFirstParent(parent);
|
||||
|
|
|
@ -62,10 +62,10 @@ public:
|
|||
|
||||
// returns null if there is no a root dir
|
||||
Item * GetRootDir();
|
||||
Item * GetEtcDir();
|
||||
Item * GetDir(const std::string & name, long parent);
|
||||
Item * GetDir(const std::string & path);
|
||||
Item * GetDir(long id);
|
||||
|
||||
Item * AddDir(const Item & item);
|
||||
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
mount_no_param,
|
||||
|
||||
no_thread,
|
||||
|
||||
empty,
|
||||
unknown = 1000
|
||||
|
||||
|
||||
|
|
|
@ -133,6 +133,12 @@ void MountParser::ReadMountType()
|
|||
SkipWhite();
|
||||
ReadWord(temp);
|
||||
|
||||
if( temp.empty() )
|
||||
{
|
||||
// an empty line (some white characters only)
|
||||
err = Error::empty;
|
||||
}
|
||||
else
|
||||
if( temp == "cms" )
|
||||
{
|
||||
mount.type = Mount::cms;
|
||||
|
@ -201,6 +207,13 @@ void MountParser::ReadRow(std::map<long, Mount> & output)
|
|||
{
|
||||
ReadMountType();
|
||||
|
||||
if( err == Error::empty )
|
||||
{
|
||||
err = Error::ok;
|
||||
SkipLine();
|
||||
return;
|
||||
}
|
||||
|
||||
if( err == Error::ok )
|
||||
ReadMountPoint();
|
||||
|
||||
|
@ -208,10 +221,7 @@ void MountParser::ReadRow(std::map<long, Mount> & output)
|
|||
ReadMountParams();
|
||||
|
||||
if( err == Error::ok )
|
||||
{
|
||||
output.insert( std::make_pair(mount.dir_id, mount) );
|
||||
}
|
||||
|
||||
|
||||
SkipLine();
|
||||
}
|
||||
|
|
|
@ -12,23 +12,15 @@
|
|||
#include "request.h"
|
||||
#include "log.h"
|
||||
#include "mountparser.h"
|
||||
#include "db.h"
|
||||
|
||||
|
||||
void Mounts::ReadMounts()
|
||||
|
||||
// reading from 'mounts'
|
||||
void Mounts::ReadMounts(const std::string & mounts)
|
||||
{
|
||||
MountParser mp;
|
||||
|
||||
// !! tymczasowo - bedzie odczyt z bazy z /etc/fstab
|
||||
|
||||
std::string temp =
|
||||
"cms / withheader, withinfo \n"
|
||||
"thread /news desc, withheader, thread_with_header, thread_with_info, restrictcreatethread(-1) \n"
|
||||
"thread /forum asc, withheader, withinfo, thread_with_info, restrictcreatethread(3), only_root_can_remove, can_use_emacs_on(4), can_use_mkdir_on(3)";
|
||||
|
||||
|
||||
|
||||
|
||||
Error err = mp.Parse(temp, mount_table);
|
||||
Error err = mp.Parse(mounts, mount_table);
|
||||
|
||||
if( err != Error::ok )
|
||||
{
|
||||
|
@ -39,6 +31,39 @@ void Mounts::ReadMounts()
|
|||
|
||||
|
||||
|
||||
// reading from /etc/fstab
|
||||
void Mounts::ReadMounts()
|
||||
{
|
||||
static std::string file = "fstab";
|
||||
|
||||
Item * etc = data.dirs.GetEtcDir();
|
||||
|
||||
if( !etc )
|
||||
{
|
||||
log << log1 << "M: there is no /etc directory" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
Item fstab;
|
||||
Error err = db.GetItem(etc->id, file, fstab);
|
||||
|
||||
if( err == Error::db_no_item )
|
||||
{
|
||||
log << log1 << "M: there is no /etc/fstab file" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
if( err != Error::ok )
|
||||
{
|
||||
log << log1 << "M: cannot read /etc/fstab" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
ReadMounts(fstab.content);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "mount.h"
|
||||
|
||||
|
||||
|
@ -21,6 +22,7 @@ class Mounts
|
|||
{
|
||||
public:
|
||||
|
||||
void ReadMounts(const std::string & mounts);
|
||||
void ReadMounts();
|
||||
|
||||
void CalculateCurrentMountType();
|
||||
|
|
|
@ -105,7 +105,7 @@ int attempts = 100;
|
|||
void SessionManager::SetSession()
|
||||
{
|
||||
CookieTable::iterator i = request.cookie_table.find(data.http_session_id_name);
|
||||
|
||||
|
||||
if( i == request.cookie_table.end() )
|
||||
{
|
||||
CreateSession();
|
||||
|
|
Loading…
Reference in New Issue