Line data Source code
1 : // Snap Websites Server -- read mount points in Linux
2 : // Copyright (c) 2013-2019 Made to Order Software Corp. All Rights Reserved
3 : //
4 : // This program is free software; you can redistribute it and/or modify
5 : // it under the terms of the GNU General Public License as published by
6 : // the Free Software Foundation; either version 2 of the License, or
7 : // (at your option) any later version.
8 : //
9 : // This program is distributed in the hope that it will be useful,
10 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : // GNU General Public License for more details.
13 : //
14 : // You should have received a copy of the GNU General Public License
15 : // along with this program; if not, write to the Free Software
16 : // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 : #pragma once
18 :
19 : #include "snapwebsites/snap_exception.h"
20 :
21 : #include <vector>
22 : //#include <memory>
23 : //
24 : //#include <proc/readproc.h>
25 : #include <mntent.h>
26 :
27 : namespace snap
28 : {
29 :
30 0 : class snap_mounts_exception : public snap_exception
31 : {
32 : public:
33 0 : explicit snap_mounts_exception(const char * whatmsg) : snap_exception("snap_mounts", whatmsg) {}
34 : explicit snap_mounts_exception(const std::string & whatmsg) : snap_exception("snap_mounts", whatmsg) {}
35 : explicit snap_mounts_exception(const QString & whatmsg) : snap_exception("snap_mounts", whatmsg) {}
36 : };
37 :
38 0 : class snap_mounts_exception_io_error : public snap_mounts_exception
39 : {
40 : public:
41 0 : explicit snap_mounts_exception_io_error(const char * whatmsg) : snap_mounts_exception(whatmsg) {}
42 : explicit snap_mounts_exception_io_error(const std::string & whatmsg) : snap_mounts_exception(whatmsg) {}
43 : explicit snap_mounts_exception_io_error(const QString & whatmsg) : snap_mounts_exception(whatmsg) {}
44 : };
45 :
46 :
47 :
48 :
49 0 : class mount_entry
50 : {
51 : public:
52 0 : mount_entry(struct mntent * e)
53 0 : : f_fsname(e->mnt_fsname)
54 0 : , f_dir(e->mnt_dir)
55 0 : , f_type(e->mnt_type)
56 0 : , f_options(e->mnt_opts)
57 0 : , f_freq(e->mnt_freq)
58 0 : , f_passno(e->mnt_passno)
59 : {
60 0 : }
61 :
62 : std::string const & get_fsname() const { return f_fsname; }
63 : std::string const & get_dir() const { return f_dir; }
64 : std::string const & get_type() const { return f_type; }
65 : std::string const & get_options() const { return f_options; }
66 : int get_freq() const { return f_freq; }
67 : int get_passno() const { return f_passno; }
68 :
69 : private:
70 : std::string f_fsname;
71 : std::string f_dir;
72 : std::string f_type;
73 : std::string f_options;
74 : int f_freq;
75 : int f_passno;
76 : };
77 :
78 :
79 :
80 : class mounts : public std::vector<mount_entry>
81 : {
82 : public:
83 : mounts(std::string const & path);
84 :
85 : std::string const & get_path() const { return f_path; }
86 :
87 : private:
88 : std::string f_path;
89 : };
90 :
91 :
92 :
93 :
94 : } // namespace snap
95 : // vim: ts=4 sw=4 et
|