From: Arvin Schnell Date: Wed, 25 Jul 2012 15:07:45 +0000 (+0200) Subject: - calculate mount-options in constructor X-Git-Tag: v0.1.3~134^2~11 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=b9a8f80b587fb02c8b4705ac490e428452a89079;p=thirdparty%2Fsnapper.git - calculate mount-options in constructor --- diff --git a/snapper/Filesystem.cc b/snapper/Filesystem.cc index 2d170de8..80d9dbf9 100644 --- a/snapper/Filesystem.cc +++ b/snapper/Filesystem.cc @@ -41,12 +41,8 @@ namespace snapper bool mount(const string& device, const string& mount_point, const string& mount_type, - const vector& old_options, const vector& new_options) + const vector& options) { - vector options = old_options; - options.erase(remove(options.begin(), options.end(), "rw"), options.end()); - options.insert(options.end(), new_options.begin(), new_options.end()); - string cmd_line = MOUNTBIN " -t " + mount_type + " --read-only"; if (!options.empty()) @@ -220,6 +216,11 @@ namespace snapper } mount_options = mtab_data.options; + mount_options.erase(remove(mount_options.begin(), mount_options.end(), "rw"), + mount_options.end()); + mount_options.push_back("noatime"); + mount_options.push_back("loop"); + mount_options.push_back("noload"); } @@ -346,12 +347,7 @@ namespace snapper throw MountSnapshotFailedException(); } - vector options; - options.push_back("noatime"); - options.push_back("loop"); - options.push_back("noload"); - - if (!mount(snapshotFile(num), snapshotDir(num), "ext4", mount_options, options)) + if (!mount(snapshotFile(num), snapshotDir(num), "ext4", mount_options)) throw MountSnapshotFailedException(); } @@ -418,6 +414,11 @@ namespace snapper throw InvalidConfigException(); mount_options = mtab_data.options; + mount_options.erase(remove(mount_options.begin(), mount_options.end(), "rw"), + mount_options.end()); + mount_options.push_back("noatime"); + if (mount_type == "xfs") + mount_options.push_back("nouuid"); } @@ -516,12 +517,7 @@ namespace snapper if (isSnapshotMounted(num)) return; - vector options; - options.push_back("noatime"); - if (mount_type == "xfs") - options.push_back("nouuid"); - - if (!mount(getDevice(num), snapshotDir(num), mount_type, mount_options, options)) + if (!mount(getDevice(num), snapshotDir(num), mount_type, mount_options)) throw MountSnapshotFailedException(); }