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"
|
|
|
|
|
|
|
|
|
|
|
|
void Mounts::ReadMounts()
|
|
|
|
{
|
|
|
|
MountParser mp;
|
|
|
|
|
|
|
|
// !! tymczasowo - bedzie odczyt z bazy z /etc/fstab
|
2009-04-21 01:49:28 +02:00
|
|
|
std::string temp = "thread /news desc";
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mount Mounts::GetCurrentMountPoint()
|
|
|
|
{
|
|
|
|
return current_dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|