eden/fs/inodes/test/make_gold_master_overlay.cpp
/**
 * Create a small gold master overlay at the current version (v2) to
 * ensure that our code continues to be able to read it.
 *
 * The given overlayPath should not exist.
 */
Create a small gold master overlay at the current version (v2) to
ensure that our code continues to be able to read it.

The given overlayPath should not exist.
Create a small gold master overlay at the current version ( v2 ) to ensure that our code continues to be able to read it . The given overlayPath should not exist .
void createGoldMasterOverlay(AbsolutePath overlayPath) {
  struct stat overlayStat;
  CHECK_EQ(-1, stat(overlayPath.c_str(), &overlayStat))
      << "given overlay path " << overlayPath << " already exists";
  CHECK_EQ(ENOENT, errno) << "error must be ENOENT";
  Hash hash1{folly::ByteRange{"abcdabcdabcdabcdabcd"_sp}};
  Hash hash2{folly::ByteRange{"01234012340123401234"_sp}};
  Hash hash3{folly::ByteRange{"e0e0e0e0e0e0e0e0e0e0"_sp}};
  Hash hash4{folly::ByteRange{"44444444444444444444"_sp}};
  Overlay overlay{overlayPath};
  auto fileInode = overlay.allocateInodeNumber();
  CHECK_EQ(2_ino, fileInode);
  auto subdirInode = overlay.allocateInodeNumber();
  auto emptyDirInode = overlay.allocateInodeNumber();
  auto helloInode = overlay.allocateInodeNumber();
  DirContents root;
  root.emplace("file"_pc, S_IFREG | 0644, fileInode, hash1);
  root.emplace("subdir"_pc, S_IFDIR | 0755, subdirInode, hash2);
  DirContents subdir;
  subdir.emplace("empty"_pc, S_IFDIR | 0755, emptyDirInode, hash3);
  subdir.emplace("hello"_pc, S_IFREG | 0644, helloInode, hash4);
  DirContents emptyDir;
  overlay.saveOverlayDir(kRootNodeId, root);
  overlay.saveOverlayDir(subdirInode, subdir);
  overlay.saveOverlayDir(emptyDirInode, emptyDir);
  overlay.createOverlayFile(fileInode, folly::ByteRange{"contents"_sp});
  overlay.createOverlayFile(helloInode, folly::ByteRange{"world"_sp});
}
void createGoldMasterOverlay ( AbsolutePath overlayPath ) { struct stat overlayStat ; CHECK_EQ ( -1 , stat ( overlayPath . c_str ( ) , & overlayStat ) ) << " " << overlayPath << " " ; CHECK_EQ ( ENOENT , errno ) << " " ; Hash hash1 { folly :: ByteRange { " " _sp } } ; Hash hash2 { folly :: ByteRange { " " _sp } } ; Hash hash3 { folly :: ByteRange { " " _sp } } ; Hash hash4 { folly :: ByteRange { " " _sp } } ; Overlay overlay { overlayPath } ; auto fileInode = overlay . allocateInodeNumber ( ) ; CHECK_EQ ( 2 _ino , fileInode ) ; auto subdirInode = overlay . allocateInodeNumber ( ) ; auto emptyDirInode = overlay . allocateInodeNumber ( ) ; auto helloInode = overlay . allocateInodeNumber ( ) ; DirContents root ; root . emplace ( " " _pc , S_IFREG | 0644 , fileInode , hash1 ) ; root . emplace ( " " _pc , S_IFDIR | 0755 , subdirInode , hash2 ) ; DirContents subdir ; subdir . emplace ( " " _pc , S_IFDIR | 0755 , emptyDirInode , hash3 ) ; subdir . emplace ( " " _pc , S_IFREG | 0644 , helloInode , hash4 ) ; DirContents emptyDir ; overlay . saveOverlayDir ( kRootNodeId , root ) ; overlay . saveOverlayDir ( subdirInode , subdir ) ; overlay . saveOverlayDir ( emptyDirInode , emptyDir ) ; overlay . createOverlayFile ( fileInode , folly :: ByteRange { " " _sp } ) ; overlay . createOverlayFile ( helloInode , folly :: ByteRange { " " _sp } ) ; }
Create a small gold master overlay at the current version (v2) to
 ensure that our code continues to be able to read it.
Create a small gold master overlay at the current version ( v2 ) to ensure that our code continues to be able to read it .