eden/fs/inodes/InodeBase.cpp
/**
 * Helper function for getPath() and getLogPath()
 *
 * Populates the names vector with the list of PathComponents from the root
 * down to this inode.
 *
 * This method should not be called on the root inode.  The caller is
 * responsible for checking that before calling getPathHelper().
 *
 * Returns true if the the file exists at the given path, or false if the file
 * has been unlinked.
 *
 * If stopOnUnlinked is true, it breaks immediately when it finds that the file
 * has been unlinked.  The contents of the names vector are then undefined if
 * the function returns false.
 *
 * If stopOnUnlinked is false it continues building the names vector even if
 * the file is unlinked, which will then contain the path that the file used to
 * exist at.  (This path should be used only for logging purposes at that
 * point.)
 */
Helper function for getPath() and getLogPath()
Populates the names vector with the list of PathComponents from the root
down to this inode.

This method should not be called on the root inode.  The caller is
responsible for checking that before calling getPathHelper().

Returns true if the the file exists at the given path, or false if the file
has been unlinked.

If stopOnUnlinked is true, it breaks immediately when it finds that the file
has been unlinked.  The contents of the names vector are then undefined if
the function returns false.

If stopOnUnlinked is false it continues building the names vector even if
the file is unlinked, which will then contain the path that the file used to
exist at.  (This path should be used only for logging purposes at that
point.)
Helper function for getPath () and getLogPath () Populates the names vector with the list of PathComponents from the root down to this inode . This method should not be called on the root inode . The caller is responsible for checking that before calling getPathHelper () . Returns true if the the file exists at the given path or false if the file has been unlinked . If stopOnUnlinked is true it breaks immediately when it finds that the file has been unlinked . The contents of the names vector are then undefined if the function returns false . If stopOnUnlinked is false it continues building the names vector even if the file is unlinked which will then contain the path that the file used to exist at . ( This path should be used only for logging purposes at that point . )
bool InodeBase::getPathHelper(
    std::vector<PathComponent>& names,
    bool stopOnUnlinked) const {
  TreeInodePtr parent;
  bool unlinked = false;
  {
    auto loc = location_.rlock();
    if (loc->unlinked) {
      if (stopOnUnlinked) {
        return false;
      }
      unlinked = true;
    }
    parent = loc->parent;
    DCHECK(parent);
    names.push_back(loc->name);
  }
  while (true) {
    if (parent->ino_ == kRootNodeId) {
      std::reverse(names.begin(), names.end());
      return !unlinked;
    }
    auto loc = parent->location_.rlock();
    if (UNLIKELY(loc->unlinked)) {
      if (stopOnUnlinked) {
        return false;
      }
      unlinked = true;
    }
    names.push_back(loc->name);
    parent = loc->parent;
    DCHECK(parent);
  }
}
bool InodeBase :: getPathHelper ( std :: vector < PathComponent > & names , bool stopOnUnlinked ) const { TreeInodePtr parent ; bool unlinked = false ; { auto loc = location_ . rlock ( ) ; if ( loc -> unlinked ) { if ( stopOnUnlinked ) { return false ; } unlinked = true ; } parent = loc -> parent ; DCHECK ( parent ) ; names . push_back ( loc -> name ) ; } while ( true ) { if ( parent -> ino_ == kRootNodeId ) { std :: reverse ( names . begin ( ) , names . end ( ) ) ; return ! unlinked ; } auto loc = parent -> location_ . rlock ( ) ; if ( UNLIKELY ( loc -> unlinked ) ) { if ( stopOnUnlinked ) { return false ; } unlinked = true ; } names . push_back ( loc -> name ) ; parent = loc -> parent ; DCHECK ( parent ) ; } }
Helper function for getPath() and getLogPath()
 Populates the names vector with the list of PathComponents from the root
 down to this inode.
Helper function for getPath () and getLogPath () Populates the names vector with the list of PathComponents from the root down to this inode .
// Our caller should ensure that we are not the root // Stop at the root inode. // We check for this based on inode number so we can stop without having to // acquire the root inode's location lock.  (Otherwise all path lookups // would have to acquire the root's lock, making it more likely to be // contended.) // Reverse the names vector, since we built it from bottom to top. // In general our parent should not be unlinked if we are not unlinked, // which we checked above.  However, we have since released our location // lock, so it's possible (but unlikely) that someone unlinked us and our // parent directories since we checked above.