Confdump Agent  1.4.0
MoreElements.cpp
Go to the documentation of this file.
00001 /* 
00002  * Confdump-Agent - Dump static and runtime system configuration
00003  * Copyright (C) 2009-2012  Straton IT, SAS
00004  * 
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  * 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 extern "C"
00019 {
00020 #include <unistd.h>
00021 }
00022 
00023 #include "QDir"
00024 #include "QVariant"
00025 #include "QFileInfo"
00026 #include "boost/system/system_error.hpp"
00027 #include "boost/foreach.hpp"
00028 #include "Confdump/System/LinuxDumper.hpp"
00029 #include "Confdump/System/Linux/MoreElements.hpp"
00030 
00031 using boost::shared_ptr;
00032 
00033 namespace Confdump
00034 {
00035 
00036 namespace System
00037 {
00038 
00039 namespace Linux
00040 {
00041 
00042 Result allBlockDevices( shared_ptr<LinuxDumper> driver )
00043 {
00044     // FIXME : ignores systemcontext
00045 
00046     QDir blocks( "/sys/block", "", QDir::Name, QDir::Dirs | QDir::NoDotAndDotDot );
00047 
00048     Result result;
00049     BOOST_FOREACH ( QString blockName, blocks.entryList() )
00050     {
00051         QFileInfo blockDir( "/sys/block/" + blockName );
00052         QFileInfo deviceDirLink( blockDir.canonicalFilePath() + "/device" );
00053 
00054         shared_ptr<ManagedElement> block( new ManagedElement() );
00055         block->setProperty( "name", blockName );
00056         block->setProperty( "device", deviceDirLink.symLinkTarget() );
00057         result.push_back( block );
00058     }
00059 
00060     return result;
00061 }
00062 
00063 } // ns Linux
00064 } // ns System
00065 } // ns Confdump
00066 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends