CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseMagicXattr Class Reference

#include <magic_xattr.h>

Inheritance diagram for BaseMagicXattr:
Collaboration diagram for BaseMagicXattr:

Public Member Functions

 BaseMagicXattr ()
 
void MarkProtected ()
 
bool PrepareValueFencedProtected (gid_t gid)
 
std::pair< bool, std::string > GetValue (int32_t requested_page, const MagicXattrMode mode)
 
virtual MagicXattrFlavor GetXattrFlavor ()
 
void Lock (PathString path, catalog::DirectoryEntry *dirent)
 
void Release ()
 
virtual ~BaseMagicXattr ()
 

Static Public Attributes

static const uint32_t kMaxCharsPerPage = 40000
 

Protected Member Functions

virtual bool PrepareValueFenced ()
 
virtual void FinalizeValue ()
 
std::string HeaderMultipageHuman (uint32_t requested_page)
 

Protected Attributes

MagicXattrManagerxattr_mgr_
 
PathString path_
 
catalog::DirectoryEntrydirent_
 
pthread_mutex_t access_mutex_
 
bool is_protected_
 
std::vector< std::string > result_pages_
 

Private Member Functions

 FRIEND_TEST (T_MagicXattr, ProtectedXattr)
 
 FRIEND_TEST (T_MagicXattr, TestFqrn)
 
 FRIEND_TEST (T_MagicXattr, TestLogBuffer)
 

Friends

class MagicXattrManager
 

Detailed Description

This is a base class for magic extended attribute. Every extended attributes must inherit from this class. It should be generally used only in cooperation with MagicXattrManager. It contains an access mutex. Users should use Lock() and Release() before and after usage (Lock() is called implicitly in MagicXattrManager).

To read out the attribute value, do: 0. Get an instance through MagicXattrManager::Get()

  1. Call PrepareValueFenced() inside FuseRemounter::fence()
  2. Call GetValue(int32_t requested_page, const MagicXattrMode mode); It returns a <bool, string> pair where the bool is set to true if the request was successful and the string contains the actual value. GetValue() can be called outside the fence. This will internally call FinalizeValue() to finalize the value preparation outside the fuse fence.

Implementation notes:

  • Each MagicXattr must implement it's own FinalizeValue() function which has to write its value into result_pages_.
  • result_pages_ is a vector of strings. Each string is <= kMaxCharsPerPage
  • BaseMagicXattr::GetValue() takes care of clearing result_pages_ before each new call of FinalizeValue(), and takes care of adding a header for the human readable version
  • In case an invalid request happens, GetValue() <bool> is set to false. "ENOENT" will be returned, while in human-readable mode a more verbose error message will be returned

Definition at line 66 of file magic_xattr.h.

Constructor & Destructor Documentation

BaseMagicXattr::BaseMagicXattr ( )
inline

Definition at line 73 of file magic_xattr.h.

Here is the call graph for this function:

virtual BaseMagicXattr::~BaseMagicXattr ( )
inlinevirtual

Definition at line 134 of file magic_xattr.h.

Member Function Documentation

BaseMagicXattr::FRIEND_TEST ( T_MagicXattr  ,
ProtectedXattr   
)
private
BaseMagicXattr::FRIEND_TEST ( T_MagicXattr  ,
TestFqrn   
)
private
BaseMagicXattr::FRIEND_TEST ( T_MagicXattr  ,
TestLogBuffer   
)
private
std::pair< bool, std::string > BaseMagicXattr::GetValue ( int32_t  requested_page,
const MagicXattrMode  mode 
)

This function needs to be called after PrepareValueFenced(), which prepares the necessary data and header for kXattrHumanMode. It does the computationaly intensive part, which should not be done inside the FuseRemounter::fence(), and returns the value.

Internally it calls FinalizeValue() which each MagicXAttr has to implement to set the value of result_pages_

  • requested_page: >= 0: requested paged of the attribute -1: get info about xattr: e.g. the number of pages available
  • mode: either machine-readable or human-readable
Returns
std::pair<bool, std::string> bool = false if in machine-readable mode an invalid request is performed (human-readable mode always succeeds and gives a verbose message) otherwise true std::string = the actual value of the attribute or info element ( or error message in human-readable mode)

Definition at line 205 of file magic_xattr.cc.

Here is the call graph for this function:

virtual MagicXattrFlavor BaseMagicXattr::GetXattrFlavor ( )
inlinevirtual
std::string BaseMagicXattr::HeaderMultipageHuman ( uint32_t  requested_page)
protected

Definition at line 198 of file magic_xattr.cc.

Referenced by GetValue().

Here is the call graph for this function:

Here is the caller graph for this function:

void BaseMagicXattr::Lock ( PathString  path,
catalog::DirectoryEntry dirent 
)
inline

Definition at line 123 of file magic_xattr.h.

Referenced by MagicXattrManager::GetLocked(), and MagicXattrRAIIWrapper::MagicXattrRAIIWrapper().

Here is the call graph for this function:

Here is the caller graph for this function:

void BaseMagicXattr::MarkProtected ( )
inline

Mark a Xattr protected so that only certain users with the correct gid can access it.

Definition at line 82 of file magic_xattr.h.

Referenced by MagicXattrManager::Register().

Here is the caller graph for this function:

virtual bool BaseMagicXattr::PrepareValueFenced ( )
inlineprotectedvirtual
bool BaseMagicXattr::PrepareValueFencedProtected ( gid_t  gid)

