ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Spectre2/Mounter.cpp
(Generate patch)

Comparing Spectre2/Mounter.cpp (file contents):
Revision 428 by douglas, 2005-03-24T17:38:00-08:00 vs.
Revision 429 by douglas, 2005-03-25T18:47:25-08:00

# Line 6 | Line 6
6  
7   #include "Mounter.hpp"
8  
9 < #include <menes-api/environment.hpp>
10 < #include <menes-api/socket.hpp>
11 <
12 < #include <arpa/inet.h>
13 <
14 < Mounter::Mounter(const api::Path& config) : Daemon(), config(config) {}
15 <
16 < Mounter::~Mounter()
17 < {
18 < #ifdef __FreeBSD__
19 <        api::Posix::CheckError(::unlink(secret.NullTerminate()));
20 < #endif
21 < }
22 <
23 < #ifdef __FreeBSD__
24 < ext::String Mounter::secret(api::TheEnvironment.Get("HOME") + "/.nsmbrc");
25 < #endif
26 <
27 < void Mounter::load()
28 < {
29 <        _synchronized (Spectre2::sharesLock)
30 <                Spectre2::shares.Clear();
31 <
32 <        _synchronized (Share::passwordsLock)
33 <                Share::passwords.Clear();
34 <
35 <        _H<xml::Document> document(xml::Parse(config.GetPath()));
36 <        _H<xml::Node> spectre(*document/"spectre");
37 < #ifdef __FreeBSD__
38 <        SecretFileWriter out(secret);
39 <        ios::FormatWriter fout(out);
40 < #endif
41 <
42 <        _foreach (const xml::NodeSet, host_, *spectre/"host")
43 <        {
44 <                ext::String host(**host_/"name");
45 <
46 <                _foreach (const xml::NodeSet, share, **host_/"share")
47 <                {
48 <                        ext::String name(**share/"name"), owner(**share/"owner"), user(**share/"user"), group(**share/"group");
49 <
50 <                        _synchronized (Spectre2::sharesLock)
51 <                                Spectre2::shares.Insert(Share(host, name, owner, user, group));
52 <                }
53 <
54 < #ifdef __FreeBSD__
55 <                ::addrinfo* info;
56 <
57 <                api::Posix::CheckGaiError(::getaddrinfo(host.NullTerminate(), NULL, NULL, &info));
58 <
59 <                ::sockaddr_in& sock(*reinterpret_cast< ::sockaddr_in*>(info->ai_addr));
60 <                ext::Buffer buffer(128);
61 <
62 <                fout << "[" << host << "]" << ios::NewLine << "addr=" << ::inet_ntop(sock.sin_family, &sock.sin_addr, buffer.Begin(), buffer.GetSize()) << ios::NewLine;
63 <
64 <                ::freeaddrinfo(info);
65 < #endif
66 <        }
67 <
68 <        _synchronized (Spectre2::sharesLock)
69 <                Spectre2::shares.Output(api::Cout);
70 <        
71 <        loaded = true;
72 < }
73 <
74 < void Mounter::run()
9 > int Mounter::work(const Share& share)
10   {
11 <        ext::ThreadSet<> workers;
77 <
78 <        _synchronized (Spectre2::sharesLock) _foreach (const ext::RedBlackSet<Share>, share, Spectre2::shares) if (!share->mounted() && share->mountable())
79 <        {
80 <                api::Cerr << "STUB: mount " << *share << ios::NewLine;
81 <        }
82 <
83 <        workers.Join();
11 >        api::Cout << "STUB: mount " << share << ios::NewLine;
12  
13          ::sleep(5);
14 +
15 +        return 0;
16   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines