<commit_before>// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
// vim: ts=8 sw=2 smarttab
/*
 * Ceph - scalable distributed file system
 *
 * Copyright (C) 2004-2006 <NAME> <<EMAIL>>
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software 
 * Foundation.  See file COPYING.
 * 
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <sys/stat.h>
#include <iostream>
#include <string>
using namespace std;

#include "config.h"

#include "mon/MonMap.h"
#include "mon/MonClient.h"

#include "osd/OSD.h"
#include "ebofs/Ebofs.h"

#include "msg/SimpleMessenger.h"

#include "common/Timer.h"
#include "common/common_init.h"

void usage() 
{
  cerr << "usage: cosd <device> [-j journalfileordev] [-m monitor] [--mkfs_for_osd <nodeid>]" << std::endl;
  cerr << "   -d              daemonize" << std::endl;
  cerr << "   --debug_osd N   set debug level (e.g. 10)" << std::endl;
  cerr << "   --debug_ms N    set message debug level (e.g. 1)" << std::endl;
  cerr << "   --ebofs         use EBOFS for object storage (default)" << std::endl;
  cerr << "   --fakestore     store objects as files in directory <device>" << std::endl;
  exit(1);
}


int main(int argc, const char **argv) 
{
  vector<const char*> args;
  argv_to_vec(argc, argv, args);
  env_to_vec(args);
  common_init(args);

  if (g_conf.clock_tare) g_clock.tare();

  // osd specific args
  const char *dev = 0, *journaldev = 0;
  int whoami = -1;
  bool mkfs = 0;
  for (unsigned i=0; i<args.size(); i++) {
    if (strcmp(args[i],"--mkfs_for_osd") == 0) {
      mkfs = 1; 
      whoami = atoi(args[++i]);
    } else if (strcmp(args[i],"--dev") == 0) 
      dev = args[++i];
    else if (strcmp(args[i],"-j") == 0)
      journaldev = args[++i];
    else if (!dev)
      dev = args[i];
    else {
      cerr << "unrecognized arg " << args[i] << std::endl;
      usage();
    }
  }
  if (!dev) {
    cerr << "must specify device file" << std::endl;
    usage();
  }

  if (mkfs && whoami < 0) {
    cerr << "must specify '--osd #' where # is the osd number" << std::endl;
    usage();
  }

  // get monmap
  MonMap monmap;
  MonClient mc;
  if (mc.get_monmap(&monmap) < 0)
    return -1;

  if (mkfs) {
    int err = OSD::mkfs(dev, journaldev, monmap.fsid, whoami);
    if (err < 0) {
      cerr << "error creating empty object store in " << dev << ": " << strerror(-err) << std::endl;<commit_msg>cosd: clean up startup options<commit_after>// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
// vim: ts=8 sw=2 smarttab
/*
 * Ceph - scalable distributed file system
 *
 * Copyright (C) 2004-2006 <NAME> <<EMAIL>>
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software 
 * Foundation.  See file COPYING.
 * 
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <sys/stat.h>
#include <iostream>
#include <string>
using namespace std;

#include "config.h"

#include "mon/MonMap.h"
#include "mon/MonClient.h"

#include "osd/OSD.h"
#include "ebofs/Ebofs.h"

#include "msg/SimpleMessenger.h"

#include "common/Timer.h"
#include "common/common_init.h"

void usage() 
{
  cerr << "usage: cosd <device> [-j journalfileordev] [-m monitor] [--mkfs_for_osd <nodeid>]" << std::endl;
  cerr << "   -d              daemonize" << std::endl;
  cerr << "   --debug_osd N   set debug level (e.g. 10)" << std::endl;
  cerr << "   --debug_ms N    set message debug level (e.g. 1)" << std::endl;
  cerr << "   --ebofs         use EBOFS for object storage (default)" << std::endl;
  cerr << "   --fakestore     store objects as files in directory <device>" << std::endl;
  exit(1);
}


int main(int argc, const char **argv) 
{
  vector<const char*> args;
  argv_to_vec(argc, argv, args);
  env_to_vec(args);
  common_init(args);

  if (g_conf.clock_tare) g_clock.tare();

  // osd specific args
  const char *dev = 0, *journaldev = 0;
  int whoami = -1;
  bool mkfs = 0;
  for (unsigned i=0; i<args.size(); i++) {
    if (strcmp(args[i],"--mkfs_for_osd") == 0) {
      mkfs = 1; 
      whoami = atoi(args[++i]);
    } else if (strcmp(args[i],"-j") == 0)
      journaldev = args[++i];
    else if (!dev)
      dev = args[i];
    else {
      cerr << "unrecognized arg " << args[i] << std::endl;
      usage();
    }
  }
  if (!dev) {
    cerr << "must specify device file" << std::endl;
    usage();
  }

  if (mkfs && whoami < 0) {
    cerr << "must specify '--osd #' where # is the osd number" << std::endl;
    usage();
  }

  // get monmap
  MonMap monmap;
  MonClient mc;
  if (mc.get_monmap(&monmap) < 0)
    return -1;

  if (mkfs) {
    int err = OSD::mkfs(dev, journaldev, monmap.fsid, whoami);
    if (err < 0) {
      cerr << "error creating empty object store in " << dev << ": " << strerror(-err) << std::endl;
{'fraction_non_alphanumeric': 0.17854283426741394, 'fraction_numerical': 0.0122097678142514, 'mean_word_length': 2.8796583850931676, 'pattern_counts': {'":': 2, '<': 133, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1912160', 'n_tokens_mistral': 1954, 'n_tokens_neox': 1895, 'n_words': 523}