sapling/eden/fs/nfs/Mountd.h
Xavier Deguillard fdbedc4818 nfs: allow mountd and nfsd sockets to be non-inet on macOS
Summary:
macOS supports NFS servers that can be reached via a unix socket as a way to
improve performance by reducing the TCP cost. To support this, let's first
allow the socket to bind to to be passed to the RpcServer, and then pass it
through to the privhelper code.

Reviewed By: kmancini

Differential Revision: D28261423

fbshipit-source-id: 78c60aac26353d1da76a67897429b964332df8b3
2021-05-12 13:06:57 -07:00

85 lines
2.3 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#ifndef _WIN32
// Implementation of the mount protocol as described in:
// https://tools.ietf.org/html/rfc1813#page-106
#include "eden/fs/inodes/InodeNumber.h"
#include "eden/fs/nfs/rpc/Server.h"
#include "eden/fs/utils/PathFuncs.h"
namespace folly {
class Executor;
}
namespace facebook::eden {
class MountdServerProcessor;
class Mountd {
public:
/**
* Create a new RPC mountd program.
*
* All the socket processing will be run on the EventBase passed in. This
* also must be called on that EventBase thread.
*
* Note: at mount time, EdenFS will manually call mount.nfs with -o mountport
* to manually specify the port on which this server is bound, so registering
* is not necessary for a properly behaving EdenFS.
*/
Mountd(folly::EventBase* evb, std::shared_ptr<folly::Executor> threadPool);
/**
* Bind the RPC mountd program to the passed in address.
*
* If registerWithRpcbind is set, this mountd program will advertise itself
* against the rpcbind daemon allowing it to be visible system wide. Be aware
* that for a given transport (tcp/udp) only one mountd program can be
* registered with rpcbind, and thus if a real NFS server is running on this
* host, EdenFS won't be able to register itself.
*/
void initialize(folly::SocketAddress addr, bool registerWithRpcbind);
/**
* Register a path as the root of a mount point.
*
* Once registered, the mount RPC request for that specific path will answer
* positively with the passed in InodeNumber.
*/
void registerMount(AbsolutePathPiece path, InodeNumber rootIno);
/**
* Unregister the mount point matching the path.
*/
void unregisterMount(AbsolutePathPiece path);
/**
* Obtain the address that this mountd program is listening on.
*/
folly::SocketAddress getAddr() const {
return server_.getAddr();
}
Mountd(const Mountd&) = delete;
Mountd(Mountd&&) = delete;
Mountd& operator=(const Mountd&) = delete;
Mountd& operator=(Mountd&&) = delete;
private:
std::shared_ptr<MountdServerProcessor> proc_;
RpcServer server_;
};
} // namespace facebook::eden
#endif