ceph/src/cfuse.cc

114 lines
2.8 KiB
C++
Raw Normal View History

// -*- 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 Sage Weil <sage@newdream.net>
*
* 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/stat.h>
#include <iostream>
#include <string>
using namespace std;
#include "config.h"
#include "client/Client.h"
#include "client/fuse.h"
#include "client/fuse_ll.h"
#include "msg/SimpleMessenger.h"
#include "mon/MonClient.h"
#include "common/Timer.h"
2009-02-09 23:46:02 +00:00
#include "common/common_init.h"
#ifndef DARWIN
#include <envz.h>
#endif // DARWIN
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
2008-01-01 22:04:31 +00:00
int main(int argc, const char **argv, const char *envp[]) {
//cerr << "cfuse starting " << myrank << "/" << world << std::endl;
2008-01-01 22:04:31 +00:00
vector<const char*> args;
argv_to_vec(argc, argv, args);
2008-11-05 22:54:13 +00:00
env_to_vec(args);
2009-03-20 19:12:33 +00:00
common_init(args, "cfuse", false);
// args for fuse
vec_to_argv(args, argc, argv);
// FUSE will chdir("/"); be ready.
2009-04-29 18:41:44 +00:00
g_conf.chdir = strdup("/");
if (g_conf.clock_tare) g_clock.tare();
2008-06-18 14:11:20 +00:00
// check for 32-bit arch
if (sizeof(long) == 4) {
cerr << std::endl;
cerr << "WARNING: Ceph inode numbers are 64 bits wide, and FUSE on 32-bit kernels does" << std::endl;
cerr << " not cope well with that situation. Expect to crash shortly." << std::endl;
cerr << std::endl;
}
// get monmap
MonMap monmap;
2009-05-06 23:28:42 +00:00
MonClient mc(&monmap, NULL);
if (!mc.get_monmap())
return -1;
// start up network
SimpleMessenger rank;
2008-01-26 17:33:13 +00:00
rank.bind();
cout << "bound to " << rank.get_rank_addr() << ", mounting ceph" << std::endl;
2009-03-03 19:33:42 +00:00
Client *client = new Client(rank.register_entity(entity_name_t::CLIENT()), &monmap);
2008-01-26 17:33:13 +00:00
rank.start();
rank.set_policy(entity_name_t::TYPE_MON, SimpleMessenger::Policy::lossy_fast_fail());
rank.set_policy(entity_name_t::TYPE_MDS, SimpleMessenger::Policy::lossless());
rank.set_policy(entity_name_t::TYPE_OSD, SimpleMessenger::Policy::lossless());
2008-08-02 21:56:15 +00:00
// start client
client->init();
// start up fuse
// use my argc, argv (make sure you pass a mount point!)
client->mount();
2008-01-25 20:04:31 +00:00
2008-11-05 23:07:39 +00:00
_dout_create_courtesy_output_symlink("client", client->get_nodeid());
2008-01-25 20:10:45 +00:00
cout << "starting fuse" << std::endl;
//cerr << "starting fuse on pid " << getpid() << std::endl;
if (g_conf.fuse_ll)
ceph_fuse_ll_main(client, argc, argv);
else
ceph_fuse_main(client, argc, argv);
//cerr << "fuse finished on pid " << getpid() << std::endl;
2008-01-25 20:10:45 +00:00
cout << "fuse finished, unmounting ceph" << std::endl;
client->unmount();
cout << "unmounted" << std::endl;
client->shutdown();
delete client;
// wait for messenger to finish
rank.wait();
return 0;
}