"Fossies" - the Fresh Open Source Software Archive 
Member "fstransform-0.9.4/fsremap/src/remap.hh" (31 Mar 2019, 4777 Bytes) of package /linux/misc/fstransform-0.9.4.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "remap.hh" see the
Fossies "Dox" file reference documentation and the latest
Fossies "Diffs" side-by-side code changes report:
0.9.3_vs_0.9.4.
1 /*
2 * fstransform - transform a file-system to another file-system type,
3 * preserving its contents and without the need for a backup
4 *
5 * Copyright (C) 2011-2012 Massimiliano Ghilardi
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * remap.hh
21 *
22 * Created on: Feb 28, 2011
23 * Author: max
24 */
25
26 #ifndef FSREMAP_REMAP_HH
27 #define FSREMAP_REMAP_HH
28
29 #include "check.hh"
30
31 #include "args.hh" // for fr_args
32 #include "io/persist.hh" // for fr_persist
33 #include "io/io.hh" // for fr_io
34 #include "io/io_posix.hh" // for fr_io_posix
35 #include "io/io_test.hh" // for fr_io_test
36 #include "ui/ui.hh" // for fr_ui
37 #include "ui/ui_tty.hh" // for fr_ui_tty
38
39 FT_NAMESPACE_BEGIN
40
41 class fr_remap
42 {
43 private:
44 fr_job * this_job;
45 FT_IO_NS fr_persist * this_persist;
46 FT_IO_NS fr_io * this_io;
47 FT_UI_NS fr_ui * this_ui;
48
49 /** true if usage() or version() was called. */
50 bool quit_immediately;
51
52 /** cannot call copy constructor */
53 fr_remap(const fr_remap &);
54
55 /** cannot call assignment operator */
56 const fr_remap & operator=(const fr_remap &);
57
58 /** display command-line usage to stdout and return 0 */
59 int usage(const char * program_name);
60
61 /** output version information and return 0 */
62 int version();
63
64 static int invalid_cmdline(const fr_args & args, int err, const char * fmt, ...);
65
66 /** return EISCONN if remapper is initialized, else call quit_io() and return 0 */
67 int check_is_closed();
68
69 /** return 0 if remapper is initialized, else call quit_io() and return ENOTCONN */
70 int check_is_open();
71
72 /** initialize job/persistence subsystem */
73 int init_job_persist(const fr_args & argsd);
74
75 /** quit job/persistence subsystem */
76 void quit_job_persist();
77
78
79 /** initialize UI subsystem */
80 int init_ui(const fr_args & args);
81 /** initialize tty UI subsystem */
82 int init_ui_tty(const char * arg);
83
84 /** quit UI subsystem */
85 void quit_ui();
86
87 int pre_init_io();
88
89 /**
90 * initialize remapper to use I/O type IO_T.
91 *
92 * args depend on I/O type:
93 * POSIX and PREALLOC I/O require two or three arguments in args.io_args: DEVICE, LOOP-FILE and optionally ZERO-FILE;
94 * test I/O requires three arguments in args.io_args: DEVICE-LENGTH, LOOP-FILE-EXTENTS and ZERO-FILE-EXTENTS;
95 * self-test I/O does not require any argument in args.io_args;
96 * return 0 if success, else error.
97 */
98 template<class IO_T>
99 int init_io_class(const fr_args & args);
100
101
102 void post_init_io(FT_IO_NS fr_io * io);
103
104 public:
105
106 /** constructor */
107 fr_remap();
108
109 /** destructor. calls quit_io() */
110 ~fr_remap();
111
112 /**
113 * high-level main method.
114 * calls in sequence: init(argc, argv), run(), quit_io()
115 *
116 * expects argc == 4 and four arguments in argv:
117 * program_name, DEVICE, LOOP-FILE and ZERO-FILE.
118 *
119 * return 0 if success, else error.
120 * if invoked with the only argument "--help", calls usage() and immediately returns 0
121 */
122 static int main(int argc, char const* const* argv);
123
124 FT_INLINE bool is_initialized() const { return this_io != NULL && this_io->is_open(); }
125
126 /**
127 * parse from command line and initialize all subsystems (job, I/O, log...)
128 * return 0 if success, else error.
129 *
130 * implementation: parse command line, fill a fr_args and call init(const fr_args &)
131 */
132 int init(int argc, char const* const* argv);
133
134 /**
135 * initialize all subsystems (job, I/O, log...) using specified arguments
136 * return 0 if success, else error.
137 */
138 int init(const fr_args & args);
139
140 /**
141 * allocate, open and use I/O specified in args.
142 * if success, stores a pointer to I/O object
143 * destructor and quit_io() will delete fr_io object.
144 *
145 * return 0 if success, else error.
146 */
147 int init_io(const fr_args & args);
148
149 /**
150 * perform actual work using configured I/O
151 * return 0 if success, else error.
152 */
153 int run();
154
155 /** close configured I/O and delete it */
156 void quit_io();
157 };
158
159
160 FT_NAMESPACE_END
161
162 #endif /* FSREMAP_REMAP_HH */