mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
ec5a6ef1f0
Summary: The NFS readdir turns out to be pretty similar to the FUSE one, with a couple of differences. For one, it only populates the directory entry name, it also puts a limit on the total size of the serialized result, including all the NFS/XDR overhead. It is not specified if the . and .. entries need to be returned, but since the NFS spec is usually pretty explicit about these and makes it clear that this is for the most part a client burden, I didn't add these. I may have to revisit this later when I get to manually browse a repository. Since the READDIR RPC doesn't populate any filehandle, the client will have to issue a LOOKUP RPC for each entries, potentially leading to some inefficiencies. A future diff will implement the READDIRPLUS to fix these. Reviewed By: chadaustin Differential Revision: D26802310 fbshipit-source-id: b821b57021d0c2dca33427975b1acd665173bc5c
53 lines
1.1 KiB
C++
53 lines
1.1 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
|
|
|
|
#include "eden/fs/inodes/InodeNumber.h"
|
|
#include "eden/fs/nfs/NfsdRpc.h"
|
|
|
|
namespace facebook::eden {
|
|
|
|
/**
|
|
* Abstraction to only add as many directory entries that can fit into a given
|
|
* amount of memory.
|
|
*/
|
|
class NfsDirList {
|
|
public:
|
|
explicit NfsDirList(uint32_t count);
|
|
|
|
NfsDirList(NfsDirList&&) = default;
|
|
NfsDirList& operator=(NfsDirList&&) = default;
|
|
|
|
NfsDirList() = delete;
|
|
NfsDirList(const NfsDirList&) = delete;
|
|
NfsDirList& operator=(const NfsDirList&) = delete;
|
|
|
|
/**
|
|
* Add an entry. Return true if the entry was successfully added, false
|
|
* otherwise.
|
|
*/
|
|
bool add(folly::StringPiece name, InodeNumber ino, uint64_t offset);
|
|
|
|
/**
|
|
* Move the built list out of the NfsDirList.
|
|
*/
|
|
XdrList<entry3> extractList() {
|
|
return std::move(list_);
|
|
}
|
|
|
|
private:
|
|
uint32_t remaining_;
|
|
XdrList<entry3> list_{};
|
|
};
|
|
|
|
} // namespace facebook::eden
|
|
|
|
#endif
|