MCPcopy Create free account
hub / github.com/ceph/ceph / parse_args

Method parse_args

src/tools/cephfs/JournalFilter.cc:178–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176
177
178int JournalFilter::parse_args(
179 std::vector<const char*> &argv,
180 std::vector<const char*>::iterator &arg)
181{
182 while(arg != argv.end()) {
183 std::string arg_str;
184 if (ceph_argparse_witharg(argv, arg, &arg_str, "--range", (char*)NULL)) {
185 size_t sep_loc = arg_str.find(JournalFilter::range_separator);
186 if (sep_loc == std::string::npos || arg_str.size() <= JournalFilter::range_separator.size()) {
187 derr << "Invalid range '" << arg_str << "'" << dendl;
188 return -EINVAL;
189 }
190
191 // We have a lower bound
192 if (sep_loc > 0) {
193 std::string range_start_str = arg_str.substr(0, sep_loc);
194 std::string parse_err;
195 range_start = strict_strtoll(range_start_str.c_str(), 0, &parse_err);
196 if (!parse_err.empty()) {
197 derr << "Invalid lower bound '" << range_start_str << "': " << parse_err << dendl;
198 return -EINVAL;
199 }
200 }
201
202 if (sep_loc < arg_str.size() - JournalFilter::range_separator.size()) {
203 std::string range_end_str = arg_str.substr(sep_loc + range_separator.size());
204 std::string parse_err;
205 range_end = strict_strtoll(range_end_str.c_str(), 0, &parse_err);
206 if (!parse_err.empty()) {
207 derr << "Invalid upper bound '" << range_end_str << "': " << parse_err << dendl;
208 return -EINVAL;
209 }
210 }
211 } else if (ceph_argparse_witharg(argv, arg, &arg_str, "--path", (char*)NULL)) {
212 if (!type.compare("purge_queue")) {
213 derr << "Invalid filter arguments: purge_queue doesn't take \"--path\"." << dendl;
214 return -EINVAL;
215 }
216 dout(4) << "Filtering by path '" << arg_str << "'" << dendl;
217 path_expr = arg_str;
218 } else if (ceph_argparse_witharg(argv, arg, &arg_str, "--inode", (char*)NULL)) {
219 dout(4) << "Filtering by inode '" << arg_str << "'" << dendl;
220 std::string parse_err;
221 inode = strict_strtoll(arg_str.c_str(), 0, &parse_err);
222 if (!parse_err.empty()) {
223 derr << "Invalid inode '" << arg_str << "': " << parse_err << dendl;
224 return -EINVAL;
225 }
226 } else if (ceph_argparse_witharg(argv, arg, &arg_str, "--type", (char*)NULL)) {
227 try {
228 if (!type.compare("mdlog")) {
229 event_type = LogEvent::str_to_type(arg_str);
230 } else if (!type.compare("purge_queue")) {
231 purge_action = PurgeItem::str_to_type(arg_str);
232 }
233 } catch (const std::out_of_range&) {
234 derr << "Invalid event type '" << arg_str << "'" << dendl;
235 return -EINVAL;

Callers 15

mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
main_eventMethod · 0.45
first-damage.pyFile · 0.45
mainFunction · 0.45
_parse_argsFunction · 0.45
mainFunction · 0.45
mainMethod · 0.45
mainFunction · 0.45
parse_cliFunction · 0.45

Calls 11

ceph_argparse_withargFunction · 0.85
strict_strtollFunction · 0.85
dirfrag_tClass · 0.85
frag_tClass · 0.85
substrMethod · 0.80
endMethod · 0.45
findMethod · 0.45
sizeMethod · 0.45
c_strMethod · 0.45
emptyMethod · 0.45
compareMethod · 0.45