CernVM-FS
2.12.0
|
#include <fd_table.h>
Classes | |
struct | FdWrapper |
Public Member Functions | |
FdTable (unsigned max_open_fds, const HandleT &invalid_handle) | |
void | AssignFrom (const FdTable< HandleT > &other) |
FdTable< HandleT > * | Clone () |
int | OpenFd (const HandleT &handle) |
HandleT | GetHandle (int fd) |
int | CloseFd (int fd) |
unsigned | GetMaxFds () const |
Private Member Functions | |
bool | IsValid (int fd) |
Private Member Functions inherited from SingleCopy | |
SingleCopy () | |
Private Attributes | |
HandleT | invalid_handle_ |
unsigned | fd_pivot_ |
std::vector< unsigned > | fd_index_ |
std::vector< FdWrapper > | open_fds_ |
This file is part of the CernVM File System. Maintains integers mapped to custom open file descriptors. File descriptors can be added, removed, and accessed. All operations take constant time. The maximum file descriptor number needs to be known upfront.
Note that new file descriptors do not necessarily have the smallest available number but any number between 0..max_open_fds.
This class is used by a couple of cache managers.
Definition at line 28 of file fd_table.h.
|
inline |
Definition at line 30 of file fd_table.h.
|
inline |
Used to restore the state.
Definition at line 48 of file fd_table.h.
Referenced by ExternalCacheManager::DoRestoreState().
Used to save the state.
Definition at line 62 of file fd_table.h.
|
inline |
Releases fd back to the set of available numbers. Gracefully handles invalid handles (-EBADFD)
Definition at line 104 of file fd_table.h.
|
inline |
For invalid and unused numbers, the invalid handle is returned.
Definition at line 95 of file fd_table.h.
|
inline |
Definition at line 125 of file fd_table.h.
|
inlineprivate |
Definition at line 139 of file fd_table.h.
Referenced by FdTable< ExternalCacheManager::ReadOnlyHandle >::CloseFd(), and FdTable< ExternalCacheManager::ReadOnlyHandle >::GetHandle().
|
inline |
Registers fd with a currently unused number. If the table is full, returns -ENFILE;
Definition at line 78 of file fd_table.h.
|
private |
Maps into open_fds_. Until fd_pivot_, file descriptors are used. As of fd_pivot_, points to free file descriptors. Used to acquire new file descriptors in constant time.
Definition at line 158 of file fd_table.h.
Referenced by FdTable< ExternalCacheManager::ReadOnlyHandle >::AssignFrom(), FdTable< ExternalCacheManager::ReadOnlyHandle >::Clone(), FdTable< ExternalCacheManager::ReadOnlyHandle >::CloseFd(), FdTable< ExternalCacheManager::ReadOnlyHandle >::FdTable(), FdTable< ExternalCacheManager::ReadOnlyHandle >::GetMaxFds(), and FdTable< ExternalCacheManager::ReadOnlyHandle >::OpenFd().
|
private |
The index of the first available file descriptor in fd_index_.
Definition at line 152 of file fd_table.h.
Referenced by FdTable< ExternalCacheManager::ReadOnlyHandle >::AssignFrom(), FdTable< ExternalCacheManager::ReadOnlyHandle >::Clone(), FdTable< ExternalCacheManager::ReadOnlyHandle >::CloseFd(), and FdTable< ExternalCacheManager::ReadOnlyHandle >::OpenFd().
|
private |
An unused (available) file descriptor.
Definition at line 148 of file fd_table.h.
Referenced by FdTable< ExternalCacheManager::ReadOnlyHandle >::AssignFrom(), FdTable< ExternalCacheManager::ReadOnlyHandle >::Clone(), FdTable< ExternalCacheManager::ReadOnlyHandle >::CloseFd(), FdTable< ExternalCacheManager::ReadOnlyHandle >::GetHandle(), FdTable< ExternalCacheManager::ReadOnlyHandle >::IsValid(), and FdTable< ExternalCacheManager::ReadOnlyHandle >::OpenFd().
The file descriptor number mapped to a user-defined file descriptor (struct). The fd integer passed to users of the file descriptor table points into this array.
Definition at line 164 of file fd_table.h.
Referenced by FdTable< ExternalCacheManager::ReadOnlyHandle >::AssignFrom(), FdTable< ExternalCacheManager::ReadOnlyHandle >::Clone(), FdTable< ExternalCacheManager::ReadOnlyHandle >::CloseFd(), FdTable< ExternalCacheManager::ReadOnlyHandle >::FdTable(), FdTable< ExternalCacheManager::ReadOnlyHandle >::GetHandle(), FdTable< ExternalCacheManager::ReadOnlyHandle >::IsValid(), and FdTable< ExternalCacheManager::ReadOnlyHandle >::OpenFd().