2019-04-17 07:14:33 +03:00
|
|
|
/*
|
2019-06-20 02:58:25 +03:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2019-04-17 07:14:33 +03:00
|
|
|
*
|
2019-06-20 02:58:25 +03:00
|
|
|
* This software may be used and distributed according to the terms of the
|
|
|
|
* GNU General Public License version 2.
|
2019-04-17 07:14:33 +03:00
|
|
|
*/
|
2019-10-11 15:26:59 +03:00
|
|
|
|
2019-04-17 07:14:33 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file contains helper functions related to parsing edenfs command line
|
|
|
|
* arguments and determining the initial Eden configuration and state directory.
|
|
|
|
*
|
|
|
|
* This enables this logic to be shared by the main edenfs process as well as
|
|
|
|
* other helper tools that need to be able to access the Eden state directory
|
|
|
|
* and configuration data.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <folly/Conv.h>
|
2019-09-06 02:53:27 +03:00
|
|
|
#include <folly/portability/GFlags.h>
|
2019-04-17 07:14:33 +03:00
|
|
|
|
|
|
|
#include "eden/fs/utils/PathFuncs.h"
|
|
|
|
|
2020-02-01 00:20:42 +03:00
|
|
|
DECLARE_bool(foreground);
|
|
|
|
DECLARE_string(configPath);
|
|
|
|
DECLARE_string(etcEdenDir);
|
|
|
|
|
2019-04-17 07:14:33 +03:00
|
|
|
namespace facebook {
|
|
|
|
namespace eden {
|
|
|
|
|
|
|
|
class EdenConfig;
|
|
|
|
class UserInfo;
|
|
|
|
|
2019-08-10 21:15:04 +03:00
|
|
|
PathComponentPiece getDefaultLogFileName();
|
|
|
|
AbsolutePath makeDefaultLogDirectory(AbsolutePathPiece edenDir);
|
|
|
|
std::string getLogPath(AbsolutePathPiece edenDir);
|
|
|
|
|
2019-04-17 07:14:33 +03:00
|
|
|
/**
|
|
|
|
* Get the EdenConfig object.
|
|
|
|
*
|
|
|
|
* This processes the command line arguments and config settings to construct
|
|
|
|
* the EdenConfig. This also determines the location of the Eden state
|
|
|
|
* directory, which can be obtained by calling EdenConfig::getEdenDir().
|
|
|
|
* This function will create the Eden state directory on disk if it does not
|
|
|
|
* already exist.
|
|
|
|
*/
|
|
|
|
std::unique_ptr<EdenConfig> getEdenConfig(UserInfo& identity);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ArgumentError will be thrown by getEdenConfig() for common or expected
|
|
|
|
* exceptions when trying to set up the Eden config data. This includes issues
|
|
|
|
* like bad command line arguments or errors creating or finding the expected
|
|
|
|
* state and config data on disk.
|
|
|
|
*
|
|
|
|
* The caller of getEdenConfig() should generally catch ArgumentError exceptions
|
|
|
|
* and display them nicely to the end user.
|
|
|
|
*/
|
|
|
|
class ArgumentError : public std::exception {
|
|
|
|
public:
|
2020-09-24 07:12:47 +03:00
|
|
|
explicit ArgumentError(std::string&& str) : message_(std::move(str)) {}
|
2019-04-17 07:14:33 +03:00
|
|
|
|
|
|
|
const char* what() const noexcept override {
|
|
|
|
return message_.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string message_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace eden
|
|
|
|
} // namespace facebook
|