2009-04-20 00:13:21 +02:00
|
|
|
/*
|
|
|
|
* This file is a part of CMSLU -- Content Management System like Unix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "mounts.h"
|
|
|
|
#include "data.h"
|
2009-04-21 22:50:55 +02:00
|
|
|
#include "request.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "mountparser.h"
|
2009-04-20 00:13:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
void Mounts::ReadMounts()
|
|
|
|
{
|
|
|
|
MountParser mp;
|
|
|
|
|
|
|
|
// !! tymczasowo - bedzie odczyt z bazy z /etc/fstab
|
2009-06-08 00:17:07 +02:00
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
std::string temp =
|
|
|
|
"cms / withheader, withinfo \n"
|
2009-06-08 00:17:07 +02:00
|
|
|
"thread /news desc, withheader, thread_with_header, thread_with_info, restrictcreatethread(-1) \n"
|
2009-06-07 04:40:27 +02:00
|
|
|
"thread /forum asc, withheader, withinfo, thread_with_info, restrictcreatethread(3), only_root_can_remove, can_use_emacs_on(4), can_use_mkdir_on(3)";
|
2009-06-08 00:17:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-20 00:13:21 +02:00
|
|
|
|
|
|
|
Error err = mp.Parse(temp, mount_table);
|
|
|
|
|
|
|
|
if( err != Error::ok )
|
|
|
|
{
|
|
|
|
log << log1 << "M: some problems with mountpoints (mountpoints table will be empty)" << logend;
|
|
|
|
mount_table.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
/*
|
2009-04-20 00:13:21 +02:00
|
|
|
Mount Mounts::GetCurrentMountPoint()
|
|
|
|
{
|
|
|
|
return current_dir;
|
|
|
|
}
|
2009-06-05 22:29:06 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
Mount::Type Mounts::CurrentMountType()
|
|
|
|
{
|
|
|
|
return current_dir.type;
|
|
|
|
}
|
2009-04-20 00:13:21 +02:00
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
bool Mounts::CurrentMountIsParam(Mount::Param p)
|
|
|
|
{
|
|
|
|
return current_dir.IsParam(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Mounts::CurrentMountIsParam(Mount::Param p, int * first_arg)
|
|
|
|
{
|
|
|
|
return current_dir.IsParam(p, first_arg);
|
|
|
|
}
|
2009-04-20 00:13:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
void Mounts::MountCmsForRoot()
|
|
|
|
{
|
|
|
|
current_dir.type = Mount::cms;
|
|
|
|
|
|
|
|
Item * proot = data.dirs.GetRootDir();
|
|
|
|
|
|
|
|
if( proot )
|
|
|
|
current_dir.dir_id = proot->id;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
current_dir.dir_id = -1;
|
|
|
|
log << log1 << "M: there is no a root dir" << logend;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Mounts::CalculateCurrentMountType()
|
|
|
|
{
|
|
|
|
std::vector<Item*>::reverse_iterator i;
|
|
|
|
|
|
|
|
|
|
|
|
for(i = request.dir_table.rbegin() ; i!=request.dir_table.rend() ; ++i)
|
|
|
|
{
|
|
|
|
std::map<long, Mount>::iterator m = mount_table.find( (*i)->id );
|
|
|
|
|
|
|
|
if( m != mount_table.end() )
|
|
|
|
{
|
|
|
|
current_dir = m->second;
|
|
|
|
log << log2 << "M: current mount point is: " << current_dir.TypeToStr() << logend;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// we assume that 'cms' mount point is used
|
|
|
|
MountCmsForRoot();
|
|
|
|
log << log2 << "M: current mount point is: cms (default)" << logend;
|
|
|
|
}
|