]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- cleanup 42/head
authorArvin Schnell <aschnell@suse.de>
Wed, 5 Feb 2014 10:43:29 +0000 (11:43 +0100)
committerArvin Schnell <aschnell@suse.de>
Wed, 5 Feb 2014 10:43:29 +0000 (11:43 +0100)
snapper/Lvm.cc
snapper/LvmCache.cc
snapper/SystemCmd.cc
snapper/SystemCmd.h

index 3a0af36dc29d6a7039ffcabd189cc1e244e4126f..05288882ffe4a0ee996991090071f2e6f3c41c7c 100644 (file)
@@ -370,7 +370,7 @@ namespace snapper
     {
        SystemCmd cmd(string(LVMBIN " version"));
 
-       if (cmd.retcode() != 0)
+       if (cmd.retcode() != 0 || cmd.stdout().empty())
        {
            y2war("Couldn't get LVM version info");
        }
@@ -378,7 +378,7 @@ namespace snapper
        {
            Regex rx(".*LVM[[:space:]]+version:[[:space:]]+([0-9]+)\\.([0-9]+)\\.([0-9]+).*$");
 
-           if (!rx.match(cmd.getLine(0)))
+           if (!rx.match(cmd.stdout().front()))
            {
                y2war("LVM version format didn't match");
            }
index 50e1db00403d8abc6b9a71e5f341b3c5da5c6d77..fb9042ae794cda83e5eb5748f1732070541997b4 100644 (file)
@@ -142,15 +142,14 @@ namespace snapper
        boost::unique_lock<boost::shared_mutex> unique_lock(lv_mutex);
 
        SystemCmd cmd(LVSBIN " --noheadings -o lv_attr,segtype " + quote(vg->get_vg_name() + "/" + lv_name));
-
-       if (cmd.retcode() != 0 || cmd.numLines() < 1)
+       if (cmd.retcode() != 0 || cmd.stdout().empty())
        {
            y2err("lvm cache: failed to get info about " << vg->get_vg_name() << "/" << lv_name);
            throw LvmCacheException();
        }
 
        vector<string> args;
-       const string tmp = boost::trim_copy(cmd.getLine(0));
+       const string tmp = boost::trim_copy(cmd.stdout().front());
        boost::split(args, tmp, boost::is_any_of(" \t\n"), boost::token_compress_on);
        if (args.size() < 1)
            throw LvmCacheException();
@@ -282,14 +281,14 @@ namespace snapper
        else
        {
            SystemCmd cmd(LVSBIN " --noheadings -o lv_attr,segtype " + quote(vg_name + "/" + lv_name));
-           if (cmd.retcode() != 0 || cmd.numLines() < 1)
+           if (cmd.retcode() != 0 || cmd.stdout().empty())
            {
                y2err("lvm cache: failed to get info about " << vg_name << "/" << lv_name);
                throw LvmCacheException();
            }
 
            vector<string> args;
-           const string tmp = boost::trim_copy(cmd.getLine(0));
+           const string tmp = boost::trim_copy(cmd.stdout().front());
            boost::split(args, tmp, boost::is_any_of(" \t\n"), boost::token_compress_on);
            if (args.size() < 1)
                throw LvmCacheException();
index 4a5011149a8fad511a569d112c8b7ebaa5664f68..83612bb9e410bc58649ad438806ce594091536b2 100644 (file)
@@ -410,43 +410,6 @@ SystemCmd::getLine( unsigned Nr_iv, bool Sel_bv, OutputStream Idx_iv ) const
     }
 
 
-int
-SystemCmd::select( const string& Pat_Cv, OutputStream Idx_iv )
-    {
-    if( Idx_iv > 1 )
-       {
-       y2err("invalid index " << Idx_iv);
-       }
-    string Search_Ci( Pat_Cv );
-    bool BeginOfLine_bi = Search_Ci.length()>0 && Search_Ci[0]=='^';
-    if( BeginOfLine_bi )
-       {
-       Search_Ci.erase( 0, 1 );
-       }
-    SelLines_aC[Idx_iv].resize(0);
-    int Size_ii = 0;
-    int End_ii = Lines_aC[Idx_iv].size();
-    for( int I_ii=0; I_ii<End_ii; I_ii++ )
-       {
-       string::size_type Pos_ii = Lines_aC[Idx_iv][I_ii].find( Search_Ci );
-       if( Pos_ii>0 && BeginOfLine_bi )
-           {
-           Pos_ii = string::npos;
-           }
-       if (Pos_ii != string::npos)
-           {
-           SelLines_aC[Idx_iv].resize( Size_ii+1 );
-           SelLines_aC[Idx_iv][Size_ii] = &Lines_aC[Idx_iv][I_ii];
-           y2deb("Select Added Line " << Size_ii << " \"" << *SelLines_aC[Idx_iv][Size_ii] << "\"");
-           Size_ii++;
-           }
-       }
-
-    y2mil("Pid:" << Pid_i << " Idx:" << Idx_iv << " Pattern:\"" << Pat_Cv << "\" Lines:" << Size_ii);
-    return Size_ii;
-    }
-
-
 void
 SystemCmd::invalidate()
     {
index 29a48264fd41d395cd391ebdcdb36a81c3cc294d..0b812ff3cac57f405d9f75daa851f953843a513e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) [2004-2012] Novell, Inc.
+ * Copyright (c) [2004-2014] Novell, Inc.
  *
  * All Rights Reserved.
  *
@@ -48,19 +48,24 @@ namespace snapper
 
        virtual ~SystemCmd();
 
+    protected:
+
        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);
 
+    public:
+
        const vector<string>& stdout() const { return Lines_aC[IDX_STDOUT]; }
        const vector<string>& stderr() const { return Lines_aC[IDX_STDERR]; }
 
        string cmd() const { return lastCmd; }
        int retcode() const { return Ret_i; }
 
-       int select(const string& Reg_Cv, OutputStream Idx_ii = IDX_STDOUT);
+    protected:
+
        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;
 
@@ -68,6 +73,8 @@ namespace snapper
 
        static void setTestmode(bool testmode = true);
 
+    public:
+
        /**
         * Quotes and protects a single string for shell execution.
         */