summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2008-05-04 16:16:39 +0100
committerRoger Leigh <rleigh@debian.org>2008-05-04 16:20:18 +0100
commit4126778ca072ef18c61a7f63b585ded5a8f80ed5 (patch)
tree45f2739b32d4ffa2699b4a46302eed768eb6948d /bin
parent0e42d9f93fb1d72bad3970298c65b9e9f5b4bae9 (diff)
downloadschroot-4126778ca072ef18c61a7f63b585ded5a8f80ed5.tar.gz
[schroot-mount] schroot-mount-main: Create mountpoint if needed.
Thanks to Kees Cook <kees@outflux.net> for this patch.
Diffstat (limited to 'bin')
-rw-r--r--bin/schroot-mount/schroot-mount-main.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/bin/schroot-mount/schroot-mount-main.cc b/bin/schroot-mount/schroot-mount-main.cc
index cc91f7c8..c461ef98 100644
--- a/bin/schroot-mount/schroot-mount-main.cc
+++ b/bin/schroot-mount/schroot-mount-main.cc
@@ -35,6 +35,7 @@
#include <unistd.h>
#include <boost/format.hpp>
+#include <boost/filesystem.hpp>
#include <mntent.h>
@@ -104,6 +105,34 @@ main::action_mount ()
std::string directory(opts->mountpoint + entry.directory);
+ if (!boost::filesystem::is_directory(directory))
+ {
+ sbuild::log_debug(sbuild::DEBUG_INFO)
+ << boost::format("Creating '%1%' in '%2%'")
+ % entry.directory
+ % opts->mountpoint
+ << std::endl;
+
+ if (!opts->dry_run)
+ {
+ try
+ {
+ boost::filesystem::create_directory(directory);
+ }
+ catch (std::exception const& e)
+ {
+ sbuild::log_exception_error(e);
+ exit(EXIT_FAILURE);
+ }
+ catch (...)
+ {
+ sbuild::log_error()
+ << _("An unknown exception occurred") << std::endl;
+ exit(EXIT_FAILURE);
+ }
+ }
+ }
+
sbuild::log_debug(sbuild::DEBUG_INFO)
<< boost::format("Mounting '%1%' on '%2%'")
% entry.filesystem_name