diff --git a/tools/tool.cpp b/tools/tool.cpp index fc91f4a1195..1a7a6a3c389 100644 --- a/tools/tool.cpp +++ b/tools/tool.cpp @@ -47,7 +47,10 @@ namespace mongo { ; if ( localDBAllowed ) _options->add_options() - ("dbpath",po::value(), "directly access mongod data files in the given path, instead of connecting to a mongod instance - needs to lock the data directory, so cannot be used if a mongod is currently accessing the same path" ) + ("dbpath",po::value(), "directly access mongod data " + "files in the given path, instead of connecting to a mongod " + "instance - needs to lock the data directory, so cannot be " + "used if a mongod is currently accessing the same path" ) ("directoryperdb", "if dbpath specified, each db is in a separate directory" ) ; @@ -157,7 +160,17 @@ namespace mongo { _host = "DIRECT"; static string myDbpath = getParam( "dbpath" ); dbpath = myDbpath.c_str(); - acquirePathLock(); + try { + acquirePathLock(); + } + catch ( DBException& e ){ + cerr << endl << "If you are running a mongod on the same " + "path you should connect to that instead of direct data " + "file access" << endl << endl; + dbexit( EXIT_CLEAN ); + return -1; + } + theFileAllocator().start(); }