// Spectre Samba Mounter // // Douglas Thrift // // $Id: Unmounter.cpp,v 1.2 2003/07/31 04:14:12 douglas Exp $ #include "Unmounter.h" void Unmounter::unmount() { if (!good) return; samba(); if (debug) { cerr << "mounted = {\n"; for (set::iterator itor = mounted.begin(); itor != mounted.end(); itor++) { cerr << " " << *itor << "\n"; } cerr << "}\n"; } if (debug) cerr << "folders = {\n"; for (map::iterator itor = folders.begin(); itor != folders.end(); itor++) { if (debug) cerr << " " << itor->first << "\n"; unmount(itor->first); } if (debug) cerr << "}\n"; } void Unmounter::unmount(const string& folder) { string path = config.root + "/" + host + "/" + (folder[folder.length() - 1] == '$' ? "." + folder.substr(0, folder.length() - 1) : folder); if (mounted.find(path) == mounted.end()) return; vector args; args.push_back("spectre"); #if defined _Linux_ args.push_back("-l"); #elif defined _FreeBSD_ args.push_back("-f"); #endif args.push_back(path); ipstream umount(config.umount, args, pstreambuf::pstderr); while (umount.good()) { string line; getline(umount, line); if (line != "") cerr << line << "\n"; } umount.close(); }