#include <SystemCmd.h>
Public Types | |
| enum | OutputStream { IDX_STDOUT, IDX_STDERR } |
Public Member Functions | |
| SystemCmd (const char *Command_Cv) | |
| SystemCmd (const string &Command_Cv) | |
| SystemCmd () | |
| virtual | ~SystemCmd () |
| int | execute (const string &Command_Cv) |
| int | executeBackground (const string &Command_Cv) |
| int | executeRestricted (const string &Command_Cv, unsigned long MaxTimeSec, unsigned long MaxLineOut, bool &ExceedTime, bool &ExceedLines) |
| void | setOutputHandler (void(*Handle_f)(void *, string, bool), void *Par_p) |
| void | logOutput () |
| void | setOutputProcessor (OutputProcessor *proc) |
| int | select (string Reg_Cv, bool Invert_bv=false, unsigned Idx_ii=IDX_STDOUT) |
| const string & | stderr () const |
| const string & | stdout () const |
| const string & | cmd () const |
| const string * | getString (unsigned Idx_ii=IDX_STDOUT) const |
| const string * | getLine (unsigned Num_iv, bool Selected_bv=false, unsigned Idx_ii=IDX_STDOUT) const |
| unsigned | numLines (bool Selected_bv=false, unsigned Idx_ii=IDX_STDOUT) const |
| void | setCombine (const bool Combine_b=true) |
| int | retcode () const |
| int | getStdout (std::vector< string > &Ret_Cr, const bool Append_bv=false) const |
| int | getStderr (std::vector< string > &Ret_Cr, const bool Append_bv=false) const |
| int | getStdout (std::list< string > &Ret_Cr, const bool Append_bv=false) const |
| int | getStderr (std::list< string > &Ret_Cr, const bool Append_bv=false) const |
Protected Member Functions | |
| int | placeOutput (unsigned Which_iv, std::vector< string > &Ret_Cr, const bool Append_bv) const |
| int | placeOutput (unsigned Which_iv, std::list< string > &Ret_Cr, const bool Append_bv) const |
| void | invalidate () |
| void | closeOpenFds () |
| int | doExecute (string Cmd_Cv) |
| bool | doWait (bool Hang_bv, int &Ret_ir) |
| void | checkOutput () |
| void | getUntilEOF (FILE *File_Cr, std::vector< string > &Lines_Cr, bool &NewLineSeen_br, bool Stderr_bv) |
| void | extractNewline (const char *Buf_ti, int Cnt_ii, bool &NewLineSeen_br, string &Text_Cr, std::vector< string > &Lines_Cr) |
| void | addLine (string Text_Cv, std::vector< string > &Lines_Cr) |
| void | init () |
Protected Attributes | |
| string | Text_aC [2] |
| bool | Valid_ab [2] |
| FILE * | File_aC [2] |
| std::vector< string > | Lines_aC [2] |
| std::vector< string * > | SelLines_aC [2] |
| bool | NewLineSeen_ab [2] |
| bool | Combine_b |
| bool | Background_b |
| string | lastCmd |
| int | Ret_i |
| int | Pid_i |
| void(* | OutputHandler_f )(void *, string, bool) |
| void * | HandlerPar_p |
| OutputProcessor * | output_proc |
| struct pollfd | pfds [2] |
Static Protected Attributes | |
| static int | Nr_i = 0 |
| SystemCmd::SystemCmd | ( | const char * | Command_Cv | ) |
References execute(), init(), Nr_i, and y2milestone.
| SystemCmd::SystemCmd | ( | const string & | Command_Cv | ) |
References execute(), init(), Nr_i, and y2milestone.
| SystemCmd::SystemCmd | ( | ) |
References init(), Nr_i, and y2milestone.
| SystemCmd::~SystemCmd | ( | ) | [virtual] |
References File_aC, IDX_STDERR, and IDX_STDOUT.
| int SystemCmd::execute | ( | const string & | Command_Cv | ) |
References Background_b, doExecute(), and y2milestone.
Referenced by storage::MdCo::activate(), storage::LvmVg::activate(), storage::DmraidCo::activate(), storage::Dm::activate(), storage::DmPartCo::activate_part(), storage::Storage::checkNfsDevice(), storage::Storage::commitPair(), storage::Volume::detectEncryption(), storage::Storage::detectObjects(), storage::MdCo::doCreate(), storage::Disk::doCreate(), storage::Volume::doCryptsetup(), storage::Volume::doFormat(), storage::Volume::doFstabUpdate(), storage::MdCo::doRemove(), storage::DmraidCo::doRemove(), storage::Storage::evmsActivateDevices(), storage::Disk::execCheckFailed(), storage::Dm::getDevice(), storage::DmPartCo::init(), storage::Volume::mount(), storage::LvmVg::normalizeDmDevices(), storage::Storage::removeDmTable(), storage::Volume::resizeFs(), SystemCmd(), storage::Volume::umount(), storage::AsciiFile::updateFile(), and storage::Storage::~Storage().
| int SystemCmd::executeBackground | ( | const string & | Command_Cv | ) |
References Background_b, doExecute(), and y2milestone.
Referenced by storage::EvmsCo::startHelper().
| int storage::SystemCmd::executeRestricted | ( | const string & | Command_Cv, | |
| unsigned long | MaxTimeSec, | |||
| unsigned long | MaxLineOut, | |||
| bool & | ExceedTime, | |||
| bool & | ExceedLines | |||
| ) |
Referenced by storage::Volume::detectEncryption().
| void SystemCmd::setOutputHandler | ( | void(*)(void *, string, bool) | Handle_f, | |
| void * | Par_p | |||
| ) |
References HandlerPar_p, and OutputHandler_f.
| void SystemCmd::logOutput | ( | ) |
| void storage::SystemCmd::setOutputProcessor | ( | OutputProcessor * | proc | ) | [inline] |
| int SystemCmd::select | ( | string | Reg_Cv, | |
| bool | Invert_bv = false, |
|||
| unsigned | Idx_ii = IDX_STDOUT | |||
| ) |
References Lines_aC, Pid_i, SelLines_aC, y2debug, y2error, and y2milestone.
Referenced by storage::Dasd::checkFdasdOutput(), storage::Volume::getFsData(), storage::Dasd::getGeometry(), storage::Volume::getLoopData(), storage::Md::Md(), and storage::ProcMounts::ProcMounts().
| const string& storage::SystemCmd::stderr | ( | ) | const [inline] |
| const string& storage::SystemCmd::stdout | ( | ) | const [inline] |
References getString(), and IDX_STDOUT.
Referenced by storage::DmPartCo::init(), and storage::Container::setExtError().
| const string& storage::SystemCmd::cmd | ( | ) | const [inline] |
| const string * SystemCmd::getString | ( | unsigned | Idx_ii = IDX_STDOUT |
) | const |
References Lines_aC, Text_aC, Valid_ab, and y2error.
Referenced by storage::Disk::checkSystemError(), storage::Storage::getFreeInfo(), stderr(), and stdout().
| const string * SystemCmd::getLine | ( | unsigned | Num_iv, | |
| bool | Selected_bv = false, |
|||
| unsigned | Idx_ii = IDX_STDOUT | |||
| ) | const |
References Lines_aC, SelLines_aC, and y2error.
Referenced by storage::Dasd::checkFdasdOutput(), storage::Disk::checkPartedOutput(), storage::DmCo::detectEncryption(), storage::Storage::detectMultipath(), storage::Storage::detectObjects(), storage::Dm::dmNumber(), storage::Dm::getDevice(), storage::DmCo::getDmData(), storage::Volume::getFsData(), storage::Dasd::getGeometry(), storage::Volume::getLoopData(), storage::getMajorDevices(), storage::Dm::getTableInfo(), storage::Storage::handleHald(), logOutput(), storage::Md::Md(), storage::LvmVg::normalizeDmDevices(), storage::ProcMounts::ProcMounts(), storage::Storage::removeDmTableTo(), and storage::Storage::testFilesEqual().
| unsigned SystemCmd::numLines | ( | bool | Selected_bv = false, |
|
| unsigned | Idx_ii = IDX_STDOUT | |||
| ) | const |
References Lines_aC, SelLines_aC, y2debug, and y2error.
Referenced by storage::Dm::activate(), storage::Dasd::checkFdasdOutput(), storage::Disk::checkPartedOutput(), storage::DmCo::detectEncryption(), storage::Storage::detectMultipath(), storage::Storage::detectObjects(), storage::Dm::dmNumber(), storage::Dm::getDevice(), storage::DmCo::getDmData(), storage::getMajorDevices(), storage::Dm::getTableInfo(), storage::Storage::handleHald(), storage::DmPartCo::init(), logOutput(), storage::Md::Md(), storage::ProcMounts::ProcMounts(), storage::Storage::removeDmTableTo(), and storage::Storage::testFilesEqual().
| void SystemCmd::setCombine | ( | const bool | Combine_b = true |
) |
| int storage::SystemCmd::retcode | ( | ) | const [inline] |
References Ret_i.
Referenced by storage::Dm::activate(), storage::Disk::checkSystemError(), storage::Loop::createFile(), storage::Volume::cryptUnsetup(), storage::Volume::detectEncryption(), storage::Dm::dmNumber(), storage::MdCo::doCreate(), storage::LvmVg::doCreate(), storage::LvmVg::doCreateVg(), storage::Volume::doCryptsetup(), storage::LvmVg::doExtendVg(), storage::Volume::doFormat(), storage::Volume::doFstabUpdate(), storage::Volume::doLosetup(), storage::LvmVg::doReduceVg(), storage::MdCo::doRemove(), storage::LvmVg::doRemove(), storage::DmraidCo::doRemove(), storage::DmCo::doRemove(), storage::LvmVg::doRemoveVg(), storage::LvmVg::doResize(), storage::Volume::doSetLabel(), storage::Dm::getDevice(), storage::Storage::getFreeInfo(), storage::Dm::getTableInfo(), storage::DmPartCo::init(), storage::Volume::loUnsetup(), storage::Md::Md(), storage::LvmVg::normalizeDmDevices(), storage::Storage::removeDmTable(), storage::Volume::resizeFs(), storage::Storage::testFilesEqual(), and storage::Storage::~Storage().
| int storage::SystemCmd::getStdout | ( | std::vector< string > & | Ret_Cr, | |
| const bool | Append_bv = false | |||
| ) | const [inline] |
References IDX_STDOUT, and placeOutput().
| int storage::SystemCmd::getStderr | ( | std::vector< string > & | Ret_Cr, | |
| const bool | Append_bv = false | |||
| ) | const [inline] |
References IDX_STDERR, and placeOutput().
| int storage::SystemCmd::getStdout | ( | std::list< string > & | Ret_Cr, | |
| const bool | Append_bv = false | |||
| ) | const [inline] |
References IDX_STDOUT, and placeOutput().
| int storage::SystemCmd::getStderr | ( | std::list< string > & | Ret_Cr, | |
| const bool | Append_bv = false | |||
| ) | const [inline] |
References IDX_STDERR, and placeOutput().
| int storage::SystemCmd::placeOutput | ( | unsigned | Which_iv, | |
| std::vector< string > & | Ret_Cr, | |||
| const bool | Append_bv | |||
| ) | const [protected] |
Referenced by getStderr(), and getStdout().
| int storage::SystemCmd::placeOutput | ( | unsigned | Which_iv, | |
| std::list< string > & | Ret_Cr, | |||
| const bool | Append_bv | |||
| ) | const [protected] |
| void SystemCmd::invalidate | ( | ) | [protected] |
| void SystemCmd::closeOpenFds | ( | ) | [protected] |
Referenced by doExecute().
| int SystemCmd::doExecute | ( | string | Cmd_Cv | ) | [protected] |
References ALTERNATE_SHELL, Background_b, checkOutput(), closeOpenFds(), Combine_b, doWait(), File_aC, IDX_STDERR, IDX_STDOUT, invalidate(), lastCmd, logOutput(), output_proc, pfds, Pid_i, storage::OutputProcessor::reset(), Ret_i, storage::system_cmd_testmode, storage::timeMark(), y2debug, y2error, and y2milestone.
Referenced by execute(), and executeBackground().
| bool SystemCmd::doWait | ( | bool | Hang_bv, | |
| int & | Ret_ir | |||
| ) | [protected] |
References checkOutput(), Combine_b, File_aC, storage::OutputProcessor::finished(), IDX_STDERR, IDX_STDOUT, output_proc, pfds, Pid_i, y2debug, and y2error.
Referenced by doExecute().
| void SystemCmd::checkOutput | ( | ) | [protected] |
References File_aC, getUntilEOF(), IDX_STDERR, IDX_STDOUT, Lines_aC, NewLineSeen_ab, and y2debug.
Referenced by doExecute(), and doWait().
| void storage::SystemCmd::getUntilEOF | ( | FILE * | File_Cr, | |
| std::vector< string > & | Lines_Cr, | |||
| bool & | NewLineSeen_br, | |||
| bool | Stderr_bv | |||
| ) | [protected] |
Referenced by checkOutput().
| void storage::SystemCmd::extractNewline | ( | const char * | Buf_ti, | |
| int | Cnt_ii, | |||
| bool & | NewLineSeen_br, | |||
| string & | Text_Cr, | |||
| std::vector< string > & | Lines_Cr | |||
| ) | [protected] |
| void storage::SystemCmd::addLine | ( | string | Text_Cv, | |
| std::vector< string > & | Lines_Cr | |||
| ) | [protected] |
| void SystemCmd::init | ( | ) | [protected] |
References Combine_b, File_aC, HandlerPar_p, output_proc, OutputHandler_f, and pfds.
Referenced by SystemCmd().
string storage::SystemCmd::Text_aC[2] [mutable, protected] |
Referenced by getString().
bool storage::SystemCmd::Valid_ab[2] [mutable, protected] |
Referenced by getString(), and invalidate().
FILE* storage::SystemCmd::File_aC[2] [protected] |
Referenced by checkOutput(), doExecute(), doWait(), init(), and ~SystemCmd().
std::vector<string> storage::SystemCmd::Lines_aC[2] [protected] |
Referenced by checkOutput(), getLine(), getString(), invalidate(), numLines(), and select().
std::vector<string*> storage::SystemCmd::SelLines_aC[2] [protected] |
Referenced by getLine(), invalidate(), numLines(), and select().
bool storage::SystemCmd::NewLineSeen_ab[2] [protected] |
Referenced by checkOutput(), and invalidate().
bool storage::SystemCmd::Combine_b [protected] |
Referenced by doExecute(), doWait(), init(), and setCombine().
bool storage::SystemCmd::Background_b [protected] |
Referenced by doExecute(), execute(), and executeBackground().
string storage::SystemCmd::lastCmd [protected] |
Referenced by cmd(), and doExecute().
int storage::SystemCmd::Ret_i [protected] |
Referenced by doExecute(), and retcode().
int storage::SystemCmd::Pid_i [protected] |
Referenced by doExecute(), doWait(), and select().
void(* storage::SystemCmd::OutputHandler_f)(void *, string, bool) [protected] |
Referenced by init(), and setOutputHandler().
void* storage::SystemCmd::HandlerPar_p [protected] |
Referenced by init(), and setOutputHandler().
OutputProcessor* storage::SystemCmd::output_proc [protected] |
Referenced by doExecute(), doWait(), init(), and setOutputProcessor().
struct pollfd storage::SystemCmd::pfds[2] [read, protected] |
Referenced by doExecute(), doWait(), and init().
int SystemCmd::Nr_i = 0 [static, protected] |
Referenced by SystemCmd().
1.5.5