]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- check for some utils
authorArvin Schnell <aschnell@suse.de>
Tue, 20 Sep 2011 12:39:04 +0000 (14:39 +0200)
committerArvin Schnell <aschnell@suse.de>
Tue, 20 Sep 2011 12:39:04 +0000 (14:39 +0200)
snapper/Exception.h
snapper/Filesystem.cc
snapper/Filesystem.h
snapper/Snapper.cc

index 14eb95c0ac61b71c133a42896ef5efed4e520b2a..b885db76ba26828dfaf1258359497fd42ac4416e 100644 (file)
@@ -62,6 +62,13 @@ namespace snapper
        virtual const char* what() const throw() { return "IO error"; }
     };
 
+    struct ProgramNotInstalledException : public SnapperException
+    {
+       explicit ProgramNotInstalledException(const char* msg) throw() : msg(msg) {}
+       virtual const char* what() const throw() { return msg; }
+       const char* msg;
+    };
+
 }
 
 
index 82376d76b5f90b6d28a4ee470b86c9d1f41d549e..8f5aef460ef18e43ede8ba6ce4403ac1fd629ad2 100644 (file)
@@ -49,6 +49,16 @@ namespace snapper
     }
 
 
+    Btrfs::Btrfs(const string& subvolume)
+       : Filesystem(subvolume)
+    {
+       if (access(BTRFSBIN, X_OK) != 0)
+       {
+           throw ProgramNotInstalledException(BTRFSBIN " not installed");
+       }
+    }
+
+
     void
     Btrfs::addConfig() const
     {
@@ -118,6 +128,21 @@ namespace snapper
     }
 
 
+    Ext4::Ext4(const string& subvolume)
+       : Filesystem(subvolume)
+    {
+       if (access(CHSNAPBIN, X_OK) != 0)
+       {
+           throw ProgramNotInstalledException(CHSNAPBIN " not installed");
+       }
+
+       if (access(CHATTRBIN, X_OK) != 0)
+       {
+           throw ProgramNotInstalledException(CHATTRBIN " not installed");
+       }
+    }
+
+
     void
     Ext4::addConfig() const
     {
index 11c35c8ab086d004983721e7e8df5274d61df7af..7eb3ecd30b81f2f1f3ba860234e584d7808b1405 100644 (file)
@@ -71,7 +71,7 @@ namespace snapper
     {
     public:
 
-       Btrfs(const string& subvolume) : Filesystem(subvolume) {}
+       Btrfs(const string& subvolume);
 
        virtual string name() const { return "btrfs"; }
 
@@ -96,7 +96,7 @@ namespace snapper
     {
     public:
 
-       Ext4(const string& subvolume) : Filesystem(subvolume) {}
+       Ext4(const string& subvolume);
 
        virtual string name() const { return "ext4"; }
 
index c593eed03abd69b909b0e79d0b679f5c2ae16366..8dcd9626b04f062ba268835488ea19cad5074a26 100644 (file)
@@ -586,6 +586,10 @@ namespace snapper
        {
            throw AddConfigFailedException("invalid filesystem type");
        }
+       catch (const ProgramNotInstalledException& e)
+       {
+           throw AddConfigFailedException(e.what());
+       }
 
        try
        {