def _VerifyNumberOfHardLinksInRawDisk(self, tar, filename, count):
    tmp_dir = tempfile.mkdtemp(dir=self.tmp_root)
    tar_cmd = ['tar', '-xzf', tar, '-C', tmp_dir]
    self.assertEqual(subprocess.call(tar_cmd), 0)
    disk_path = os.path.join(tmp_dir, 'disk.raw')
    with utils.LoadDiskImage(disk_path) as devices:
      self.assertEqual(len(devices), 1)
      mnt_dir = tempfile.mkdtemp(dir=self.tmp_root)
      with utils.MountFileSystem(devices[0], mnt_dir, 'ext4'):
        self.assertEqual(os.stat(os.path.join(mnt_dir, filename)).st_nlink,
                         count)
Tests if a file on raw disk has a specified number of hard links.
dataset/ETHPy150Open GoogleCloudPlatform/compute-image-packages/legacy/gcimagebundle/gcimagebundlelib/tests/block_disk_test.py/FsRawDiskTest._VerifyNumberOfHardLinksInRawDisk