Skip to content

Commit

Permalink
cosd.cc: use new argument parsing functions
Browse files Browse the repository at this point in the history
Signed-off-by: Colin McCabe <[email protected]>
  • Loading branch information
cmccabe committed Sep 6, 2011
1 parent ba05e5e commit b1da7ec
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions src/cosd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ void usage()

int main(int argc, const char **argv)
{
DEFINE_CONF_VARS(usage);
vector<const char*> args;
argv_to_vec(argc, argv, args);
env_to_vec(args);
Expand All @@ -65,31 +64,41 @@ int main(int argc, const char **argv)
bool mkkey = false;
bool flushjournal = false;
bool convertfilestore = false;
char *dump_pg_log = 0;
FOR_EACH_ARG(args) {
if (CEPH_ARGPARSE_EQ("mkfs", '\0')) {
std::string dump_pg_log;

std::string val;
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
if (ceph_argparse_double_dash(args, i)) {
break;
} else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
usage();
exit(0);
} else if (ceph_argparse_flag(args, i, "--mkfs", (char*)NULL)) {
mkfs = true;
} else if (CEPH_ARGPARSE_EQ("mkjournal", '\0')) {
} else if (ceph_argparse_flag(args, i, "--mkjournal", (char*)NULL)) {
mkjournal = true;
} else if (CEPH_ARGPARSE_EQ("mkkey", '\0')) {
} else if (ceph_argparse_flag(args, i, "--mkkey", (char*)NULL)) {
mkkey = true;
} else if (CEPH_ARGPARSE_EQ("flush-journal", '\0')) {
} else if (ceph_argparse_flag(args, i, "--flush-journal", (char*)NULL)) {
flushjournal = true;
} else if (CEPH_ARGPARSE_EQ("convert-filestore", '\0')) {
} else if (ceph_argparse_flag(args, i, "--convert-filestore", (char*)NULL)) {
convertfilestore = true;
} else if (CEPH_ARGPARSE_EQ("dump-pg-log", '\0')) {
CEPH_ARGPARSE_SET_ARG_VAL(&dump_pg_log, OPT_STR);
} else if (ceph_argparse_witharg(args, i, &val, "--dump-pg-log", (char*)NULL)) {
dump_pg_log = val;
} else {
derr << "unrecognized arg " << args[i] << dendl;
usage();
++i;
}
}
if (!args.empty()) {
derr << "unrecognized arg " << args[0] << dendl;
usage();
}

if (dump_pg_log) {
if (!dump_pg_log.empty()) {
common_init_finish(g_ceph_context);
bufferlist bl;
std::string error;
int r = bl.read_file(dump_pg_log, &error);
int r = bl.read_file(dump_pg_log.c_str(), &error);
if (r >= 0) {
PG::Log::Entry e;
bufferlist::iterator p = bl.begin();
Expand Down

0 comments on commit b1da7ec

Please sign in to comment.