diff options
author | Roger Leigh <rleigh@debian.org> | 2012-10-27 22:51:47 +0100 |
---|---|---|
committer | Roger Leigh <rleigh@debian.org> | 2012-10-27 22:55:10 +0100 |
commit | b018d31cfcffa163f23a4336d1a34f9a37372253 (patch) | |
tree | d82563a37cb419e61108b6ffabb62e0057aa1d0d | |
parent | c4328e8b1a92dce11186c98ab328a18d87eb233d (diff) | |
download | schroot-b018d31cfcffa163f23a4336d1a34f9a37372253.tar.gz |
schroot-mount: Cope with recursion into single directories
-rw-r--r-- | bin/schroot-mount/schroot-mount-main.cc | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/bin/schroot-mount/schroot-mount-main.cc b/bin/schroot-mount/schroot-mount-main.cc index 38b98892..84dcfb52 100644 --- a/bin/schroot-mount/schroot-mount-main.cc +++ b/bin/schroot-mount/schroot-mount-main.cc @@ -113,25 +113,22 @@ main::resolve_path (std::string const& mountpoint) link = true; } catch (...) - { - exists = false; - } - - std::cerr << "MOUNTPT= " << directory << "E=" << exists << "L=" << link << std::endl; + {} // Does not exist, not a link - if (exists && link) + if (link) throw error(directory, REALPATH, strerror(ENOTDIR)); else { // Try validating the parent directory. sbuild::string_list dirs = sbuild::split_string(mountpoint, "/"); - if (dirs.size() == 1) // Not possible to recurse. - throw error(directory, REALPATH, strerror(err)); - std::string saveddir = *dirs.rbegin(); - dirs.pop_back(); + if (dirs.size() > 1) // Recurse if possible, otherwise continue + { + std::string saveddir = *dirs.rbegin(); + dirs.pop_back(); - std::string newpath(resolve_path(sbuild::string_list_to_string(dirs, "/"))); - directory = newpath + "/" + saveddir; + std::string newpath(resolve_path(sbuild::string_list_to_string(dirs, "/"))); + directory = newpath + "/" + saveddir; + } } } else |