ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/Spectre/trunk/Unmounter.cpp
Revision: 228
Committed: 2003-07-30T21:14:12-07:00 (21 years, 10 months ago) by douglas
Original Path: trunk/Spectre/Unmounter.cpp
File size: 1242 byte(s)
Log Message:
Made Unmounter and made autounmount work. I like cheese.

File Contents

# User Rev Content
1 douglas 227 // Spectre Samba Mounter
2     //
3     // Douglas Thrift
4     //
5 douglas 228 // $Id: Unmounter.cpp,v 1.2 2003/07/31 04:14:12 douglas Exp $
6 douglas 227
7     #include "Unmounter.h"
8    
9     void Unmounter::unmount()
10     {
11 douglas 228 if (!good) return;
12 douglas 227
13 douglas 228 samba();
14    
15     if (debug)
16     {
17     cerr << "mounted = {\n";
18    
19     for (set<string>::iterator itor = mounted.begin(); itor !=
20     mounted.end(); itor++)
21     {
22     cerr << " " << *itor << "\n";
23     }
24    
25     cerr << "}\n";
26     }
27    
28     if (debug) cerr << "folders = {\n";
29    
30     for (map<string, Folder>::iterator itor = folders.begin(); itor !=
31     folders.end(); itor++)
32     {
33     if (debug) cerr << " " << itor->first << "\n";
34    
35     unmount(itor->first);
36     }
37    
38     if (debug) cerr << "}\n";
39 douglas 227 }
40    
41 douglas 228 void Unmounter::unmount(const string& folder)
42 douglas 227 {
43 douglas 228 string path = config.root + "/" + host + "/" + (folder[folder.length() - 1]
44     == '$' ? "." + folder.substr(0, folder.length() - 1) : folder);
45 douglas 227
46 douglas 228 if (mounted.find(path) == mounted.end()) return;
47    
48     vector<string> args;
49    
50     args.push_back("spectre");
51     #if defined _Linux_
52     args.push_back("-l");
53     #elif defined _FreeBSD_
54     args.push_back("-f");
55     #endif
56     args.push_back(path);
57    
58     ipstream umount(config.umount, args, pstreambuf::pstderr);
59    
60     while (umount.good())
61     {
62     string line;
63    
64     getline(umount, line);
65    
66     if (line != "") cerr << line << "\n";
67     }
68    
69     umount.close();
70 douglas 227 }