#include <SystemCmd.h>
Public Types | |
| enum | OutputStream { IDX_STDOUT, IDX_STDERR } |
Public Member Functions | |
| 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 | setOutputProcessor (OutputProcessor *proc) |
| const vector< string > & | stdout () const |
| const vector< string > & | stderr () const |
| string | cmd () const |
| int | retcode () const |
| int | select (const string &Reg_Cv, OutputStream Idx_ii=IDX_STDOUT) |
| unsigned | numLines (bool Selected_bv=false, OutputStream Idx_ii=IDX_STDOUT) const |
| string | getLine (unsigned Num_iv, bool Selected_bv=false, OutputStream Idx_ii=IDX_STDOUT) const |
| void | setCombine (bool combine=true) |
Static Public Member Functions | |
| static void | setTestmode (bool testmode=true) |
| static string | quote (const string &str) |
| static string | quote (const std::list< string > &strs) |
Protected Member Functions | |
| void | invalidate () |
| void | closeOpenFds () const |
| int | doExecute (const 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 string &Buf_ti, int Cnt_ii, bool &NewLineSeen_br, string &Text_Cr, std::vector< string > &Lines_Cr) |
| void | addLine (const string &Text_Cv, std::vector< string > &Lines_Cr) |
| void | init () |
| void | logOutput () const |
Protected Attributes | |
| 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 |
| OutputProcessor * | output_proc |
| struct pollfd | pfds [2] |
Static Protected Attributes | |
| static bool | testmode = false |
| static const unsigned | line_limit = 50 |
| storage::SystemCmd::SystemCmd | ( | const string & | Command_Cv | ) |
| storage::SystemCmd::~SystemCmd | ( | ) | [virtual] |
References File_aC, IDX_STDERR, and IDX_STDOUT.
| int storage::SystemCmd::execute | ( | const string & | Command_Cv | ) |
References Background_b, doExecute(), and y2mil.
Referenced by storage::MdCo::activate(), storage::LvmVg::activate(), storage::DmraidCo::activate(), storage::DmmultipathCo::activate(), storage::Dm::activate(), storage::Storage::checkNfsDevice(), storage::Storage::commitPair(), storage::Volume::detectEncryption(), storage::Storage::detectObjects(), storage::LvmVg::doCreatePv(), storage::Btrfs::doCreateSubvol(), storage::Volume::doCryptsetup(), storage::Btrfs::doDeleteSubvol(), storage::Btrfs::doExtend(), storage::Volume::doFormat(), storage::Volume::doFormatBtrfs(), storage::Volume::doFstabUpdate(), storage::Btrfs::doReduce(), storage::MdPartCo::doRemove(), storage::MdCo::doRemove(), storage::DmraidCo::doRemove(), storage::Disk::execCheckFailed(), storage::Volume::mount(), storage::Storage::removeDmTable(), storage::Volume::resizeFs(), SystemCmd(), storage::Volume::umount(), and storage::Storage::zeroDevice().
| int storage::SystemCmd::executeBackground | ( | const string & | Command_Cv | ) |
References Background_b, doExecute(), and y2mil.
| int storage::SystemCmd::executeRestricted | ( | const string & | Command_Cv, | |
| unsigned long | MaxTimeSec, | |||
| unsigned long | MaxLineOut, | |||
| bool & | ExceedTime, | |||
| bool & | ExceedLines | |||
| ) |
Referenced by storage::Volume::detectEncryption().
| void storage::SystemCmd::setOutputProcessor | ( | OutputProcessor * | proc | ) | [inline] |
| const vector<string>& storage::SystemCmd::stdout | ( | ) | const [inline] |
References IDX_STDOUT, and Lines_aC.
Referenced by storage::Blkid::Blkid(), storage::Disk::checkSystemError(), storage::CmdBtrfsShow::CmdBtrfsShow(), storage::CmdDmraid::CmdDmraid(), storage::CmdDmsetup::CmdDmsetup(), storage::CmdMultipath::CmdMultipath(), storage::FreeInfo::detectResizeInfo(), storage::BtrfsCo::getBtrfsData(), storage::getMdadmDetails(), storage::LvmVg::getVgs(), storage::Lsscsi::Lsscsi(), storage::Parted::Parted(), and storage::Container::setExtError().
| const vector<string>& storage::SystemCmd::stderr | ( | ) | const [inline] |
References IDX_STDERR, and Lines_aC.
Referenced by storage::Disk::checkSystemError(), and storage::Container::setExtError().
| string storage::SystemCmd::cmd | ( | ) | const [inline] |
| int storage::SystemCmd::retcode | ( | ) | const [inline] |
References Ret_i.
Referenced by storage::Dm::activate(), storage::Blkid::Blkid(), storage::Disk::callAddpart(), storage::Disk::callDelpart(), storage::Disk::checkSystemError(), storage::CmdBtrfsShow::CmdBtrfsShow(), storage::CmdDmraid::CmdDmraid(), storage::CmdDmsetup::CmdDmsetup(), storage::CmdMultipath::CmdMultipath(), storage::Loop::createFile(), storage::Volume::cryptUnsetup(), storage::Dasdview::Dasdview(), storage::Volume::detectEncryption(), storage::FreeInfo::detectResizeInfo(), storage::MdCo::doCreate(), storage::LvmVg::doCreate(), storage::LvmVg::doCreatePv(), storage::Btrfs::doCreateSubvol(), storage::LvmVg::doCreateVg(), storage::Volume::doCryptsetup(), storage::Btrfs::doDeleteSubvol(), storage::Btrfs::doExtend(), storage::Volume::doFormat(), storage::Volume::doFormatBtrfs(), storage::Volume::doFstabUpdate(), storage::Volume::doLosetup(), storage::Btrfs::doReduce(), storage::MdPartCo::doRemove(), storage::DmraidCo::doRemove(), storage::LvmVg::doRemoveVg(), storage::Volume::doSetLabel(), storage::Fdasd::Fdasd(), storage::getMdadmDetails(), storage::LvmLv::getState(), storage::Dm::getTableInfo(), storage::LvmVg::getVgs(), storage::Volume::loUnsetup(), storage::Lsscsi::Lsscsi(), storage::Storage::removeDmTable(), storage::Volume::resizeFs(), storage::MdPartCo::scanForRaid(), and storage::Storage::waitForDevice().
| int storage::SystemCmd::select | ( | const string & | Reg_Cv, | |
| OutputStream | Idx_ii = IDX_STDOUT | |||
| ) |
References Lines_aC, Pid_i, SelLines_aC, y2deb, y2err, and y2mil.
Referenced by storage::Dasdview::Dasdview(), storage::Volume::doFormatBtrfs(), storage::Fdasd::Fdasd(), storage::Volume::getFreeLoop(), storage::Volume::getLoopData(), storage::ProcMounts::isBind(), storage::isImsmPlatform(), storage::Parted::Parted(), storage::Fdasd::scanGeometry(), and storage::Dasdview::scanGeometry().
| unsigned storage::SystemCmd::numLines | ( | bool | Selected_bv = false, |
|
| OutputStream | Idx_ii = IDX_STDOUT | |||
| ) | const |
References Lines_aC, SelLines_aC, y2deb, and y2err.
Referenced by storage::Dm::activate(), storage::CmdBtrfsShow::CmdBtrfsShow(), storage::CmdDmsetup::CmdDmsetup(), storage::CmdMultipath::CmdMultipath(), storage::DmCo::detectEncryption(), storage::Storage::detectObjects(), storage::Fdasd::Fdasd(), storage::LvmLv::getState(), storage::Dm::getTableInfo(), storage::LvmVg::getVgData(), storage::Storage::handleHald(), storage::ProcMounts::isBind(), storage::isImsmPlatform(), logOutput(), storage::Storage::removeDmTableTo(), and storage::MdPartCo::scanForRaid().
| string storage::SystemCmd::getLine | ( | unsigned | Num_iv, | |
| bool | Selected_bv = false, |
|||
| OutputStream | Idx_ii = IDX_STDOUT | |||
| ) | const |
References Lines_aC, SelLines_aC, and y2err.
Referenced by storage::Dm::activate(), storage::Dasdview::Dasdview(), storage::DmCo::detectEncryption(), storage::Storage::detectObjects(), storage::Volume::doFormatBtrfs(), storage::Fdasd::Fdasd(), storage::Volume::getLoopData(), storage::LvmLv::getState(), storage::Dm::getTableInfo(), storage::LvmVg::getVgData(), storage::Storage::handleHald(), storage::ProcMounts::isBind(), storage::isImsmPlatform(), logOutput(), storage::Parted::Parted(), storage::Storage::removeDmTableTo(), storage::MdPartCo::scanForRaid(), storage::Fdasd::scanGeometry(), and storage::Dasdview::scanGeometry().
| void storage::SystemCmd::setCombine | ( | bool | combine = true |
) |
| void storage::SystemCmd::setTestmode | ( | bool | testmode = true |
) | [static] |
| string storage::SystemCmd::quote | ( | const string & | str | ) | [static] |
Quotes and protects a single string for shell execution.
Referenced by quote().
| string storage::SystemCmd::quote | ( | const std::list< string > & | strs | ) | [static] |
Quotes and protects every single string in the list for shell execution.
References quote().
| void storage::SystemCmd::invalidate | ( | ) | [protected] |
| void storage::SystemCmd::closeOpenFds | ( | ) | const [protected] |
Referenced by doExecute().
| int storage::SystemCmd::doExecute | ( | const string & | Cmd_Cv | ) | [protected] |
References ALTERNATE_SHELL, Background_b, checkOutput(), closeOpenFds(), cmd(), Combine_b, doWait(), File_aC, IDX_STDERR, IDX_STDOUT, invalidate(), lastCmd, logOutput(), output_proc, pfds, Pid_i, PRIMARY_SHELL, storage::OutputProcessor::reset(), Ret_i, testmode, y2deb, y2err, and y2mil.
Referenced by execute(), and executeBackground().
| bool storage::SystemCmd::doWait | ( | bool | Hang_bv, | |
| int & | Ret_ir | |||
| ) | [protected] |
References checkOutput(), Combine_b, File_aC, storage::OutputProcessor::finish(), IDX_STDERR, IDX_STDOUT, lastCmd, output_proc, pfds, Pid_i, y2deb, and y2err.
Referenced by doExecute().
| void storage::SystemCmd::checkOutput | ( | ) | [protected] |
References File_aC, getUntilEOF(), IDX_STDERR, IDX_STDOUT, Lines_aC, NewLineSeen_ab, and y2deb.
Referenced by doExecute(), and doWait().
| void storage::SystemCmd::getUntilEOF | ( | FILE * | File_Cr, | |
| std::vector< string > & | Lines_Cr, | |||
| bool & | NewLineSeen_br, | |||
| bool | Stderr_bv | |||
| ) | [protected] |
References addLine(), BUF_LEN, extractNewline(), output_proc, Pid_i, storage::OutputProcessor::process(), y2deb, and y2mil.
Referenced by checkOutput().
| void storage::SystemCmd::extractNewline | ( | const string & | Buf_ti, | |
| int | Cnt_ii, | |||
| bool & | NewLineSeen_br, | |||
| string & | Text_Cr, | |||
| std::vector< string > & | Lines_Cr | |||
| ) | [protected] |
| void storage::SystemCmd::addLine | ( | const string & | Text_Cv, | |
| std::vector< string > & | Lines_Cr | |||
| ) | [protected] |
| void storage::SystemCmd::init | ( | ) | [protected] |
| void storage::SystemCmd::logOutput | ( | ) | const [protected] |
References getLine(), IDX_STDERR, IDX_STDOUT, line_limit, numLines(), and y2mil.
Referenced by doExecute().
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(), invalidate(), numLines(), select(), stderr(), and stdout().
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(), and setCombine().
bool storage::SystemCmd::Background_b [protected] |
Referenced by doExecute(), execute(), and executeBackground().
string storage::SystemCmd::lastCmd [protected] |
Referenced by cmd(), doExecute(), and doWait().
int storage::SystemCmd::Ret_i [protected] |
Referenced by doExecute(), and retcode().
int storage::SystemCmd::Pid_i [protected] |
Referenced by doExecute(), doWait(), getUntilEOF(), and select().
OutputProcessor* storage::SystemCmd::output_proc [protected] |
Referenced by doExecute(), doWait(), getUntilEOF(), and setOutputProcessor().
struct pollfd storage::SystemCmd::pfds[2] [read, protected] |
Referenced by doExecute(), doWait(), and init().
bool storage::SystemCmd::testmode = false [static, protected] |
Referenced by doExecute(), and setTestmode().
const unsigned storage::SystemCmd::line_limit = 50 [static, protected] |
Referenced by addLine(), and logOutput().
1.5.6