00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021
00022 #include "sbuild-chroot-directory.h"
00023 #include "sbuild-format-detail.h"
00024 #include "sbuild-lock.h"
00025
00026 #include <cerrno>
00027
00028 #include <sys/types.h>
00029 #include <sys/stat.h>
00030 #include <sys/sysmacros.h>
00031 #include <unistd.h>
00032
00033 using namespace sbuild;
00034
00035 chroot_directory::chroot_directory ():
00036 chroot()
00037 {
00038 }
00039
00040 chroot_directory::~chroot_directory ()
00041 {
00042 }
00043
00044 sbuild::chroot::ptr
00045 chroot_directory::clone () const
00046 {
00047 return ptr(new chroot_directory(*this));
00048 }
00049
00050 std::string const&
00051 chroot_directory::get_location () const
00052 {
00053 return chroot::get_location();
00054 }
00055
00056 void
00057 chroot_directory::set_location (std::string const& location)
00058 {
00059 if (!is_absname(location))
00060 throw error(location, LOCATION_ABS);
00061
00062 chroot::set_location(location);
00063 }
00064
00065 std::string
00066 chroot_directory::get_path () const
00067 {
00068
00069
00070 if (get_run_setup_scripts() == true)
00071 return get_mount_location();
00072 else
00073 return get_location();
00074 }
00075
00076 std::string const&
00077 chroot_directory::get_chroot_type () const
00078 {
00079 static const std::string type("directory");
00080
00081 return type;
00082 }
00083
00084 void
00085 chroot_directory::setup_lock (chroot::setup_type type,
00086 bool lock,
00087 int status)
00088 {
00089
00090
00091 if (get_run_setup_scripts() == true)
00092 {
00093 if ((type == SETUP_START && lock == true) ||
00094 (type == SETUP_STOP && lock == false && status == 0))
00095 {
00096 bool start = (type == SETUP_START);
00097 setup_session_info(start);
00098 }
00099 }
00100 }
00101
00102 sbuild::chroot::session_flags
00103 chroot_directory::get_session_flags () const
00104 {
00105 if (get_run_setup_scripts() == true)
00106 return SESSION_CREATE;
00107 else
00108 return static_cast<session_flags>(0);
00109 }
00110
00111 void
00112 chroot_directory::get_details (format_detail& detail) const
00113 {
00114 chroot::get_details(detail);
00115 }
00116
00117 void
00118 chroot_directory::get_keyfile (keyfile& keyfile) const
00119 {
00120 chroot::get_keyfile(keyfile);
00121
00122 keyfile::set_object_value(*this, &chroot_directory::get_location,
00123 keyfile, get_name(), "location");
00124 }
00125
00126 void
00127 chroot_directory::set_keyfile (keyfile const& keyfile)
00128 {
00129 chroot::set_keyfile(keyfile);
00130
00131 keyfile::get_object_value(*this, &chroot_directory::set_location,
00132 keyfile, get_name(), "location",
00133 keyfile::PRIORITY_REQUIRED);
00134 }