sapling/eden/fs/testharness/FakePrivHelper.h
Adam Simpkins f2b4038361 add a privhelper call to set the log file
Summary:
Add a call to tell the privhelper process to redirect its log messages to a
different file handle.

This call will make it possible for the privhelper processed to be forked
before the main edenfs process has processed the --logPath argument.  The main
edenfs process can now drop privileges before it processes arguments and opens
the log file, and it can then pass the file handle to the privhelper process.

Reviewed By: wez

Differential Revision: D8212776

fbshipit-source-id: 3ec6bfc82ee090216d66c5bfd1b8c2b8819c1f45
2018-06-18 17:22:18 -07:00

62 lines
1.9 KiB
C++

/*
* Copyright (c) 2004-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include "eden/fs/fuse/privhelper/PrivHelper.h"
#include "eden/fs/utils/PathFuncs.h"
#include <string>
#include <unordered_map>
namespace facebook {
namespace eden {
class FakeFuse;
/**
* FakePrivHelper implements the PrivHelper API, but returns FakeFuse
* connections rather than performing actual FUSE mounts to the kernel.
*
* This allows test code to directly control the FUSE messages sent to an
* EdenMount.
*/
class FakePrivHelper : public PrivHelper {
public:
FakePrivHelper();
void registerMount(
AbsolutePathPiece mountPath,
std::shared_ptr<FakeFuse> fuse);
// PrivHelper functions
void attachEventBase(folly::EventBase* eventBase) override;
void detachEventBase() override;
folly::Future<folly::File> fuseMount(folly::StringPiece mountPath) override;
folly::Future<folly::Unit> fuseUnmount(folly::StringPiece mountPath) override;
folly::Future<folly::Unit> bindMount(
folly::StringPiece clientPath,
folly::StringPiece mountPath) override;
folly::Future<folly::Unit> fuseTakeoverShutdown(
folly::StringPiece mountPath) override;
folly::Future<folly::Unit> fuseTakeoverStartup(
folly::StringPiece mountPath,
const std::vector<std::string>& bindMounts) override;
folly::Future<folly::Unit> setLogFile(folly::File logFile) override;
int stop() override;
private:
FakePrivHelper(FakePrivHelper const&) = delete;
FakePrivHelper& operator=(FakePrivHelper const&) = delete;
std::unordered_map<std::string, std::shared_ptr<FakeFuse>> mounts_;
};
} // namespace eden
} // namespace facebook