sapling/eden/fs/inodes/UnmaterializedUnloadedBlobDirEntry.h
Katie Mancini c0ba5509a2 InodeOrTreeOrEntry -> VirtualInode
Summary:
InodeOrTreeOrEntry is a lot to type and doesn't really indicate what
InodeOrTreeOrEntry is used for.

We are using it a virtualization abstaction to allow us to operate on inodes
in different states with out having to load all of them.

Let's pick a name that is a little shorter and is more indicative of the use of
InodeOrTreeOrEntry.

VirtualInode was suggested by Chad, and seems to capture what we want well.

I used:

```
find . -type f | xargs sed -i 's/InodeOrTreeOrEntry/VirtualInode/g'
find . -type f | xargs sed -i 's/inodeOrTreeOrEntry/virtualInode/g'
find . -type f | xargs sed -i 's/InodeOrTree/VirtualInode/g'
find . -type f | xargs sed -i 's/InodeOr/VirtualInode/g'
find . -type f | xargs sed -i 's/inodeOrTree/virtualInode/g'
find . -type f | xargs sed -i 's/inodeOrEntry/virtualInode/g'
find . -type f | xargs sed -i 's/inodeOr/virtualInode/g'
```

manually edited filenames and targets

Reviewed By: chadaustin

Differential Revision: D37804497

fbshipit-source-id: a931c4c4aaa306c638310df12432328d49f21375
2022-07-18 20:19:51 -07:00

64 lines
1.9 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#include "eden/fs/inodes/DirEntry.h"
#include "eden/fs/model/ObjectId.h"
#include "eden/fs/utils/DirType.h"
namespace facebook::eden {
/**
* A fake directory entry for use inside VirtualInode.
*
* The VirtualInode class allows callers to see a "mixed" view of the eden
* mount, which respresents both on-disk (inode) state, and in-backing-store
* (source control) state. When a DirEntry represents a ObjectStore object that
* doesn't exist on disk (isn't loaded, isn't materialized), some of the
* contents of DirEntry must be returned to represent the object (particularly
* the ObjectId), but DirEntry can't be safely copied, as it protected by the
* holding-Inode's contents() lock.
*
* This class copies enough of the DirEntry to be able to reason about the
* underlying objects, and is safe to copy around.
*/
class UnmaterializedUnloadedBlobDirEntry {
public:
// Note that these objects are only constructed when it is known that the
// entry.getHash() exists. See TreeInode::getOrFindChild()
explicit UnmaterializedUnloadedBlobDirEntry(const DirEntry& entry)
: hash_(entry.getHash()),
dtype_(entry.getDtype()),
initialMode_(entry.getInitialMode()) {}
const ObjectId getHash() const {
return hash_;
}
dtype_t getDtype() const {
return dtype_;
}
/**
* The initial mode of the shadowed DirEntry.
*
* Note that these objects are only created for unloaded/unmaterialized
* inodes, so the initialMode is a good representation of the mode just after
* loading.
*/
mode_t getInitialMode() const {
return initialMode_;
}
private:
ObjectId hash_;
dtype_t dtype_;
mode_t initialMode_;
};
} // namespace facebook::eden