Access right check before normal fence

Definition at line 158 of file magic_xattr.cc.

Here is the call graph for this function:

void BaseMagicXattr::Release ( )
inline

Definition at line 129 of file magic_xattr.h.

Referenced by MagicXattrRAIIWrapper::~MagicXattrRAIIWrapper().

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class MagicXattrManager
friend

Definition at line 67 of file magic_xattr.h.

Member Data Documentation

pthread_mutex_t BaseMagicXattr::access_mutex_
protected

Definition at line 153 of file magic_xattr.h.

Referenced by BaseMagicXattr(), Lock(), and Release().

bool BaseMagicXattr::is_protected_
protected

Definition at line 154 of file magic_xattr.h.

Referenced by MarkProtected(), and PrepareValueFencedProtected().

const uint32_t BaseMagicXattr::kMaxCharsPerPage = 40000
static
std::vector<std::string> BaseMagicXattr::result_pages_
protected

Definition at line 155 of file magic_xattr.h.

Referenced by AuthzMagicXattr::FinalizeValue(), CatalogCountersMagicXattr::FinalizeValue(), ChunkListMagicXattr::FinalizeValue(), ChunksMagicXattr::FinalizeValue(), CompressionMagicXattr::FinalizeValue(), DirectIoMagicXattr::FinalizeValue(), ExternalFileMagicXattr::FinalizeValue(), ExternalHostMagicXattr::FinalizeValue(), ExternalTimeoutMagicXattr::FinalizeValue(), FqrnMagicXattr::FinalizeValue(), HashMagicXattr::FinalizeValue(), HostMagicXattr::FinalizeValue(), HostListMagicXattr::FinalizeValue(), LHashMagicXattr::FinalizeValue(), LogBufferXattr::FinalizeValue(), NCleanup24MagicXattr::FinalizeValue(), NClgMagicXattr::FinalizeValue(), NDirOpenMagicXattr::FinalizeValue(), NDownloadMagicXattr::FinalizeValue(), NIOErrMagicXattr::FinalizeValue(), NOpenMagicXattr::FinalizeValue(), HitrateMagicXattr::FinalizeValue(), ProxyMagicXattr::FinalizeValue(), ProxyListMagicXattr::FinalizeValue(), ProxyListExternalMagicXattr::FinalizeValue(), PubkeysMagicXattr::FinalizeValue(), RawlinkMagicXattr::FinalizeValue(), RepoCountersMagicXattr::FinalizeValue(), RepoMetainfoMagicXattr::FinalizeValue(), RevisionMagicXattr::FinalizeValue(), RootHashMagicXattr::FinalizeValue(), RxMagicXattr::FinalizeValue(), SpeedMagicXattr::FinalizeValue(), TagMagicXattr::FinalizeValue(), TimeoutMagicXattr::FinalizeValue(), TimeoutDirectMagicXattr::FinalizeValue(), TimestampLastIOErrMagicXattr::FinalizeValue(), UsedFdMagicXattr::FinalizeValue(), UsedDirPMagicXattr::FinalizeValue(), VersionMagicXattr::FinalizeValue(), ExternalURLMagicXattr::FinalizeValue(), GetValue(), and HeaderMultipageHuman().

MagicXattrManager* BaseMagicXattr::xattr_mgr_
protected

Definition at line 149 of file magic_xattr.h.

Referenced by AuthzMagicXattr::FinalizeValue(), ExternalHostMagicXattr::FinalizeValue(), ExternalTimeoutMagicXattr::FinalizeValue(), FqrnMagicXattr::FinalizeValue(), HostMagicXattr::FinalizeValue(), HostListMagicXattr::FinalizeValue(), LHashMagicXattr::FinalizeValue(), NCleanup24MagicXattr::FinalizeValue(), NDirOpenMagicXattr::FinalizeValue(), NDownloadMagicXattr::FinalizeValue(), NIOErrMagicXattr::FinalizeValue(), NOpenMagicXattr::FinalizeValue(), HitrateMagicXattr::FinalizeValue(), ProxyMagicXattr::FinalizeValue(), ProxyListMagicXattr::FinalizeValue(), ProxyListExternalMagicXattr::FinalizeValue(), RepoMetainfoMagicXattr::FinalizeValue(), RxMagicXattr::FinalizeValue(), SpeedMagicXattr::FinalizeValue(), TimeoutMagicXattr::FinalizeValue(), TimeoutDirectMagicXattr::FinalizeValue(), TimestampLastIOErrMagicXattr::FinalizeValue(), UsedFdMagicXattr::FinalizeValue(), UsedDirPMagicXattr::FinalizeValue(), ExternalURLMagicXattr::FinalizeValue(), AuthzMagicXattr::PrepareValueFenced(), CatalogCountersMagicXattr::PrepareValueFenced(), ChunkListMagicXattr::PrepareValueFenced(), ChunksMagicXattr::PrepareValueFenced(), NClgMagicXattr::PrepareValueFenced(), PubkeysMagicXattr::PrepareValueFenced(), RepoCountersMagicXattr::PrepareValueFenced(), RepoMetainfoMagicXattr::PrepareValueFenced(), RevisionMagicXattr::PrepareValueFenced(), RootHashMagicXattr::PrepareValueFenced(), TagMagicXattr::PrepareValueFenced(), PrepareValueFencedProtected(), and MagicXattrManager::Register().


The documentation for this class was generated from the following files: