2 |
|
// |
3 |
|
// Douglas Thrift |
4 |
|
// |
5 |
< |
// $Id: Unmounter.cpp,v 1.1 2003/07/31 00:56:29 douglas Exp $ |
5 |
> |
// $Id: Unmounter.cpp,v 1.2 2003/07/31 04:14:12 douglas Exp $ |
6 |
|
|
7 |
|
#include "Unmounter.h" |
8 |
|
|
9 |
|
void Unmounter::unmount() |
10 |
|
{ |
11 |
< |
// |
12 |
< |
} |
11 |
> |
if (!good) return; |
12 |
|
|
13 |
< |
void Unmounter::samba() |
15 |
< |
{ |
16 |
< |
// |
17 |
< |
} |
13 |
> |
samba(); |
14 |
|
|
15 |
< |
void Unmounter::samba(ipstream& pin) |
16 |
< |
{ |
17 |
< |
// |
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 |
|
} |
40 |
|
|
41 |
< |
void Unmounter::unmount(const string& unmount) |
41 |
> |
void Unmounter::unmount(const string& folder) |
42 |
|
{ |
43 |
< |
// |
43 |
> |
string path = config.root + "/" + host + "/" + (folder[folder.length() - 1] |
44 |
> |
== '$' ? "." + folder.substr(0, folder.length() - 1) : folder); |
45 |
> |
|
46 |
> |
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 |
|
} |