ext2fs_group_first_block2:
   30|     16|{
   31|     16|	return fs->super->s_first_data_block +
   32|     16|		EXT2_GROUPS_TO_BLOCKS(fs->super, group);
  ------------------
  |  |  304|     16|#define EXT2_GROUPS_TO_BLOCKS(s, g)   ((blk64_t) EXT2_BLOCKS_PER_GROUP(s) * \
  |  |  ------------------
  |  |  |  |  286|     16|#define EXT2_BLOCKS_PER_GROUP(s)	(EXT2_SB(s)->s_blocks_per_group)
  |  |  |  |  ------------------
  |  |  |  |  |  |   91|     16|#define EXT2_SB(sb)	(sb)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  305|     16|				       (g))
  ------------------
   33|     16|}
ext2fs_blocks_count:
  108|  1.25k|{
  109|  1.25k|	return super->s_blocks_count |
  110|  1.25k|		(ext2fs_has_feature_64bit(super) ?
  ------------------
  |  Branch (110:4): [True: 566, False: 688]
  ------------------
  111|    688|		(__u64) super->s_blocks_count_hi << 32 : 0);
  112|  1.25k|}
ext2fs_group_desc:
  203|    303|{
  204|    303|	struct ext2_group_desc *ret_gdp;
  205|    303|	errcode_t	retval;
  206|    303|	static char	*buf = 0;
  207|    303|	static unsigned	bufsize = 0;
  208|    303|	blk64_t		blk;
  209|    303|	int		desc_size = EXT2_DESC_SIZE(fs->super) & ~7;
  ------------------
  |  |  284|    303|	(ext2fs_has_feature_64bit(s) ? (s)->s_desc_size : EXT2_MIN_DESC_SIZE)
  |  |  ------------------
  |  |  |  |  280|    179|#define EXT2_MIN_DESC_SIZE             32
  |  |  ------------------
  |  |  |  Branch (284:3): [True: 124, False: 179]
  |  |  ------------------
  ------------------
  210|    303|	int		desc_per_blk = EXT2_DESC_PER_BLOCK(fs->super);
  ------------------
  |  |  301|    303|#define EXT2_DESC_PER_BLOCK(s)		(EXT2_BLOCK_SIZE(s) / EXT2_DESC_SIZE(s))
  |  |  ------------------
  |  |  |  |  113|    303|#define EXT2_BLOCK_SIZE(s)	(EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|    303|#define EXT2_MIN_BLOCK_SIZE	(1 << EXT2_MIN_BLOCK_LOG_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  102|    303|#define EXT2_MIN_BLOCK_LOG_SIZE		10	/* 1024 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define EXT2_DESC_PER_BLOCK(s)		(EXT2_BLOCK_SIZE(s) / EXT2_DESC_SIZE(s))
  |  |  ------------------
  |  |  |  |  284|    303|	(ext2fs_has_feature_64bit(s) ? (s)->s_desc_size : EXT2_MIN_DESC_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  280|    179|#define EXT2_MIN_DESC_SIZE             32
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (284:3): [True: 124, False: 179]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  211|       |
  212|    303|	if (group > fs->group_desc_count)
  ------------------
  |  Branch (212:6): [True: 0, False: 303]
  ------------------
  213|      0|		return NULL;
  214|    303|	if (gdp)
  ------------------
  |  Branch (214:6): [True: 303, False: 0]
  ------------------
  215|    303|		return (struct ext2_group_desc *)((char *)gdp +
  216|    303|						  group * desc_size);
  217|       |	/*
  218|       |	 * If fs->group_desc wasn't read in when the file system was
  219|       |	 * opened, then read it on demand here.
  220|       |	 */
  221|      0|	if (bufsize < fs->blocksize)
  ------------------
  |  Branch (221:6): [True: 0, False: 0]
  ------------------
  222|      0|		ext2fs_free_mem(&buf);
  223|      0|	if (!buf) {
  ------------------
  |  Branch (223:6): [True: 0, False: 0]
  ------------------
  224|      0|		retval = ext2fs_get_mem(fs->blocksize, &buf);
  225|      0|		if (retval)
  ------------------
  |  Branch (225:7): [True: 0, False: 0]
  ------------------
  226|      0|			return NULL;
  227|      0|		bufsize = fs->blocksize;
  228|      0|	}
  229|      0|	blk = ext2fs_descriptor_block_loc2(fs, fs->super->s_first_data_block,
  230|      0|					   group / desc_per_blk);
  231|      0|	retval = io_channel_read_blk(fs->io, blk, 1, buf);
  ------------------
  |  |  118|      0|#define io_channel_read_blk(c,b,n,d)	((c)->manager->read_blk((c),b,n,d))
  ------------------
  232|      0|	if (retval)
  ------------------
  |  Branch (232:6): [True: 0, False: 0]
  ------------------
  233|      0|		return NULL;
  234|      0|	ret_gdp = (struct ext2_group_desc *)
  235|      0|		(buf + ((group % desc_per_blk) * desc_size));
  236|       |#ifdef WORDS_BIGENDIAN
  237|       |	ext2fs_swap_group_desc2(fs, ret_gdp);
  238|       |#endif
  239|      0|	return ret_gdp;
  240|      0|}
ext2fs_inode_table_loc:
  336|    303|{
  337|    303|	struct ext4_group_desc *gdp;
  338|       |
  339|    303|	gdp = ext4fs_group_desc(fs, fs->group_desc, group);
  340|    303|	return gdp->bg_inode_table |
  341|    303|		(ext2fs_has_feature_64bit(fs->super) ?
  ------------------
  |  Branch (341:4): [True: 124, False: 179]
  ------------------
  342|    179|		 (__u64) gdp->bg_inode_table_hi << 32 : 0);
  343|    303|}
blknum.c:ext4fs_group_desc:
  246|    303|{
  247|    303|	return (struct ext4_group_desc *)ext2fs_group_desc(fs, gdp, group);
  248|    303|}

ext2fs_bg_has_super:
   37|     16|{
   38|     16|	if (group == 0)
  ------------------
  |  Branch (38:6): [True: 16, False: 0]
  ------------------
   39|     16|		return 1;
   40|      0|	if (ext2fs_has_feature_sparse_super2(fs->super)) {
  ------------------
  |  Branch (40:6): [True: 0, False: 0]
  ------------------
   41|      0|		if (group == fs->super->s_backup_bgs[0] ||
  ------------------
  |  Branch (41:7): [True: 0, False: 0]
  ------------------
   42|      0|		    group == fs->super->s_backup_bgs[1])
  ------------------
  |  Branch (42:7): [True: 0, False: 0]
  ------------------
   43|      0|			return 1;
   44|      0|		return 0;
   45|      0|	}
   46|      0|	if ((group <= 1) || !ext2fs_has_feature_sparse_super(fs->super))
  ------------------
  |  Branch (46:6): [True: 0, False: 0]
  |  Branch (46:22): [True: 0, False: 0]
  ------------------
   47|      0|		return 1;
   48|      0|	if (!(group & 1))
  ------------------
  |  Branch (48:6): [True: 0, False: 0]
  ------------------
   49|      0|		return 0;
   50|      0|	if (test_root(group, 3) || (test_root(group, 5)) ||
  ------------------
  |  Branch (50:6): [True: 0, False: 0]
  |  Branch (50:29): [True: 0, False: 0]
  ------------------
   51|      0|	    test_root(group, 7))
  ------------------
  |  Branch (51:6): [True: 0, False: 0]
  ------------------
   52|      0|		return 1;
   53|       |
   54|      0|	return 0;
   55|      0|}
ext2fs_close:
  479|    303|{
  480|    303|	return ext2fs_close2(fs, 0);
  481|    303|}
ext2fs_close2:
  484|    303|{
  485|    303|	errcode_t	retval;
  486|    303|	int		meta_blks;
  487|    303|	io_stats stats = 0;
  488|       |
  489|    303|	EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
  ------------------
  |  |  697|    303|	  if ((struct)->magic != (code)) return (code)
  |  |  ------------------
  |  |  |  Branch (697:8): [True: 0, False: 303]
  |  |  ------------------
  ------------------
  490|       |
  491|    303|	if (fs->write_bitmaps) {
  ------------------
  |  Branch (491:6): [True: 0, False: 303]
  ------------------
  492|      0|		retval = fs->write_bitmaps(fs);
  493|      0|		if (retval)
  ------------------
  |  Branch (493:7): [True: 0, False: 0]
  ------------------
  494|      0|			return retval;
  495|      0|	}
  496|    303|	if (fs->super->s_kbytes_written &&
  ------------------
  |  Branch (496:6): [True: 165, False: 138]
  ------------------
  497|    303|	    fs->io->manager->get_stats)
  ------------------
  |  Branch (497:6): [True: 165, False: 0]
  ------------------
  498|    165|		fs->io->manager->get_stats(fs->io, &stats);
  499|    303|	if (stats && stats->bytes_written && (fs->flags & EXT2_FLAG_RW)) {
  ------------------
  |  |  195|      0|#define EXT2_FLAG_RW			0x01
  ------------------
  |  Branch (499:6): [True: 165, False: 138]
  |  Branch (499:15): [True: 0, False: 165]
  |  Branch (499:39): [True: 0, False: 0]
  ------------------
  500|      0|		fs->super->s_kbytes_written += stats->bytes_written >> 10;
  501|      0|		meta_blks = fs->desc_blocks + 1;
  502|      0|		if (!(fs->flags & EXT2_FLAG_SUPER_ONLY))
  ------------------
  |  |  206|      0|#define EXT2_FLAG_SUPER_ONLY		0x800
  ------------------
  |  Branch (502:7): [True: 0, False: 0]
  ------------------
  503|      0|			fs->super->s_kbytes_written += meta_blks /
  504|      0|				(fs->blocksize / 1024);
  505|      0|		if ((fs->flags & EXT2_FLAG_DIRTY) == 0)
  ------------------
  |  |  197|      0|#define EXT2_FLAG_DIRTY			0x04
  ------------------
  |  Branch (505:7): [True: 0, False: 0]
  ------------------
  506|      0|			fs->flags |= EXT2_FLAG_SUPER_ONLY | EXT2_FLAG_DIRTY;
  ------------------
  |  |  206|      0|#define EXT2_FLAG_SUPER_ONLY		0x800
  ------------------
              			fs->flags |= EXT2_FLAG_SUPER_ONLY | EXT2_FLAG_DIRTY;
  ------------------
  |  |  197|      0|#define EXT2_FLAG_DIRTY			0x04
  ------------------
  507|      0|	}
  508|    303|	if (fs->flags & EXT2_FLAG_DIRTY) {
  ------------------
  |  |  197|    303|#define EXT2_FLAG_DIRTY			0x04
  ------------------
  |  Branch (508:6): [True: 0, False: 303]
  ------------------
  509|      0|		retval = ext2fs_flush2(fs, flags);
  510|      0|		if (retval)
  ------------------
  |  Branch (510:7): [True: 0, False: 0]
  ------------------
  511|      0|			return retval;
  512|      0|	}
  513|       |
  514|    303|	retval = ext2fs_mmp_stop(fs);
  515|    303|	if (retval)
  ------------------
  |  Branch (515:6): [True: 0, False: 303]
  ------------------
  516|      0|		return retval;
  517|       |
  518|    303|	ext2fs_free(fs);
  519|    303|	return 0;
  520|    303|}

ext2fs_crc32c_le:
  193|    453|{
  194|    453|	return crc32_le_generic(crc, p, len, crc32ctable_le, CRC32C_POLY_LE);
  ------------------
  |  |   14|    453|#define CRC32C_POLY_LE 0x82F63B78
  ------------------
  195|    453|}
crc32c.c:crc32_le_generic:
  156|    453|{
  157|       |#if CRC_LE_BITS == 1
  158|       |	int i;
  159|       |	while (len--) {
  160|       |		crc ^= *p++;
  161|       |		for (i = 0; i < 8; i++)
  162|       |			crc = (crc >> 1) ^ ((crc & 1) ? polynomial : 0);
  163|       |	}
  164|       |# elif CRC_LE_BITS == 2
  165|       |	while (len--) {
  166|       |		crc ^= *p++;
  167|       |		crc = (crc >> 2) ^ tab[0][crc & 3];
  168|       |		crc = (crc >> 2) ^ tab[0][crc & 3];
  169|       |		crc = (crc >> 2) ^ tab[0][crc & 3];
  170|       |		crc = (crc >> 2) ^ tab[0][crc & 3];
  171|       |	}
  172|       |# elif CRC_LE_BITS == 4
  173|       |	while (len--) {
  174|       |		crc ^= *p++;
  175|       |		crc = (crc >> 4) ^ tab[0][crc & 15];
  176|       |		crc = (crc >> 4) ^ tab[0][crc & 15];
  177|       |	}
  178|       |# elif CRC_LE_BITS == 8
  179|       |	/* aka Sarwate algorithm */
  180|       |	while (len--) {
  181|       |		crc ^= *p++;
  182|       |		crc = (crc >> 8) ^ tab[0][crc & 255];
  183|       |	}
  184|       |# else
  185|    453|	crc = __cpu_to_le32(crc);
  ------------------
  |  |   55|    453|#define __cpu_to_le32(x) (x)
  ------------------
  186|    453|	crc = crc32_body(crc, p, len, tab);
  187|    453|	crc = __le32_to_cpu(crc);
  ------------------
  |  |   56|    453|#define __le32_to_cpu(x) (x)
  ------------------
  188|    453|#endif
  189|    453|	return crc;
  190|    453|}
crc32c.c:crc32_body:
   85|    453|{
   86|    453|# ifndef WORDS_BIGENDIAN
   87|    453|#  define DO_CRC(x) (crc = t0[(crc ^ (x)) & 255] ^ (crc >> 8))
   88|    453|#  define DO_CRC4 (t3[(q) & 255] ^ t2[(q >> 8) & 255] ^ \
   89|    453|		   t1[(q >> 16) & 255] ^ t0[(q >> 24) & 255])
   90|    453|#  define DO_CRC8 (t7[(q) & 255] ^ t6[(q >> 8) & 255] ^ \
   91|    453|		   t5[(q >> 16) & 255] ^ t4[(q >> 24) & 255])
   92|       |# else
   93|       |#  define DO_CRC(x) (crc = t0[((crc >> 24) ^ (x)) & 255] ^ (crc << 8))
   94|       |#  define DO_CRC4 (t0[(q) & 255] ^ t1[(q >> 8) & 255] ^ \
   95|       |		   t2[(q >> 16) & 255] ^ t3[(q >> 24) & 255])
   96|       |#  define DO_CRC8 (t4[(q) & 255] ^ t5[(q >> 8) & 255] ^ \
   97|       |		   t6[(q >> 16) & 255] ^ t7[(q >> 24) & 255])
   98|       |# endif
   99|    453|	const uint32_t *b;
  100|    453|	size_t rem_len;
  101|    453|	const uint32_t *t0 = tab[0], *t1 = tab[1], *t2 = tab[2], *t3 = tab[3];
  102|    453|	const uint32_t *t4 = tab[4], *t5 = tab[5], *t6 = tab[6], *t7 = tab[7];
  103|    453|	uint32_t q;
  104|       |
  105|       |	/* Align it */
  106|    453|	if (unlikely((uintptr_t)buf & 3 && len)) {
  ------------------
  |  |   55|    453|#define unlikely(x)	__builtin_expect(!!(x), 0)
  |  |  ------------------
  |  |  |  Branch (55:21): [True: 0, False: 453]
  |  |  |  Branch (55:41): [True: 0, False: 453]
  |  |  |  Branch (55:41): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  107|      0|		do {
  108|      0|			DO_CRC(*buf++);
  ------------------
  |  |   87|      0|#  define DO_CRC(x) (crc = t0[(crc ^ (x)) & 255] ^ (crc >> 8))
  ------------------
  109|      0|		} while ((--len) && ((uintptr_t)buf)&3);
  ------------------
  |  Branch (109:12): [True: 0, False: 0]
  |  Branch (109:23): [True: 0, False: 0]
  ------------------
  110|      0|	}
  111|       |
  112|       |# if CRC_LE_BITS == 32
  113|       |	rem_len = len & 3;
  114|       |	len = len >> 2;
  115|       |# else
  116|    453|	rem_len = len & 7;
  117|    453|	len = len >> 3;
  118|    453|# endif
  119|       |
  120|    453|	b = (const uint32_t *)buf;
  121|  5.99k|	for (--b; len; --len) {
  ------------------
  |  Branch (121:12): [True: 5.54k, False: 453]
  ------------------
  122|  5.54k|		q = crc ^ *++b; /* use pre increment for speed */
  123|       |# if CRC_LE_BITS == 32
  124|       |		crc = DO_CRC4;
  125|       |# else
  126|  5.54k|		crc = DO_CRC8;
  ------------------
  |  |   90|  5.54k|#  define DO_CRC8 (t7[(q) & 255] ^ t6[(q >> 8) & 255] ^ \
  |  |   91|  5.54k|		   t5[(q >> 16) & 255] ^ t4[(q >> 24) & 255])
  ------------------
  127|  5.54k|		q = *++b;
  128|  5.54k|		crc ^= DO_CRC4;
  ------------------
  |  |   88|  5.54k|#  define DO_CRC4 (t3[(q) & 255] ^ t2[(q >> 8) & 255] ^ \
  |  |   89|  5.54k|		   t1[(q >> 16) & 255] ^ t0[(q >> 24) & 255])
  ------------------
  129|  5.54k|# endif
  130|  5.54k|	}
  131|    453|	len = rem_len;
  132|       |	/* And the last few bytes */
  133|    453|	if (len) {
  ------------------
  |  Branch (133:6): [True: 114, False: 339]
  ------------------
  134|    114|		const uint8_t *p = (const uint8_t *)(b + 1) - 1;
  135|    456|		do {
  136|    456|			DO_CRC(*++p); /* use pre increment for speed */
  ------------------
  |  |   87|    456|#  define DO_CRC(x) (crc = t0[(crc ^ (x)) & 255] ^ (crc >> 8))
  ------------------
  137|    456|		} while (--len);
  ------------------
  |  Branch (137:12): [True: 342, False: 114]
  ------------------
  138|    114|	}
  139|    453|	return crc;
  140|    453|#undef DO_CRC
  141|    453|#undef DO_CRC4
  142|    453|#undef DO_CRC8
  143|    453|}

ext2fs_init_csum_seed:
   34|    532|{
   35|    532|	if (ext2fs_has_feature_csum_seed(fs->super))
  ------------------
  |  Branch (35:6): [True: 6, False: 526]
  ------------------
   36|      6|		fs->csum_seed = fs->super->s_checksum_seed;
   37|    526|	else if (ext2fs_has_feature_metadata_csum(fs->super) ||
  ------------------
  |  Branch (37:11): [True: 281, False: 245]
  ------------------
   38|    526|		 ext2fs_has_feature_ea_inode(fs->super))
  ------------------
  |  Branch (38:4): [True: 1, False: 244]
  ------------------
   39|    282|		fs->csum_seed = ext2fs_crc32c_le(~0, fs->super->s_uuid,
   40|    282|						 sizeof(fs->super->s_uuid));
   41|    532|}
ext2fs_inode_csum_verify:
  653|     63|{
  654|     63|	errcode_t retval;
  655|     63|	__u32 provided, calculated;
  656|     63|	unsigned int i, has_hi;
  657|     63|	char *cp;
  658|       |
  659|     63|	if (!ext2fs_has_feature_metadata_csum(fs->super))
  ------------------
  |  Branch (659:6): [True: 6, False: 57]
  ------------------
  660|      6|		return 1;
  661|       |
  662|     57|	has_hi = (EXT2_INODE_SIZE(fs->super) > EXT2_GOOD_OLD_INODE_SIZE &&
  ------------------
  |  |  115|     57|#define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
  |  |  ------------------
  |  |  |  |  796|     57|#define EXT2_GOOD_OLD_REV	0	/* The good old (original) format */
  |  |  ------------------
  |  |  |  Branch (115:29): [True: 18, False: 39]
  |  |  ------------------
  |  |  116|     57|				 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
  |  |  ------------------
  |  |  |  |  802|     18|#define EXT2_GOOD_OLD_INODE_SIZE 128
  |  |  ------------------
  ------------------
              	has_hi = (EXT2_INODE_SIZE(fs->super) > EXT2_GOOD_OLD_INODE_SIZE &&
  ------------------
  |  |  802|    114|#define EXT2_GOOD_OLD_INODE_SIZE 128
  ------------------
  |  Branch (662:12): [True: 38, False: 19]
  ------------------
  663|     57|		  inode->i_extra_isize >= EXT4_INODE_CSUM_HI_EXTRA_END);
  ------------------
  |  |  507|     38|	(offsetof(struct ext2_inode_large, i_checksum_hi) + sizeof(__u16) - \
  |  |  508|     38|	 EXT2_GOOD_OLD_INODE_SIZE)
  |  |  ------------------
  |  |  |  |  802|     38|#define EXT2_GOOD_OLD_INODE_SIZE 128
  |  |  ------------------
  ------------------
  |  Branch (663:5): [True: 30, False: 8]
  ------------------
  664|       |
  665|     57|	provided = ext2fs_le16_to_cpu(inode->i_checksum_lo);
  ------------------
  |  |   33|     57|#define ext2fs_le16_to_cpu(x) ((__force __u16)(__le16)(x))
  ------------------
  666|     57|	retval = ext2fs_inode_csum(fs, inum, inode, &calculated, has_hi);
  667|     57|	if (retval)
  ------------------
  |  Branch (667:6): [True: 0, False: 57]
  ------------------
  668|      0|		return 0;
  669|     57|	if (has_hi) {
  ------------------
  |  Branch (669:6): [True: 30, False: 27]
  ------------------
  670|     30|		__u32 hi = ext2fs_le16_to_cpu(inode->i_checksum_hi);
  ------------------
  |  |   33|     30|#define ext2fs_le16_to_cpu(x) ((__force __u16)(__le16)(x))
  ------------------
  671|     30|		provided |= hi << 16;
  672|     30|	} else
  673|     27|		calculated &= 0xFFFF;
  674|       |
  675|     57|	if (provided == calculated)
  ------------------
  |  Branch (675:6): [True: 2, False: 55]
  ------------------
  676|      2|		return 1;
  677|       |
  678|       |	/*
  679|       |	 * If the checksum didn't match, it's possible it was due to
  680|       |	 * the inode being all zero's.  It's unlikely this is the
  681|       |	 * case, but it can happen.  So check for it here.  (We only
  682|       |	 * check the base inode since that's good enough, and it's not
  683|       |	 * worth the bother to figure out how much of the extended
  684|       |	 * inode, if any, is present.)
  685|       |	 */
  686|     55|	for (cp = (char *) inode, i = 0;
  687|    717|	     i < sizeof(struct ext2_inode);
  ------------------
  |  Branch (687:7): [True: 715, False: 2]
  ------------------
  688|    662|	     cp++, i++)
  689|    715|		if (*cp)
  ------------------
  |  Branch (689:7): [True: 53, False: 662]
  ------------------
  690|     53|			return 0;
  691|      2|	return 1;		/* Inode must have been all zero's */
  692|     55|}
csum.c:ext2fs_inode_csum:
  624|     57|{
  625|     57|	__u32 gen;
  626|     57|	struct ext2_inode_large *desc = inode;
  627|     57|	size_t size = EXT2_INODE_SIZE(fs->super);
  ------------------
  |  |  115|     57|#define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
  |  |  ------------------
  |  |  |  |  796|     57|#define EXT2_GOOD_OLD_REV	0	/* The good old (original) format */
  |  |  ------------------
  |  |  |  Branch (115:29): [True: 18, False: 39]
  |  |  ------------------
  |  |  116|     57|				 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
  |  |  ------------------
  |  |  |  |  802|     18|#define EXT2_GOOD_OLD_INODE_SIZE 128
  |  |  ------------------
  ------------------
  628|     57|	__u16 old_lo;
  629|     57|	__u16 old_hi = 0;
  630|       |
  631|     57|	old_lo = inode->i_checksum_lo;
  ------------------
  |  |  513|     57|#define i_checksum_lo	osd2.linux2.l_i_checksum_lo
  ------------------
  632|     57|	inode->i_checksum_lo = 0;
  ------------------
  |  |  513|     57|#define i_checksum_lo	osd2.linux2.l_i_checksum_lo
  ------------------
  633|     57|	if (has_hi) {
  ------------------
  |  Branch (633:6): [True: 30, False: 27]
  ------------------
  634|     30|		old_hi = inode->i_checksum_hi;
  635|     30|		inode->i_checksum_hi = 0;
  636|     30|	}
  637|       |
  638|     57|	inum = ext2fs_cpu_to_le32(inum);
  ------------------
  |  |   30|     57|#define ext2fs_cpu_to_le32(x) ((__force __le32)(__u32)(x))
  ------------------
  639|     57|	gen = inode->i_generation;
  640|     57|	*crc = ext2fs_crc32c_le(fs->csum_seed, (unsigned char *)&inum,
  641|     57|				sizeof(inum));
  642|     57|	*crc = ext2fs_crc32c_le(*crc, (unsigned char *)&gen, sizeof(gen));
  643|     57|	*crc = ext2fs_crc32c_le(*crc, (unsigned char *)desc, size);
  644|       |
  645|     57|	inode->i_checksum_lo = old_lo;
  ------------------
  |  |  513|     57|#define i_checksum_lo	osd2.linux2.l_i_checksum_lo
  ------------------
  646|     57|	if (has_hi)
  ------------------
  |  Branch (646:6): [True: 30, False: 27]
  ------------------
  647|     30|		inode->i_checksum_hi = old_hi;
  648|     57|	return 0;
  649|     57|}

csum.c:ext2fs_has_feature_csum_seed:
  909|    532|static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
  910|    532|{ \
  911|    532|	return ((EXT2_SB(sb)->s_feature_incompat & \
  ------------------
  |  |   91|    532|#define EXT2_SB(sb)	(sb)
  ------------------
  912|    532|		 EXT##ver##_FEATURE_INCOMPAT_##flagname) != 0); \
  913|    532|} \
csum.c:ext2fs_has_feature_metadata_csum:
  892|    589|static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
  893|    589|{ \
  894|    589|	return ((EXT2_SB(sb)->s_feature_ro_compat & \
  ------------------
  |  |   91|    589|#define EXT2_SB(sb)	(sb)
  ------------------
  895|    589|		 EXT##ver##_FEATURE_RO_COMPAT_##flagname) != 0); \
  896|    589|} \
csum.c:ext2fs_has_feature_ea_inode:
  909|    245|static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
  910|    245|{ \
  911|    245|	return ((EXT2_SB(sb)->s_feature_incompat & \
  ------------------
  |  |   91|    245|#define EXT2_SB(sb)	(sb)
  ------------------
  912|    245|		 EXT##ver##_FEATURE_INCOMPAT_##flagname) != 0); \
  913|    245|} \
inode.c:ext2fs_has_feature_journal_dev:
  909|    303|static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
  910|    303|{ \
  911|    303|	return ((EXT2_SB(sb)->s_feature_incompat & \
  ------------------
  |  |   91|    303|#define EXT2_SB(sb)	(sb)
  ------------------
  912|    303|		 EXT##ver##_FEATURE_INCOMPAT_##flagname) != 0); \
  913|    303|} \
mmp.c:ext2fs_has_feature_mmp:
  909|    303|static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
  910|    303|{ \
  911|    303|	return ((EXT2_SB(sb)->s_feature_incompat & \
  ------------------
  |  |   91|    303|#define EXT2_SB(sb)	(sb)
  ------------------
  912|    303|		 EXT##ver##_FEATURE_INCOMPAT_##flagname) != 0); \
  913|    303|} \
openfs.c:ext2fs_has_feature_meta_bg:
  909|    693|static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
  910|    693|{ \
  911|    693|	return ((EXT2_SB(sb)->s_feature_incompat & \
  ------------------
  |  |   91|    693|#define EXT2_SB(sb)	(sb)
  ------------------
  912|    693|		 EXT##ver##_FEATURE_INCOMPAT_##flagname) != 0); \
  913|    693|} \
openfs.c:ext2fs_has_feature_64bit:
  909|  1.47k|static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
  910|  1.47k|{ \
  911|  1.47k|	return ((EXT2_SB(sb)->s_feature_incompat & \
  ------------------
  |  |   91|  1.47k|#define EXT2_SB(sb)	(sb)
  ------------------
  912|  1.47k|		 EXT##ver##_FEATURE_INCOMPAT_##flagname) != 0); \
  913|  1.47k|} \
openfs.c:ext2fs_has_feature_journal_dev:
  909|  1.23k|static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
  910|  1.23k|{ \
  911|  1.23k|	return ((EXT2_SB(sb)->s_feature_incompat & \
  ------------------
  |  |   91|  1.23k|#define EXT2_SB(sb)	(sb)
  ------------------
  912|  1.23k|		 EXT##ver##_FEATURE_INCOMPAT_##flagname) != 0); \
  913|  1.23k|} \
openfs.c:ext2fs_has_feature_bigalloc:
  892|  1.27k|static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
  893|  1.27k|{ \
  894|  1.27k|	return ((EXT2_SB(sb)->s_feature_ro_compat & \
  ------------------
  |  |   91|  1.27k|#define EXT2_SB(sb)	(sb)
  ------------------
  895|  1.27k|		 EXT##ver##_FEATURE_RO_COMPAT_##flagname) != 0); \
  896|  1.27k|} \
openfs.c:ext2fs_has_feature_mmp:
  909|    303|static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
  910|    303|{ \
  911|    303|	return ((EXT2_SB(sb)->s_feature_incompat & \
  ------------------
  |  |   91|    303|#define EXT2_SB(sb)	(sb)
  ------------------
  912|    303|		 EXT##ver##_FEATURE_INCOMPAT_##flagname) != 0); \
  913|    303|} \
openfs.c:ext2fs_has_feature_casefold:
  909|    303|static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
  910|    303|{ \
  911|    303|	return ((EXT2_SB(sb)->s_feature_incompat & \
  ------------------
  |  |   91|    303|#define EXT2_SB(sb)	(sb)
  ------------------
  912|    303|		 EXT##ver##_FEATURE_INCOMPAT_##flagname) != 0); \
  913|    303|} \
blknum.c:ext2fs_has_feature_64bit:
  909|  2.16k|static inline int ext2fs_has_feature_##name(struct ext2_super_block *sb) \
  910|  2.16k|{ \
  911|  2.16k|	return ((EXT2_SB(sb)->s_feature_incompat & \
  ------------------
  |  |   91|  2.16k|#define EXT2_SB(sb)	(sb)
  ------------------
  912|  2.16k|		 EXT##ver##_FEATURE_INCOMPAT_##flagname) != 0); \
  913|  2.16k|} \

ext2fs_get_mem:
 1996|  14.4k|{
 1997|  14.4k|	void *pp;
 1998|       |
 1999|  14.4k|	pp = malloc(size);
 2000|  14.4k|	if (!pp)
  ------------------
  |  Branch (2000:6): [True: 0, False: 14.4k]
  ------------------
 2001|      0|		return EXT2_ET_NO_MEMORY;
  ------------------
  |  |   78|      0|#define EXT2_ET_NO_MEMORY                        (2133571398L)
  ------------------
 2002|  14.4k|	memcpy(ptr, &pp, sizeof (pp));
 2003|  14.4k|	return 0;
 2004|  14.4k|}
ext2fs_get_array:
 2020|    628|{
 2021|    628|	if (count && (~0UL)/count < size)
  ------------------
  |  Branch (2021:6): [True: 628, False: 0]
  |  Branch (2021:15): [True: 0, False: 628]
  ------------------
 2022|      0|		return EXT2_ET_NO_MEMORY;
  ------------------
  |  |   78|      0|#define EXT2_ET_NO_MEMORY                        (2133571398L)
  ------------------
 2023|    628|	return ext2fs_get_mem(count*size, ptr);
 2024|    628|}
ext2fs_free_mem:
 2039|  14.4k|{
 2040|  14.4k|	void *p;
 2041|       |
 2042|  14.4k|	memcpy(&p, ptr, sizeof(p));
 2043|  14.4k|	free(p);
 2044|  14.4k|	p = 0;
 2045|  14.4k|	memcpy(ptr, &p, sizeof(p));
 2046|  14.4k|	return 0;
 2047|  14.4k|}
ext2fs_div_ceil:
 2230|    352|{
 2231|    352|	if (!a)
  ------------------
  |  Branch (2231:6): [True: 0, False: 352]
  ------------------
 2232|      0|		return 0;
 2233|    352|	return ((a - 1) / b) + 1;
 2234|    352|}
ext2fs_div64_ceil:
 2237|    498|{
 2238|    498|	if (!a)
  ------------------
  |  Branch (2238:6): [True: 0, False: 498]
  ------------------
 2239|      0|		return 0;
 2240|    498|	return ((a - 1) / b) + 1;
 2241|    498|}

unix_io.c:ext2fsP_is_disk_device:
   21|    797|{
   22|       |#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
   23|       |	return S_ISBLK(mode) || S_ISCHR(mode);
   24|       |#else
   25|    797|	return S_ISBLK(mode);
   26|    797|#endif
   27|    797|}

ext2fs_free:
   23|    797|{
   24|    797|	if (!fs || (fs->magic != EXT2_ET_MAGIC_EXT2FS_FILSYS))
  ------------------
  |  |    9|    797|#define EXT2_ET_MAGIC_EXT2FS_FILSYS              (2133571329L)
  ------------------
  |  Branch (24:6): [True: 0, False: 797]
  |  Branch (24:13): [True: 0, False: 797]
  ------------------
   25|      0|		return;
   26|    797|	if (fs->image_io != fs->io) {
  ------------------
  |  Branch (26:6): [True: 0, False: 797]
  ------------------
   27|      0|		if (fs->image_io)
  ------------------
  |  Branch (27:7): [True: 0, False: 0]
  ------------------
   28|      0|			io_channel_close(fs->image_io);
  ------------------
  |  |  116|      0|#define io_channel_close(c) 		((c)->manager->close((c)))
  ------------------
   29|      0|	}
   30|    797|	if (fs->io) {
  ------------------
  |  Branch (30:6): [True: 797, False: 0]
  ------------------
   31|    797|		io_channel_close(fs->io);
  ------------------
  |  |  116|    797|#define io_channel_close(c) 		((c)->manager->close((c)))
  ------------------
   32|    797|	}
   33|    797|	if (fs->device_name)
  ------------------
  |  Branch (33:6): [True: 797, False: 0]
  ------------------
   34|    797|		ext2fs_free_mem(&fs->device_name);
   35|    797|	if (fs->super)
  ------------------
  |  Branch (35:6): [True: 797, False: 0]
  ------------------
   36|    797|		ext2fs_free_mem(&fs->super);
   37|    797|	if (fs->orig_super)
  ------------------
  |  Branch (37:6): [True: 797, False: 0]
  ------------------
   38|    797|		ext2fs_free_mem(&fs->orig_super);
   39|    797|	if (fs->group_desc)
  ------------------
  |  Branch (39:6): [True: 325, False: 472]
  ------------------
   40|    325|		ext2fs_free_mem(&fs->group_desc);
   41|    797|	if (fs->block_map)
  ------------------
  |  Branch (41:6): [True: 0, False: 797]
  ------------------
   42|      0|		ext2fs_free_block_bitmap(fs->block_map);
   43|    797|	if (fs->inode_map)
  ------------------
  |  Branch (43:6): [True: 0, False: 797]
  ------------------
   44|      0|		ext2fs_free_inode_bitmap(fs->inode_map);
   45|    797|	if (fs->image_header)
  ------------------
  |  Branch (45:6): [True: 0, False: 797]
  ------------------
   46|      0|		ext2fs_free_mem(&fs->image_header);
   47|       |
   48|    797|	if (fs->badblocks)
  ------------------
  |  Branch (48:6): [True: 0, False: 797]
  ------------------
   49|      0|		ext2fs_badblocks_list_free(fs->badblocks);
   50|    797|	fs->badblocks = 0;
   51|       |
   52|    797|	if (fs->dblist)
  ------------------
  |  Branch (52:6): [True: 0, False: 797]
  ------------------
   53|      0|		ext2fs_free_dblist(fs->dblist);
   54|       |
   55|    797|	if (fs->icache)
  ------------------
  |  Branch (55:6): [True: 303, False: 494]
  ------------------
   56|    303|		ext2fs_free_inode_cache(fs->icache);
   57|       |
   58|    797|	if (fs->mmp_buf)
  ------------------
  |  Branch (58:6): [True: 0, False: 797]
  ------------------
   59|      0|		ext2fs_free_mem(&fs->mmp_buf);
   60|    797|	if (fs->mmp_cmp)
  ------------------
  |  Branch (60:6): [True: 0, False: 797]
  ------------------
   61|      0|		ext2fs_free_mem(&fs->mmp_cmp);
   62|       |
   63|    797|	if (fs->block_sha_map)
  ------------------
  |  Branch (63:6): [True: 0, False: 797]
  ------------------
   64|      0|		ext2fs_hashmap_free(fs->block_sha_map);
   65|       |
   66|    797|	fs->magic = 0;
   67|       |
   68|    797|	ext2fs_zero_blocks2(NULL, 0, 0, NULL, NULL);
   69|    797|	ext2fs_free_mem(&fs);
   70|    797|}

ext2fs_safe_getenv:
   37|  3.18k|{
   38|  3.18k|	if ((getuid() != geteuid()) || (getgid() != getegid()))
  ------------------
  |  Branch (38:6): [True: 0, False: 3.18k]
  |  Branch (38:33): [True: 0, False: 3.18k]
  ------------------
   39|      0|		return NULL;
   40|  3.18k|#ifdef HAVE_PRCTL
   41|  3.18k|	if (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) == 0)
  ------------------
  |  Branch (41:6): [True: 0, False: 3.18k]
  ------------------
   42|      0|		return NULL;
   43|       |#else
   44|       |#if (defined(linux) && defined(SYS_prctl))
   45|       |	if (syscall(SYS_prctl, PR_GET_DUMPABLE, 0, 0, 0, 0) == 0)
   46|       |		return NULL;
   47|       |#endif
   48|       |#endif
   49|       |
   50|  3.18k|#if defined(HAVE_SECURE_GETENV)
   51|  3.18k|	return secure_getenv(arg);
   52|       |#elif defined(HAVE___SECURE_GETENV)
   53|       |	return __secure_getenv(arg);
   54|       |#else
   55|       |	return getenv(arg);
   56|       |#endif
   57|  3.18k|}

ext2fs_flush_icache:
   66|    303|{
   67|    303|	unsigned	i;
   68|       |
   69|    303|	if (!fs->icache)
  ------------------
  |  Branch (69:6): [True: 0, False: 303]
  ------------------
   70|      0|		return 0;
   71|       |
   72|  1.51k|	for (i=0; i < fs->icache->cache_size; i++)
  ------------------
  |  Branch (72:12): [True: 1.21k, False: 303]
  ------------------
   73|  1.21k|		fs->icache->cache[i].ino = 0;
   74|       |
   75|    303|	fs->icache->buffer_blk = 0;
   76|    303|	return 0;
   77|    303|}
ext2fs_free_inode_cache:
   83|    303|{
   84|    303|	unsigned i;
   85|       |
   86|    303|	if (--icache->refcount)
  ------------------
  |  Branch (86:6): [True: 0, False: 303]
  ------------------
   87|      0|		return;
   88|    303|	if (icache->buffer)
  ------------------
  |  Branch (88:6): [True: 303, False: 0]
  ------------------
   89|    303|		ext2fs_free_mem(&icache->buffer);
   90|  1.51k|	for (i = 0; i < icache->cache_size; i++)
  ------------------
  |  Branch (90:14): [True: 1.21k, False: 303]
  ------------------
   91|  1.21k|		ext2fs_free_mem(&icache->cache[i].inode);
   92|    303|	if (icache->cache)
  ------------------
  |  Branch (92:6): [True: 303, False: 0]
  ------------------
   93|    303|		ext2fs_free_mem(&icache->cache);
   94|    303|	icache->buffer_blk = 0;
   95|    303|	ext2fs_free_mem(&icache);
   96|    303|}
ext2fs_create_inode_cache:
   99|    303|{
  100|    303|	unsigned	i;
  101|    303|	errcode_t	retval;
  102|       |
  103|    303|	if (fs->icache)
  ------------------
  |  Branch (103:6): [True: 0, False: 303]
  ------------------
  104|      0|		return 0;
  105|    303|	retval = ext2fs_get_mem(sizeof(struct ext2_inode_cache), &fs->icache);
  106|    303|	if (retval)
  ------------------
  |  Branch (106:6): [True: 0, False: 303]
  ------------------
  107|      0|		return retval;
  108|       |
  109|    303|	memset(fs->icache, 0, sizeof(struct ext2_inode_cache));
  110|    303|	retval = ext2fs_get_mem(fs->blocksize, &fs->icache->buffer);
  111|    303|	if (retval)
  ------------------
  |  Branch (111:6): [True: 0, False: 303]
  ------------------
  112|      0|		goto errout;
  113|       |
  114|    303|	fs->icache->buffer_blk = 0;
  115|    303|	fs->icache->cache_last = -1;
  116|    303|	fs->icache->cache_size = cache_size;
  117|    303|	fs->icache->refcount = 1;
  118|    303|	retval = ext2fs_get_array(fs->icache->cache_size,
  119|    303|				  sizeof(struct ext2_inode_cache_ent),
  120|    303|				  &fs->icache->cache);
  121|    303|	if (retval)
  ------------------
  |  Branch (121:6): [True: 0, False: 303]
  ------------------
  122|      0|		goto errout;
  123|       |
  124|  1.51k|	for (i = 0; i < fs->icache->cache_size; i++) {
  ------------------
  |  Branch (124:14): [True: 1.21k, False: 303]
  ------------------
  125|  1.21k|		retval = ext2fs_get_mem(EXT2_INODE_SIZE(fs->super),
  ------------------
  |  |  115|  1.21k|#define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
  |  |  ------------------
  |  |  |  |  796|  1.21k|#define EXT2_GOOD_OLD_REV	0	/* The good old (original) format */
  |  |  ------------------
  |  |  |  Branch (115:29): [True: 996, False: 216]
  |  |  ------------------
  |  |  116|  1.21k|				 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
  |  |  ------------------
  |  |  |  |  802|    996|#define EXT2_GOOD_OLD_INODE_SIZE 128
  |  |  ------------------
  ------------------
  126|  1.21k|					&fs->icache->cache[i].inode);
  127|  1.21k|		if (retval)
  ------------------
  |  Branch (127:7): [True: 0, False: 1.21k]
  ------------------
  128|      0|			goto errout;
  129|  1.21k|	}
  130|       |
  131|    303|	ext2fs_flush_icache(fs);
  132|    303|	return 0;
  133|      0|errout:
  134|      0|	ext2fs_free_inode_cache(fs->icache);
  135|      0|	fs->icache = 0;
  136|      0|	return retval;
  137|    303|}
ext2fs_read_inode2:
  759|    303|{
  760|    303|	blk64_t		block_nr;
  761|    303|	dgrp_t		group;
  762|    303|	unsigned long 	block, offset;
  763|    303|	char 		*ptr;
  764|    303|	errcode_t	retval;
  765|    303|	unsigned	i;
  766|    303|	int		clen, inodes_per_block;
  767|    303|	io_channel	io;
  768|    303|	int		length = EXT2_INODE_SIZE(fs->super);
  ------------------
  |  |  115|    303|#define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
  |  |  ------------------
  |  |  |  |  796|    303|#define EXT2_GOOD_OLD_REV	0	/* The good old (original) format */
  |  |  ------------------
  |  |  |  Branch (115:29): [True: 249, False: 54]
  |  |  ------------------
  |  |  116|    303|				 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
  |  |  ------------------
  |  |  |  |  802|    249|#define EXT2_GOOD_OLD_INODE_SIZE 128
  |  |  ------------------
  ------------------
  769|    303|	struct ext2_inode_large	*iptr;
  770|    303|	int		cache_slot, fail_csum;
  771|       |
  772|    303|	EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
  ------------------
  |  |  697|    303|	  if ((struct)->magic != (code)) return (code)
  |  |  ------------------
  |  |  |  Branch (697:8): [True: 0, False: 303]
  |  |  ------------------
  ------------------
  773|       |
  774|    303|	if (ext2fs_has_feature_journal_dev(fs->super))
  ------------------
  |  Branch (774:6): [True: 0, False: 303]
  ------------------
  775|      0|		return EXT2_ET_EXTERNAL_JOURNAL_NOSUPP;
  ------------------
  |  |  190|      0|#define EXT2_ET_EXTERNAL_JOURNAL_NOSUPP          (2133571510L)
  ------------------
  776|       |
  777|    303|	if (fs->blocksize < 1024)
  ------------------
  |  Branch (777:6): [True: 0, False: 303]
  ------------------
  778|      0|		return EXT2_FILSYS_CORRUPTED; /* Should never happen */
  ------------------
  |  |  188|      0|#define EXT2_FILSYS_CORRUPTED                    (2133571508L)
  ------------------
  779|       |
  780|       |	/* Check to see if user has an override function */
  781|    303|	if (fs->read_inode &&
  ------------------
  |  Branch (781:6): [True: 0, False: 303]
  ------------------
  782|    303|	    ((bufsize == sizeof(struct ext2_inode)) ||
  ------------------
  |  Branch (782:7): [True: 0, False: 0]
  ------------------
  783|      0|	     (EXT2_INODE_SIZE(fs->super) == sizeof(struct ext2_inode)))) {
  ------------------
  |  |  115|      0|#define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
  |  |  ------------------
  |  |  |  |  796|      0|#define EXT2_GOOD_OLD_REV	0	/* The good old (original) format */
  |  |  ------------------
  |  |  |  Branch (115:29): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|				 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
  |  |  ------------------
  |  |  |  |  802|      0|#define EXT2_GOOD_OLD_INODE_SIZE 128
  |  |  ------------------
  ------------------
  |  Branch (783:7): [True: 0, False: 0]
  ------------------
  784|      0|		retval = (fs->read_inode)(fs, ino, inode);
  785|      0|		if (retval != EXT2_ET_CALLBACK_NOTHANDLED)
  ------------------
  |  |   73|      0|#define EXT2_ET_CALLBACK_NOTHANDLED              (2133571393L)
  ------------------
  |  Branch (785:7): [True: 0, False: 0]
  ------------------
  786|      0|			return retval;
  787|      0|	}
  788|    303|	if ((ino == 0) || (ino > fs->super->s_inodes_count))
  ------------------
  |  Branch (788:6): [True: 0, False: 303]
  |  Branch (788:20): [True: 0, False: 303]
  ------------------
  789|      0|		return EXT2_ET_BAD_INODE_NUM;
  ------------------
  |  |   49|      0|#define EXT2_ET_BAD_INODE_NUM                    (2133571369L)
  ------------------
  790|       |	/* Create inode cache if not present */
  791|    303|	if (!fs->icache) {
  ------------------
  |  Branch (791:6): [True: 303, False: 0]
  ------------------
  792|    303|		retval = ext2fs_create_inode_cache(fs, 4);
  793|    303|		if (retval)
  ------------------
  |  Branch (793:7): [True: 0, False: 303]
  ------------------
  794|      0|			return retval;
  795|    303|	}
  796|       |	/* Check to see if it's in the inode cache */
  797|  1.51k|	for (i = 0; i < fs->icache->cache_size; i++) {
  ------------------
  |  Branch (797:14): [True: 1.21k, False: 303]
  ------------------
  798|  1.21k|		if (fs->icache->cache[i].ino == ino) {
  ------------------
  |  Branch (798:7): [True: 0, False: 1.21k]
  ------------------
  799|      0|			memcpy(inode, fs->icache->cache[i].inode,
  800|      0|			       (bufsize > length) ? length : bufsize);
  ------------------
  |  Branch (800:11): [True: 0, False: 0]
  ------------------
  801|      0|			return 0;
  802|      0|		}
  803|  1.21k|	}
  804|    303|	if (fs->flags & EXT2_FLAG_IMAGE_FILE) {
  ------------------
  |  |  208|    303|#define EXT2_FLAG_IMAGE_FILE		0x2000
  ------------------
  |  Branch (804:6): [True: 0, False: 303]
  ------------------
  805|      0|		inodes_per_block = fs->blocksize / EXT2_INODE_SIZE(fs->super);
  ------------------
  |  |  115|      0|#define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
  |  |  ------------------
  |  |  |  |  796|      0|#define EXT2_GOOD_OLD_REV	0	/* The good old (original) format */
  |  |  ------------------
  |  |  |  Branch (115:29): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|				 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
  |  |  ------------------
  |  |  |  |  802|      0|#define EXT2_GOOD_OLD_INODE_SIZE 128
  |  |  ------------------
  ------------------
  806|      0|		block_nr = ext2fs_le32_to_cpu(fs->image_header->offset_inode) / fs->blocksize;
  ------------------
  |  |   31|      0|#define ext2fs_le32_to_cpu(x) ((__force __u32)(__le32)(x))
  ------------------
  807|      0|		block_nr += (ino - 1) / inodes_per_block;
  808|      0|		offset = ((ino - 1) % inodes_per_block) *
  809|      0|			EXT2_INODE_SIZE(fs->super);
  ------------------
  |  |  115|      0|#define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
  |  |  ------------------
  |  |  |  |  796|      0|#define EXT2_GOOD_OLD_REV	0	/* The good old (original) format */
  |  |  ------------------
  |  |  |  Branch (115:29): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|				 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
  |  |  ------------------
  |  |  |  |  802|      0|#define EXT2_GOOD_OLD_INODE_SIZE 128
  |  |  ------------------
  ------------------
  810|      0|		io = fs->image_io;
  811|    303|	} else {
  812|    303|		group = (ino - 1) / EXT2_INODES_PER_GROUP(fs->super);
  ------------------
  |  |  287|    303|#define EXT2_INODES_PER_GROUP(s)	(EXT2_SB(s)->s_inodes_per_group)
  |  |  ------------------
  |  |  |  |   91|    303|#define EXT2_SB(sb)	(sb)
  |  |  ------------------
  ------------------
  813|    303|		if (group > fs->group_desc_count)
  ------------------
  |  Branch (813:7): [True: 0, False: 303]
  ------------------
  814|      0|			return EXT2_ET_BAD_INODE_NUM;
  ------------------
  |  |   49|      0|#define EXT2_ET_BAD_INODE_NUM                    (2133571369L)
  ------------------
  815|    303|		offset = ((ino - 1) % EXT2_INODES_PER_GROUP(fs->super)) *
  ------------------
  |  |  287|    303|#define EXT2_INODES_PER_GROUP(s)	(EXT2_SB(s)->s_inodes_per_group)
  |  |  ------------------
  |  |  |  |   91|    303|#define EXT2_SB(sb)	(sb)
  |  |  ------------------
  ------------------
  816|    303|			EXT2_INODE_SIZE(fs->super);
  ------------------
  |  |  115|    303|#define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
  |  |  ------------------
  |  |  |  |  796|    303|#define EXT2_GOOD_OLD_REV	0	/* The good old (original) format */
  |  |  ------------------
  |  |  |  Branch (115:29): [True: 249, False: 54]
  |  |  ------------------
  |  |  116|    303|				 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
  |  |  ------------------
  |  |  |  |  802|    249|#define EXT2_GOOD_OLD_INODE_SIZE 128
  |  |  ------------------
  ------------------
  817|    303|		block = offset >> EXT2_BLOCK_SIZE_BITS(fs->super);
  ------------------
  |  |  114|    303|#define EXT2_BLOCK_SIZE_BITS(s)	((s)->s_log_block_size + 10)
  ------------------
  818|    303|		block_nr = ext2fs_inode_table_loc(fs, group);
  819|    303|		if (!block_nr)
  ------------------
  |  Branch (819:7): [True: 47, False: 256]
  ------------------
  820|     47|			return EXT2_ET_MISSING_INODE_TABLE;
  ------------------
  |  |   67|     47|#define EXT2_ET_MISSING_INODE_TABLE              (2133571387L)
  ------------------
  821|    256|		if ((block_nr < fs->super->s_first_data_block) ||
  ------------------
  |  Branch (821:7): [True: 1, False: 255]
  ------------------
  822|    256|		    (block_nr + fs->inode_blocks_per_group - 1 >=
  ------------------
  |  Branch (822:7): [True: 168, False: 87]
  ------------------
  823|    255|		     ext2fs_blocks_count(fs->super)))
  824|    169|			return EXT2_ET_GDESC_BAD_INODE_TABLE;
  ------------------
  |  |   34|    169|#define EXT2_ET_GDESC_BAD_INODE_TABLE            (2133571354L)
  ------------------
  825|     87|		block_nr += block;
  826|     87|		io = fs->io;
  827|     87|	}
  828|     87|	offset &= (EXT2_BLOCK_SIZE(fs->super) - 1);
  ------------------
  |  |  113|     87|#define EXT2_BLOCK_SIZE(s)	(EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  |  |  ------------------
  |  |  |  |  104|     87|#define EXT2_MIN_BLOCK_SIZE	(1 << EXT2_MIN_BLOCK_LOG_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  102|     87|#define EXT2_MIN_BLOCK_LOG_SIZE		10	/* 1024 */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  829|       |
  830|     87|	cache_slot = (fs->icache->cache_last + 1) % fs->icache->cache_size;
  831|     87|	iptr = (struct ext2_inode_large *)fs->icache->cache[cache_slot].inode;
  832|       |
  833|     87|	ptr = (char *) iptr;
  834|    150|	while (length) {
  ------------------
  |  Branch (834:9): [True: 87, False: 63]
  ------------------
  835|     87|		clen = length;
  836|     87|		if ((offset + length) > fs->blocksize)
  ------------------
  |  Branch (836:7): [True: 0, False: 87]
  ------------------
  837|      0|			clen = fs->blocksize - offset;
  838|       |
  839|     87|		if (block_nr != fs->icache->buffer_blk) {
  ------------------
  |  Branch (839:7): [True: 87, False: 0]
  ------------------
  840|     87|			retval = io_channel_read_blk64(io, block_nr, 1,
  841|     87|						     fs->icache->buffer);
  842|     87|			if (retval)
  ------------------
  |  Branch (842:8): [True: 24, False: 63]
  ------------------
  843|     24|				return retval;
  844|     63|			fs->icache->buffer_blk = block_nr;
  845|     63|		}
  846|       |
  847|     63|		memcpy(ptr, ((char *) fs->icache->buffer) + (unsigned) offset,
  848|     63|		       clen);
  849|       |
  850|     63|		offset = 0;
  851|     63|		length -= clen;
  852|     63|		ptr += clen;
  853|     63|		block_nr++;
  854|     63|	}
  855|     63|	length = EXT2_INODE_SIZE(fs->super);
  ------------------
  |  |  115|     63|#define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
  |  |  ------------------
  |  |  |  |  796|     63|#define EXT2_GOOD_OLD_REV	0	/* The good old (original) format */
  |  |  ------------------
  |  |  |  Branch (115:29): [True: 21, False: 42]
  |  |  ------------------
  |  |  116|     63|				 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
  |  |  ------------------
  |  |  |  |  802|     21|#define EXT2_GOOD_OLD_INODE_SIZE 128
  |  |  ------------------
  ------------------
  856|       |
  857|       |	/* Verify the inode checksum. */
  858|     63|	fail_csum = !ext2fs_inode_csum_verify(fs, ino, iptr);
  859|       |
  860|       |#ifdef WORDS_BIGENDIAN
  861|       |	ext2fs_swap_inode_full(fs, (struct ext2_inode_large *) iptr,
  862|       |			       (struct ext2_inode_large *) iptr,
  863|       |			       0, length);
  864|       |#endif
  865|       |
  866|       |	/* Update the inode cache bookkeeping */
  867|     63|	if (!fail_csum) {
  ------------------
  |  Branch (867:6): [True: 10, False: 53]
  ------------------
  868|     10|		fs->icache->cache_last = cache_slot;
  869|     10|		fs->icache->cache[cache_slot].ino = ino;
  870|     10|	}
  871|     63|	memcpy(inode, iptr, (bufsize > length) ? length : bufsize);
  ------------------
  |  Branch (871:22): [True: 0, False: 63]
  ------------------
  872|       |
  873|     63|	if (!(fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) &&
  ------------------
  |  |  216|     63|#define EXT2_FLAG_IGNORE_CSUM_ERRORS	0x200000
  ------------------
  |  Branch (873:6): [True: 0, False: 63]
  ------------------
  874|     63|	    !(flags & READ_INODE_NOCSUM) && fail_csum)
  ------------------
  |  |  679|      0|#define READ_INODE_NOCSUM	0x0001
  ------------------
  |  Branch (874:6): [True: 0, False: 0]
  |  Branch (874:38): [True: 0, False: 0]
  ------------------
  875|      0|		return EXT2_ET_INODE_CSUM_INVALID;
  ------------------
  |  |  154|      0|#define EXT2_ET_INODE_CSUM_INVALID               (2133571474L)
  ------------------
  876|       |
  877|     63|	return 0;
  878|     63|}
ext2fs_read_inode:
  888|    303|{
  889|    303|	return ext2fs_read_inode2(fs, ino, inode,
  890|    303|				  sizeof(struct ext2_inode), 0);
  891|    303|}
ext2fs_check_directory:
 1101|    303|{
 1102|    303|	struct	ext2_inode	inode;
 1103|    303|	errcode_t		retval;
 1104|       |
 1105|    303|	EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
  ------------------
  |  |  697|    303|	  if ((struct)->magic != (code)) return (code)
  |  |  ------------------
  |  |  |  Branch (697:8): [True: 0, False: 303]
  |  |  ------------------
  ------------------
 1106|       |
 1107|    303|	if (ino > fs->super->s_inodes_count)
  ------------------
  |  Branch (1107:6): [True: 0, False: 303]
  ------------------
 1108|      0|		return EXT2_ET_BAD_INODE_NUM;
  ------------------
  |  |   49|      0|#define EXT2_ET_BAD_INODE_NUM                    (2133571369L)
  ------------------
 1109|       |
 1110|    303|	if (fs->check_directory) {
  ------------------
  |  Branch (1110:6): [True: 0, False: 303]
  ------------------
 1111|      0|		retval = (fs->check_directory)(fs, ino);
 1112|      0|		if (retval != EXT2_ET_CALLBACK_NOTHANDLED)
  ------------------
  |  |   73|      0|#define EXT2_ET_CALLBACK_NOTHANDLED              (2133571393L)
  ------------------
  |  Branch (1112:7): [True: 0, False: 0]
  ------------------
 1113|      0|			return retval;
 1114|      0|	}
 1115|    303|	retval = ext2fs_read_inode(fs, ino, &inode);
 1116|    303|	if (retval)
  ------------------
  |  Branch (1116:6): [True: 240, False: 63]
  ------------------
 1117|    240|		return retval;
 1118|     63|	if (!LINUX_S_ISDIR(inode.i_mode))
  ------------------
  |  |  577|     63|#define LINUX_S_ISDIR(m)	(((m) & LINUX_S_IFMT) == LINUX_S_IFDIR)
  |  |  ------------------
  |  |  |  |  548|     63|#define LINUX_S_IFMT  00170000
  |  |  ------------------
  |  |               #define LINUX_S_ISDIR(m)	(((m) & LINUX_S_IFMT) == LINUX_S_IFDIR)
  |  |  ------------------
  |  |  |  |  553|     63|#define LINUX_S_IFDIR  0040000
  |  |  ------------------
  ------------------
  |  Branch (1118:6): [True: 62, False: 1]
  ------------------
 1119|     62|		return EXT2_ET_NO_DIRECTORY;
  ------------------
  |  |   82|     62|#define EXT2_ET_NO_DIRECTORY                     (2133571402L)
  ------------------
 1120|      1|	return 0;
 1121|     63|}

io_channel_read_blk64:
   74|     95|{
   75|     95|	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
  ------------------
  |  |  697|     95|	  if ((struct)->magic != (code)) return (code)
  |  |  ------------------
  |  |  |  Branch (697:8): [True: 0, False: 95]
  |  |  ------------------
  ------------------
   76|       |
   77|     95|	if (channel->manager->read_blk64)
  ------------------
  |  Branch (77:6): [True: 95, False: 0]
  ------------------
   78|     95|		return (channel->manager->read_blk64)(channel, block,
   79|     95|						      count, data);
   80|       |
   81|      0|	if ((block >> 32) != 0)
  ------------------
  |  Branch (81:6): [True: 0, False: 0]
  ------------------
   82|      0|		return EXT2_ET_IO_CHANNEL_NO_SUPPORT_64;
  ------------------
  |  |  143|      0|#define EXT2_ET_IO_CHANNEL_NO_SUPPORT_64         (2133571463L)
  ------------------
   83|       |
   84|      0|	return (channel->manager->read_blk)(channel, (unsigned long) block,
   85|      0|					     count, data);
   86|      0|}
io_channel_alloc_buf:
  127|  7.18k|{
  128|  7.18k|	size_t	size;
  129|       |
  130|  7.18k|	if (count == 0)
  ------------------
  |  Branch (130:6): [True: 6.39k, False: 797]
  ------------------
  131|  6.39k|		size = io->block_size;
  132|    797|	else if (count > 0)
  ------------------
  |  Branch (132:11): [True: 0, False: 797]
  ------------------
  133|      0|		size = io->block_size * count;
  134|    797|	else
  135|    797|		size = -count;
  136|       |
  137|  7.18k|	if (io->align > 0) {
  ------------------
  |  Branch (137:6): [True: 0, False: 7.18k]
  ------------------
  138|      0|		if ((unsigned) io->align > size)
  ------------------
  |  Branch (138:7): [True: 0, False: 0]
  ------------------
  139|      0|			size = io->align;
  140|      0|		return ext2fs_get_memalign(size, io->align, ptr);
  141|      0|	} else
  142|  7.18k|		return ext2fs_get_mem(size, ptr);
  143|  7.18k|}
io_channel_cache_readahead:
  147|      8|{
  148|      8|	if (!io->manager->cache_readahead)
  ------------------
  |  Branch (148:6): [True: 0, False: 8]
  ------------------
  149|      0|		return EXT2_ET_OP_NOT_SUPPORTED;
  ------------------
  |  |  137|      0|#define EXT2_ET_OP_NOT_SUPPORTED                 (2133571457L)
  ------------------
  150|       |
  151|      8|	return io->manager->cache_readahead(io, block, count);
  152|      8|}

ext2fs_llseek:
   63|     65|{
   64|     65|	ext2_loff_t result;
   65|     65|	static int do_compat = 0;
   66|       |
   67|     65|	if (do_compat)
  ------------------
  |  Branch (67:6): [True: 0, False: 65]
  ------------------
   68|      0|		goto fallback;
   69|       |
   70|     65|	result = my_llseek (fd, offset, origin);
   71|     65|	if (result == -1 && errno == ENOSYS) {
  ------------------
  |  Branch (71:6): [True: 1, False: 64]
  |  Branch (71:22): [True: 0, False: 1]
  ------------------
   72|       |		/*
   73|       |		 * Just in case this code runs on top of an old kernel
   74|       |		 * which does not support the llseek system call
   75|       |		 */
   76|      0|		do_compat++;
   77|      0|	fallback:
   78|      0|		if (offset < ((ext2_loff_t) 1 << ((sizeof(off_t)*8) -1)))
  ------------------
  |  Branch (78:7): [True: 0, False: 0]
  ------------------
   79|      0|			return lseek(fd, (off_t) offset, origin);
   80|      0|		errno = EINVAL;
   81|      0|		return -1;
   82|      0|	}
   83|     65|	return result;
   84|     65|}
llseek.c:my_llseek:
   41|     65|{
   42|     65|#if SIZEOF_OFF_T >= 8
   43|     65|	return lseek(fd, offset, origin);
   44|       |#elif HAVE_LSEEK64_PROTOTYPE
   45|       |	return lseek64(fd, offset, origin);
   46|       |#elif HAVE_LLSEEK_PROTOTYPE
   47|       |	return llseek(fd, offset, origin);
   48|       |#elif defined(__NR__llseek)
   49|       |	loff_t result;
   50|       |	int retval;
   51|       |	retval = syscall(__NR__llseek, fd,
   52|       |		(unsigned long)(offset >> 32),
   53|       |		(unsigned long)(offset & 0xffffffff),
   54|       |		&result, origin);
   55|       |	return (retval == -1 ? retval : result);
   56|       |#else
   57|       |	errno = ENOSYS;
   58|       |	return -1;
   59|       |#endif
   60|     65|}

ext2fs_zero_blocks2:
  167|    797|{
  168|    797|	int		j, count;
  169|    797|	static void	*buf;
  170|    797|	static int	stride_length;
  171|    797|	errcode_t	retval;
  172|       |
  173|       |	/* If fs is null, clean up the static buffer and return */
  174|    797|	if (!fs) {
  ------------------
  |  Branch (174:6): [True: 797, False: 0]
  ------------------
  175|    797|		if (buf) {
  ------------------
  |  Branch (175:7): [True: 0, False: 797]
  ------------------
  176|      0|			free(buf);
  177|      0|			buf = 0;
  178|      0|			stride_length = 0;
  179|      0|		}
  180|    797|		return 0;
  181|    797|	}
  182|       |
  183|       |	/* Deal with zeroing less than 1 block */
  184|      0|	if (num <= 0)
  ------------------
  |  Branch (184:6): [True: 0, False: 0]
  ------------------
  185|      0|		return 0;
  186|       |
  187|       |	/* Try a zero out command, if supported */
  188|      0|	retval = io_channel_zeroout(fs->io, blk, num);
  189|      0|	if (retval == 0)
  ------------------
  |  Branch (189:6): [True: 0, False: 0]
  ------------------
  190|      0|		return 0;
  191|       |
  192|       |	/* Allocate the zeroizing buffer if necessary */
  193|      0|	if (num > stride_length && stride_length < MAX_STRIDE_LENGTH) {
  ------------------
  |  |  164|      0|#define MAX_STRIDE_LENGTH (4194304 / (int) fs->blocksize)
  ------------------
  |  Branch (193:6): [True: 0, False: 0]
  |  Branch (193:29): [True: 0, False: 0]
  ------------------
  194|      0|		void *p;
  195|      0|		int new_stride = num;
  196|       |
  197|      0|		if (new_stride > MAX_STRIDE_LENGTH)
  ------------------
  |  |  164|      0|#define MAX_STRIDE_LENGTH (4194304 / (int) fs->blocksize)
  ------------------
  |  Branch (197:7): [True: 0, False: 0]
  ------------------
  198|      0|			new_stride = MAX_STRIDE_LENGTH;
  ------------------
  |  |  164|      0|#define MAX_STRIDE_LENGTH (4194304 / (int) fs->blocksize)
  ------------------
  199|      0|		p = realloc(buf, fs->blocksize * new_stride);
  200|      0|		if (!p)
  ------------------
  |  Branch (200:7): [True: 0, False: 0]
  ------------------
  201|      0|			return EXT2_ET_NO_MEMORY;
  ------------------
  |  |   78|      0|#define EXT2_ET_NO_MEMORY                        (2133571398L)
  ------------------
  202|      0|		buf = p;
  203|      0|		stride_length = new_stride;
  204|      0|		memset(buf, 0, fs->blocksize * stride_length);
  205|      0|	}
  206|       |	/* OK, do the write loop */
  207|      0|	j=0;
  208|      0|	while (j < num) {
  ------------------
  |  Branch (208:9): [True: 0, False: 0]
  ------------------
  209|      0|		if (blk % stride_length) {
  ------------------
  |  Branch (209:7): [True: 0, False: 0]
  ------------------
  210|      0|			count = stride_length - (blk % stride_length);
  211|      0|			if (count > (num - j))
  ------------------
  |  Branch (211:8): [True: 0, False: 0]
  ------------------
  212|      0|				count = num - j;
  213|      0|		} else {
  214|      0|			count = num - j;
  215|      0|			if (count > stride_length)
  ------------------
  |  Branch (215:8): [True: 0, False: 0]
  ------------------
  216|      0|				count = stride_length;
  217|      0|		}
  218|      0|		retval = io_channel_write_blk64(fs->io, blk, count, buf);
  219|      0|		if (retval) {
  ------------------
  |  Branch (219:7): [True: 0, False: 0]
  ------------------
  220|      0|			if (ret_count)
  ------------------
  |  Branch (220:8): [True: 0, False: 0]
  ------------------
  221|      0|				*ret_count = count;
  222|      0|			if (ret_blk)
  ------------------
  |  Branch (222:8): [True: 0, False: 0]
  ------------------
  223|      0|				*ret_blk = blk;
  224|      0|			return retval;
  225|      0|		}
  226|      0|		j += count; blk += count;
  227|      0|	}
  228|      0|	return 0;
  229|      0|}

ext2fs_mmp_stop:
  400|    303|{
  401|    303|#ifdef CONFIG_MMP
  402|    303|	struct mmp_struct *mmp, *mmp_cmp;
  403|    303|	errcode_t retval = 0;
  404|       |
  405|    303|	if (!ext2fs_has_feature_mmp(fs->super) ||
  ------------------
  |  Branch (405:6): [True: 299, False: 4]
  ------------------
  406|    303|	    !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP) ||
  ------------------
  |  |  195|      4|#define EXT2_FLAG_RW			0x01
  ------------------
              	    !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP) ||
  ------------------
  |  |  215|      0|#define EXT2_FLAG_SKIP_MMP		0x100000
  ------------------
  |  Branch (406:6): [True: 4, False: 0]
  |  Branch (406:37): [True: 0, False: 0]
  ------------------
  407|    303|	    (fs->mmp_buf == NULL) || (fs->mmp_cmp == NULL))
  ------------------
  |  Branch (407:6): [True: 0, False: 0]
  |  Branch (407:31): [True: 0, False: 0]
  ------------------
  408|    303|		goto mmp_error;
  409|       |
  410|      0|	retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, NULL);
  411|      0|	if (retval)
  ------------------
  |  Branch (411:6): [True: 0, False: 0]
  ------------------
  412|      0|		goto mmp_error;
  413|       |
  414|       |	/* Check if the MMP block is not changed. */
  415|      0|	mmp = fs->mmp_buf;
  416|      0|	mmp_cmp = fs->mmp_cmp;
  417|      0|	if (memcmp(mmp, mmp_cmp, sizeof(*mmp_cmp))) {
  ------------------
  |  Branch (417:6): [True: 0, False: 0]
  ------------------
  418|      0|		retval = EXT2_ET_MMP_CHANGE_ABORT;
  ------------------
  |  |  151|      0|#define EXT2_ET_MMP_CHANGE_ABORT                 (2133571471L)
  ------------------
  419|      0|		goto mmp_error;
  420|      0|	}
  421|       |
  422|      0|	mmp_cmp->mmp_seq = EXT4_MMP_SEQ_CLEAN;
  ------------------
  |  | 1155|      0|#define EXT4_MMP_SEQ_CLEAN 0xFF4D4D50U /* mmp_seq value for clean unmount */
  ------------------
  423|      0|	retval = ext2fs_mmp_write(fs, fs->super->s_mmp_block, fs->mmp_cmp);
  424|       |
  425|    303|mmp_error:
  426|    303|	if (fs->mmp_fd > 0) {
  ------------------
  |  Branch (426:6): [True: 0, False: 303]
  ------------------
  427|      0|		close(fs->mmp_fd);
  428|      0|		fs->mmp_fd = -1;
  429|      0|	}
  430|       |
  431|    303|	return retval;
  432|       |#else
  433|       |	if (!ext2fs_has_feature_mmp(fs->super) ||
  434|       |	    !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP))
  435|       |		return 0;
  436|       |
  437|       |	return EXT2_ET_OP_NOT_SUPPORTED;
  438|       |#endif
  439|      0|}

ext2fs_load_nls_table:
  982|     25|{
  983|     25|	if (encoding == EXT4_ENC_UTF8_12_1)
  ------------------
  |  | 1197|     25|#define EXT4_ENC_UTF8_12_1	1
  ------------------
  |  Branch (983:6): [True: 1, False: 24]
  ------------------
  984|      1|		return &nls_utf8;
  985|       |
  986|     24|	return NULL;
  987|     25|}

ext2fs_descriptor_block_loc2:
   37|     16|{
   38|     16|	int	bg;
   39|     16|	int	has_super = 0, group_zero_adjust = 0;
   40|     16|	blk64_t	ret_blk;
   41|       |
   42|       |	/*
   43|       |	 * On a bigalloc FS with 1K blocks, block 0 is reserved for non-ext4
   44|       |	 * stuff, so adjust for that if we're being asked for group 0.
   45|       |	 */
   46|     16|	if (i == 0 && fs->blocksize == 1024 && EXT2FS_CLUSTER_RATIO(fs) > 1)
  ------------------
  |  |  758|     16|#define EXT2FS_CLUSTER_RATIO(fs)	(1 << (fs)->cluster_ratio_bits)
  ------------------
  |  Branch (46:6): [True: 16, False: 0]
  |  Branch (46:16): [True: 16, False: 0]
  |  Branch (46:41): [True: 0, False: 16]
  ------------------
   47|      0|		group_zero_adjust = 1;
   48|       |
   49|     16|	if (!ext2fs_has_feature_meta_bg(fs->super) ||
  ------------------
  |  Branch (49:6): [True: 0, False: 16]
  ------------------
   50|     16|	    (i < fs->super->s_first_meta_bg))
  ------------------
  |  Branch (50:6): [True: 0, False: 16]
  ------------------
   51|      0|		return group_block + i + 1 + group_zero_adjust;
   52|       |
   53|     16|	bg = EXT2_DESC_PER_BLOCK(fs->super) * i;
  ------------------
  |  |  301|     16|#define EXT2_DESC_PER_BLOCK(s)		(EXT2_BLOCK_SIZE(s) / EXT2_DESC_SIZE(s))
  |  |  ------------------
  |  |  |  |  113|     16|#define EXT2_BLOCK_SIZE(s)	(EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|     16|#define EXT2_MIN_BLOCK_SIZE	(1 << EXT2_MIN_BLOCK_LOG_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  102|     16|#define EXT2_MIN_BLOCK_LOG_SIZE		10	/* 1024 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define EXT2_DESC_PER_BLOCK(s)		(EXT2_BLOCK_SIZE(s) / EXT2_DESC_SIZE(s))
  |  |  ------------------
  |  |  |  |  284|     16|	(ext2fs_has_feature_64bit(s) ? (s)->s_desc_size : EXT2_MIN_DESC_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  280|     14|#define EXT2_MIN_DESC_SIZE             32
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (284:3): [True: 2, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   54|     16|	if (ext2fs_bg_has_super(fs, bg))
  ------------------
  |  Branch (54:6): [True: 16, False: 0]
  ------------------
   55|     16|		has_super = 1;
   56|     16|	ret_blk = ext2fs_group_first_block2(fs, bg);
   57|       |	/*
   58|       |	 * If group_block is not the normal value, we're trying to use
   59|       |	 * the backup group descriptors and superblock --- so use the
   60|       |	 * alternate location of the second block group in the
   61|       |	 * metablock group.  Ideally we should be testing each bg
   62|       |	 * descriptor block individually for correctness, but we don't
   63|       |	 * have the infrastructure in place to do that.
   64|       |	 */
   65|     16|	if (group_block != fs->super->s_first_data_block &&
  ------------------
  |  Branch (65:6): [True: 0, False: 16]
  ------------------
   66|     16|	    ((ret_blk + has_super + fs->super->s_blocks_per_group) <
  ------------------
  |  Branch (66:6): [True: 0, False: 0]
  ------------------
   67|      0|	     ext2fs_blocks_count(fs->super))) {
   68|      0|		ret_blk += fs->super->s_blocks_per_group;
   69|       |
   70|       |		/*
   71|       |		 * If we're going to jump forward a block group, make sure
   72|       |		 * that we adjust has_super to account for the next group's
   73|       |		 * backup superblock (or lack thereof).
   74|       |		 */
   75|      0|		if (ext2fs_bg_has_super(fs, bg + 1))
  ------------------
  |  Branch (75:7): [True: 0, False: 0]
  ------------------
   76|      0|			has_super = 1;
   77|      0|		else
   78|      0|			has_super = 0;
   79|      0|	}
   80|     16|	return ret_blk + has_super + group_zero_adjust;
   81|     16|}
ext2fs_open:
   91|    797|{
   92|    797|	return ext2fs_open2(name, 0, flags, superblock, block_size,
   93|    797|			    manager, ret_fs);
   94|    797|}
ext2fs_open2:
  120|    797|{
  121|    797|	ext2_filsys	fs;
  122|    797|	errcode_t	retval;
  123|    797|	unsigned long	i, first_meta_bg;
  124|    797|	__u32		features;
  125|    797|	unsigned int	blocks_per_group, io_flags;
  126|    797|	blk64_t		group_block, blk;
  127|    797|	char		*dest, *cp;
  128|    797|	int		group_zero_adjust = 0;
  129|    797|	unsigned int	inode_size;
  130|    797|	__u64		groups_cnt;
  131|       |#ifdef WORDS_BIGENDIAN
  132|       |	unsigned int	groups_per_block;
  133|       |	struct ext2_group_desc *gdp;
  134|       |	int		j;
  135|       |#endif
  136|    797|	char		*time_env;
  137|    797|	int		csum_retries = 0;
  138|       |
  139|    797|	EXT2_CHECK_MAGIC(manager, EXT2_ET_MAGIC_IO_MANAGER);
  ------------------
  |  |  697|    797|	  if ((struct)->magic != (code)) return (code)
  |  |  ------------------
  |  |  |  Branch (697:8): [True: 0, False: 797]
  |  |  ------------------
  ------------------
  140|       |
  141|    797|	retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs);
  142|    797|	if (retval)
  ------------------
  |  Branch (142:6): [True: 0, False: 797]
  ------------------
  143|      0|		return retval;
  144|       |
  145|    797|	memset(fs, 0, sizeof(struct struct_ext2_filsys));
  146|    797|	fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS;
  ------------------
  |  |    9|    797|#define EXT2_ET_MAGIC_EXT2FS_FILSYS              (2133571329L)
  ------------------
  147|    797|	fs->flags = flags;
  148|       |	/* don't overwrite sb backups unless flag is explicitly cleared */
  149|    797|	fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
  ------------------
  |  |  204|    797|#define EXT2_FLAG_MASTER_SB_ONLY	0x200
  ------------------
  150|    797|	fs->umask = 022;
  151|       |
  152|    797|	time_env = ext2fs_safe_getenv("SOURCE_DATE_EPOCH");
  153|    797|	if (time_env) {
  ------------------
  |  Branch (153:6): [True: 0, False: 797]
  ------------------
  154|      0|		fs->now = strtoul(time_env, NULL, 0);
  155|      0|		fs->flags2 |= EXT2_FLAG2_USE_FAKE_TIME;
  ------------------
  |  |  227|      0|#define EXT2_FLAG2_USE_FAKE_TIME	0x000000001
  ------------------
  156|    797|	} else {
  157|    797|		time_env = ext2fs_safe_getenv("E2FSPROGS_FAKE_TIME");
  158|    797|		if (time_env)
  ------------------
  |  Branch (158:7): [True: 0, False: 797]
  ------------------
  159|      0|			fs->now = strtoul(time_env, NULL, 0);
  160|    797|	}
  161|       |
  162|    797|	retval = ext2fs_get_mem(strlen(name)+1, &fs->device_name);
  163|    797|	if (retval)
  ------------------
  |  Branch (163:6): [True: 0, False: 797]
  ------------------
  164|      0|		goto cleanup;
  165|    797|	strcpy(fs->device_name, name);
  166|    797|	cp = strchr(fs->device_name, '?');
  167|    797|	if (!io_options && cp) {
  ------------------
  |  Branch (167:6): [True: 797, False: 0]
  |  Branch (167:21): [True: 0, False: 797]
  ------------------
  168|      0|		*cp++ = 0;
  169|      0|		io_options = cp;
  170|      0|	}
  171|       |
  172|    797|	io_flags = 0;
  173|    797|	if (flags & EXT2_FLAG_RW)
  ------------------
  |  |  195|    797|#define EXT2_FLAG_RW			0x01
  ------------------
  |  Branch (173:6): [True: 0, False: 797]
  ------------------
  174|      0|		io_flags |= IO_FLAG_RW;
  ------------------
  |  |  106|      0|#define IO_FLAG_RW		0x0001
  ------------------
  175|    797|	if (flags & EXT2_FLAG_EXCLUSIVE)
  ------------------
  |  |  209|    797|#define EXT2_FLAG_EXCLUSIVE		0x4000
  ------------------
  |  Branch (175:6): [True: 0, False: 797]
  ------------------
  176|      0|		io_flags |= IO_FLAG_EXCLUSIVE;
  ------------------
  |  |  107|      0|#define IO_FLAG_EXCLUSIVE	0x0002
  ------------------
  177|    797|	if (flags & EXT2_FLAG_DIRECT_IO)
  ------------------
  |  |  214|    797|#define EXT2_FLAG_DIRECT_IO		0x80000
  ------------------
  |  Branch (177:6): [True: 0, False: 797]
  ------------------
  178|      0|		io_flags |= IO_FLAG_DIRECT_IO;
  ------------------
  |  |  108|      0|#define IO_FLAG_DIRECT_IO	0x0004
  ------------------
  179|    797|	if (flags & EXT2_FLAG_THREADS)
  ------------------
  |  |  221|    797|#define EXT2_FLAG_THREADS		0x4000000
  ------------------
  |  Branch (179:6): [True: 0, False: 797]
  ------------------
  180|      0|		io_flags |= IO_FLAG_THREADS;
  ------------------
  |  |  110|      0|#define IO_FLAG_THREADS		0x0010
  ------------------
  181|    797|	retval = manager->open(fs->device_name, io_flags, &fs->io);
  182|    797|	if (retval)
  ------------------
  |  Branch (182:6): [True: 0, False: 797]
  ------------------
  183|      0|		goto cleanup;
  184|    797|	if (io_options &&
  ------------------
  |  Branch (184:6): [True: 0, False: 797]
  ------------------
  185|    797|	    (retval = io_channel_set_options(fs->io, io_options)))
  ------------------
  |  Branch (185:6): [True: 0, False: 0]
  ------------------
  186|      0|		goto cleanup;
  187|    797|	fs->image_io = fs->io;
  188|    797|	fs->io->app_data = fs;
  189|    797|	retval = io_channel_alloc_buf(fs->io, -SUPERBLOCK_SIZE, &fs->super);
  ------------------
  |  |   58|    797|#define SUPERBLOCK_SIZE		1024
  ------------------
  190|    797|	if (retval)
  ------------------
  |  Branch (190:6): [True: 0, False: 797]
  ------------------
  191|      0|		goto cleanup;
  192|    797|	if (flags & EXT2_FLAG_IMAGE_FILE) {
  ------------------
  |  |  208|    797|#define EXT2_FLAG_IMAGE_FILE		0x2000
  ------------------
  |  Branch (192:6): [True: 0, False: 797]
  ------------------
  193|      0|		retval = ext2fs_get_mem(sizeof(struct ext2_image_hdr),
  194|      0|					&fs->image_header);
  195|      0|		if (retval)
  ------------------
  |  Branch (195:7): [True: 0, False: 0]
  ------------------
  196|      0|			goto cleanup;
  197|      0|		retval = io_channel_read_blk(fs->io, 0,
  ------------------
  |  |  118|      0|#define io_channel_read_blk(c,b,n,d)	((c)->manager->read_blk((c),b,n,d))
  ------------------
  198|      0|					     -(int)sizeof(struct ext2_image_hdr),
  199|      0|					     fs->image_header);
  200|      0|		if (retval)
  ------------------
  |  Branch (200:7): [True: 0, False: 0]
  ------------------
  201|      0|			goto cleanup;
  202|      0|		if (ext2fs_le32_to_cpu(fs->image_header->magic_number) != EXT2_ET_MAGIC_E2IMAGE)
  ------------------
  |  |   31|      0|#define ext2fs_le32_to_cpu(x) ((__force __u32)(__le32)(x))
  ------------------
              		if (ext2fs_le32_to_cpu(fs->image_header->magic_number) != EXT2_ET_MAGIC_E2IMAGE)
  ------------------
  |  |   24|      0|#define EXT2_ET_MAGIC_E2IMAGE                    (2133571344L)
  ------------------
  |  Branch (202:7): [True: 0, False: 0]
  ------------------
  203|      0|			return EXT2_ET_MAGIC_E2IMAGE;
  ------------------
  |  |   24|      0|#define EXT2_ET_MAGIC_E2IMAGE                    (2133571344L)
  ------------------
  204|      0|		superblock = 1;
  205|      0|		block_size = ext2fs_le32_to_cpu(fs->image_header->fs_blocksize);
  ------------------
  |  |   31|      0|#define ext2fs_le32_to_cpu(x) ((__force __u32)(__le32)(x))
  ------------------
  206|      0|	}
  207|       |
  208|       |	/*
  209|       |	 * If the user specifies a specific block # for the
  210|       |	 * superblock, then he/she must also specify the block size!
  211|       |	 * Otherwise, read the master superblock located at offset
  212|       |	 * SUPERBLOCK_OFFSET from the start of the partition.
  213|       |	 *
  214|       |	 * Note: we only save a backup copy of the superblock if we
  215|       |	 * are reading the superblock from the primary superblock location.
  216|       |	 */
  217|    797|	if (superblock) {
  ------------------
  |  Branch (217:6): [True: 0, False: 797]
  ------------------
  218|      0|		if (!block_size) {
  ------------------
  |  Branch (218:7): [True: 0, False: 0]
  ------------------
  219|      0|			retval = EXT2_ET_INVALID_ARGUMENT;
  ------------------
  |  |   79|      0|#define EXT2_ET_INVALID_ARGUMENT                 (2133571399L)
  ------------------
  220|      0|			goto cleanup;
  221|      0|		}
  222|      0|		io_channel_set_blksize(fs->io, block_size);
  ------------------
  |  |  117|      0|#define io_channel_set_blksize(c,s)	((c)->manager->set_blksize((c),s))
  ------------------
  223|      0|		group_block = superblock;
  224|      0|		fs->orig_super = 0;
  225|    797|	} else {
  226|    797|		io_channel_set_blksize(fs->io, SUPERBLOCK_OFFSET);
  ------------------
  |  |  117|    797|#define io_channel_set_blksize(c,s)	((c)->manager->set_blksize((c),s))
  ------------------
  227|    797|		superblock = 1;
  228|    797|		group_block = 0;
  229|    797|		retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &fs->orig_super);
  ------------------
  |  |   58|    797|#define SUPERBLOCK_SIZE		1024
  ------------------
  230|    797|		if (retval)
  ------------------
  |  Branch (230:7): [True: 0, False: 797]
  ------------------
  231|      0|			goto cleanup;
  232|    797|	}
  233|    797|retry:
  234|    797|	retval = io_channel_read_blk(fs->io, superblock, -SUPERBLOCK_SIZE,
  ------------------
  |  |  118|    797|#define io_channel_read_blk(c,b,n,d)	((c)->manager->read_blk((c),b,n,d))
  ------------------
  235|    797|				     fs->super);
  236|    797|	if (retval)
  ------------------
  |  Branch (236:6): [True: 19, False: 778]
  ------------------
  237|     19|		goto cleanup;
  238|    778|	if (fs->orig_super)
  ------------------
  |  Branch (238:6): [True: 778, False: 0]
  ------------------
  239|    778|		memcpy(fs->orig_super, fs->super, SUPERBLOCK_SIZE);
  ------------------
  |  |   58|    778|#define SUPERBLOCK_SIZE		1024
  ------------------
  240|       |
  241|    778|	if (!(fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS)) {
  ------------------
  |  |  216|    778|#define EXT2_FLAG_IGNORE_CSUM_ERRORS	0x200000
  ------------------
  |  Branch (241:6): [True: 0, False: 778]
  ------------------
  242|      0|		retval = 0;
  243|      0|		if (!ext2fs_verify_csum_type(fs, fs->super))
  ------------------
  |  Branch (243:7): [True: 0, False: 0]
  ------------------
  244|      0|			retval = EXT2_ET_UNKNOWN_CSUM;
  ------------------
  |  |  161|      0|#define EXT2_ET_UNKNOWN_CSUM                     (2133571481L)
  ------------------
  245|      0|		if (!ext2fs_superblock_csum_verify(fs, fs->super)) {
  ------------------
  |  Branch (245:7): [True: 0, False: 0]
  ------------------
  246|      0|			if (csum_retries++ < 3)
  ------------------
  |  Branch (246:8): [True: 0, False: 0]
  ------------------
  247|      0|				goto retry;
  248|      0|			retval = EXT2_ET_SB_CSUM_INVALID;
  ------------------
  |  |  160|      0|#define EXT2_ET_SB_CSUM_INVALID                  (2133571480L)
  ------------------
  249|      0|		}
  250|      0|	}
  251|       |
  252|       |#ifdef WORDS_BIGENDIAN
  253|       |	fs->flags |= EXT2_FLAG_SWAP_BYTES;
  254|       |	ext2fs_swap_super(fs->super);
  255|       |#else
  256|    778|	if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
  ------------------
  |  |  201|    778|#define EXT2_FLAG_SWAP_BYTES		0x40
  ------------------
  |  Branch (256:6): [True: 0, False: 778]
  ------------------
  257|      0|		retval = EXT2_ET_UNIMPLEMENTED;
  ------------------
  |  |   88|      0|#define EXT2_ET_UNIMPLEMENTED                    (2133571408L)
  ------------------
  258|      0|		goto cleanup;
  259|      0|	}
  260|    778|#endif
  261|       |
  262|    778|	if (fs->super->s_magic != EXT2_SUPER_MAGIC)
  ------------------
  |  |   83|    778|#define EXT2_SUPER_MAGIC	0xEF53
  ------------------
  |  Branch (262:6): [True: 15, False: 763]
  ------------------
  263|     15|		retval = EXT2_ET_BAD_MAGIC;
  ------------------
  |  |   27|     15|#define EXT2_ET_BAD_MAGIC                        (2133571347L)
  ------------------
  264|    778|	if (retval)
  ------------------
  |  Branch (264:6): [True: 15, False: 763]
  ------------------
  265|     15|		goto cleanup;
  266|       |
  267|    763|	if (fs->super->s_rev_level > EXT2_LIB_CURRENT_REV) {
  ------------------
  |  |   66|    763|#define EXT2_LIB_CURRENT_REV	EXT2_DYNAMIC_REV
  |  |  ------------------
  |  |  |  |  797|    763|#define EXT2_DYNAMIC_REV	1	/* V2 format w/ dynamic inode sizes */
  |  |  ------------------
  ------------------
  |  Branch (267:6): [True: 40, False: 723]
  ------------------
  268|     40|		retval = EXT2_ET_REV_TOO_HIGH;
  ------------------
  |  |   28|     40|#define EXT2_ET_REV_TOO_HIGH                     (2133571348L)
  ------------------
  269|     40|		goto cleanup;
  270|     40|	}
  271|       |
  272|       |	/*
  273|       |	 * Check for feature set incompatibility
  274|       |	 */
  275|    723|	if (!(flags & EXT2_FLAG_FORCE)) {
  ------------------
  |  |  205|    723|#define EXT2_FLAG_FORCE			0x400
  ------------------
  |  Branch (275:6): [True: 723, False: 0]
  ------------------
  276|    723|		features = fs->super->s_feature_incompat;
  277|    723|#ifdef EXT2_LIB_SOFTSUPP_INCOMPAT
  278|    723|		if (flags & EXT2_FLAG_SOFTSUPP_FEATURES)
  ------------------
  |  |  210|    723|#define EXT2_FLAG_SOFTSUPP_FEATURES	0x8000
  ------------------
  |  Branch (278:7): [True: 0, False: 723]
  ------------------
  279|      0|			features &= ~EXT2_LIB_SOFTSUPP_INCOMPAT;
  ------------------
  |  |  753|      0|#define EXT2_LIB_SOFTSUPP_INCOMPAT	(0)
  ------------------
  280|    723|#endif
  281|    723|		if (features & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP) {
  ------------------
  |  |  719|    723|#define EXT2_LIB_FEATURE_INCOMPAT_SUPP	(EXT2_FEATURE_INCOMPAT_FILETYPE|\
  |  |  ------------------
  |  |  |  |  858|    723|#define EXT2_FEATURE_INCOMPAT_FILETYPE		0x0002
  |  |  ------------------
  |  |  720|    723|					 EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
  |  |  ------------------
  |  |  |  |  860|    723|#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV	0x0008 /* Journal device */
  |  |  ------------------
  |  |  721|    723|					 EXT2_FEATURE_INCOMPAT_META_BG|\
  |  |  ------------------
  |  |  |  |  861|    723|#define EXT2_FEATURE_INCOMPAT_META_BG		0x0010
  |  |  ------------------
  |  |  722|    723|					 EXT3_FEATURE_INCOMPAT_RECOVER|\
  |  |  ------------------
  |  |  |  |  859|    723|#define EXT3_FEATURE_INCOMPAT_RECOVER		0x0004 /* Needs recovery */
  |  |  ------------------
  |  |  723|    723|					 EXT3_FEATURE_INCOMPAT_EXTENTS|\
  |  |  ------------------
  |  |  |  |  862|    723|#define EXT3_FEATURE_INCOMPAT_EXTENTS		0x0040
  |  |  ------------------
  |  |  724|    723|					 EXT4_FEATURE_INCOMPAT_FLEX_BG|\
  |  |  ------------------
  |  |  |  |  865|    723|#define EXT4_FEATURE_INCOMPAT_FLEX_BG		0x0200
  |  |  ------------------
  |  |  725|    723|					 EXT4_FEATURE_INCOMPAT_EA_INODE|\
  |  |  ------------------
  |  |  |  |  866|    723|#define EXT4_FEATURE_INCOMPAT_EA_INODE		0x0400
  |  |  ------------------
  |  |  726|    723|					 EXT4_LIB_INCOMPAT_MMP|\
  |  |  ------------------
  |  |  |  |  714|    723|#define EXT4_LIB_INCOMPAT_MMP		EXT4_FEATURE_INCOMPAT_MMP
  |  |  |  |  ------------------
  |  |  |  |  |  |  864|    723|#define EXT4_FEATURE_INCOMPAT_MMP		0x0100
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  727|    723|					 EXT4_FEATURE_INCOMPAT_64BIT|\
  |  |  ------------------
  |  |  |  |  863|    723|#define EXT4_FEATURE_INCOMPAT_64BIT		0x0080
  |  |  ------------------
  |  |  728|    723|					 EXT4_FEATURE_INCOMPAT_INLINE_DATA|\
  |  |  ------------------
  |  |  |  |  870|    723|#define EXT4_FEATURE_INCOMPAT_INLINE_DATA	0x8000 /* data in inode */
  |  |  ------------------
  |  |  729|    723|					 EXT4_FEATURE_INCOMPAT_ENCRYPT|\
  |  |  ------------------
  |  |  |  |  871|    723|#define EXT4_FEATURE_INCOMPAT_ENCRYPT		0x10000
  |  |  ------------------
  |  |  730|    723|					 EXT4_FEATURE_INCOMPAT_CASEFOLD|\
  |  |  ------------------
  |  |  |  |  872|    723|#define EXT4_FEATURE_INCOMPAT_CASEFOLD		0x20000
  |  |  ------------------
  |  |  731|    723|					 EXT4_FEATURE_INCOMPAT_CSUM_SEED|\
  |  |  ------------------
  |  |  |  |  868|    723|#define EXT4_FEATURE_INCOMPAT_CSUM_SEED		0x2000
  |  |  ------------------
  |  |  732|    723|					 EXT4_FEATURE_INCOMPAT_LARGEDIR)
  |  |  ------------------
  |  |  |  |  869|    723|#define EXT4_FEATURE_INCOMPAT_LARGEDIR		0x4000 /* >2GB or 3-lvl htree */
  |  |  ------------------
  ------------------
  |  Branch (281:7): [True: 22, False: 701]
  ------------------
  282|     22|			retval = EXT2_ET_UNSUPP_FEATURE;
  ------------------
  |  |   75|     22|#define EXT2_ET_UNSUPP_FEATURE                   (2133571395L)
  ------------------
  283|     22|			goto cleanup;
  284|     22|		}
  285|       |
  286|    701|		features = fs->super->s_feature_ro_compat;
  287|    701|#ifdef EXT2_LIB_SOFTSUPP_RO_COMPAT
  288|    701|		if (flags & EXT2_FLAG_SOFTSUPP_FEATURES)
  ------------------
  |  |  210|    701|#define EXT2_FLAG_SOFTSUPP_FEATURES	0x8000
  ------------------
  |  Branch (288:7): [True: 0, False: 701]
  ------------------
  289|      0|			features &= ~EXT2_LIB_SOFTSUPP_RO_COMPAT;
  ------------------
  |  |  754|      0|#define EXT2_LIB_SOFTSUPP_RO_COMPAT	(EXT4_FEATURE_RO_COMPAT_REPLICA)
  |  |  ------------------
  |  |  |  |  850|      0|#define EXT4_FEATURE_RO_COMPAT_REPLICA		0x0800
  |  |  ------------------
  ------------------
  290|    701|#endif
  291|    701|		if ((flags & EXT2_FLAG_RW) &&
  ------------------
  |  |  195|    701|#define EXT2_FLAG_RW			0x01
  ------------------
  |  Branch (291:7): [True: 0, False: 701]
  ------------------
  292|    701|		    (features & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP)) {
  ------------------
  |  |  734|      0|#define EXT2_LIB_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\
  |  |  ------------------
  |  |  |  |  834|      0|#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER	0x0001
  |  |  ------------------
  |  |  735|      0|					 EXT4_FEATURE_RO_COMPAT_HUGE_FILE|\
  |  |  ------------------
  |  |  |  |  837|      0|#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE	0x0008
  |  |  ------------------
  |  |  736|      0|					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE|\
  |  |  ------------------
  |  |  |  |  835|      0|#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE	0x0002
  |  |  ------------------
  |  |  737|      0|					 EXT4_FEATURE_RO_COMPAT_DIR_NLINK|\
  |  |  ------------------
  |  |  |  |  839|      0|#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK	0x0020
  |  |  ------------------
  |  |  738|      0|					 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|\
  |  |  ------------------
  |  |  |  |  840|      0|#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE	0x0040
  |  |  ------------------
  |  |  739|      0|					 EXT4_FEATURE_RO_COMPAT_GDT_CSUM|\
  |  |  ------------------
  |  |  |  |  838|      0|#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM		0x0010
  |  |  ------------------
  |  |  740|      0|					 EXT4_FEATURE_RO_COMPAT_BIGALLOC|\
  |  |  ------------------
  |  |  |  |  843|      0|#define EXT4_FEATURE_RO_COMPAT_BIGALLOC		0x0200
  |  |  ------------------
  |  |  741|      0|					 EXT4_FEATURE_RO_COMPAT_QUOTA|\
  |  |  ------------------
  |  |  |  |  842|      0|#define EXT4_FEATURE_RO_COMPAT_QUOTA		0x0100
  |  |  ------------------
  |  |  742|      0|					 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM|\
  |  |  ------------------
  |  |  |  |  849|      0|#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM	0x0400
  |  |  ------------------
  |  |  743|      0|					 EXT4_FEATURE_RO_COMPAT_READONLY |\
  |  |  ------------------
  |  |  |  |  851|      0|#define EXT4_FEATURE_RO_COMPAT_READONLY		0x1000
  |  |  ------------------
  |  |  744|      0|					 EXT4_FEATURE_RO_COMPAT_PROJECT |\
  |  |  ------------------
  |  |  |  |  852|      0|#define EXT4_FEATURE_RO_COMPAT_PROJECT		0x2000 /* Project quota */
  |  |  ------------------
  |  |  745|      0|					 EXT4_FEATURE_RO_COMPAT_SHARED_BLOCKS |\
  |  |  ------------------
  |  |  |  |  853|      0|#define EXT4_FEATURE_RO_COMPAT_SHARED_BLOCKS	0x4000
  |  |  ------------------
  |  |  746|      0|					 EXT4_FEATURE_RO_COMPAT_VERITY |\
  |  |  ------------------
  |  |  |  |  854|      0|#define EXT4_FEATURE_RO_COMPAT_VERITY		0x8000
  |  |  ------------------
  |  |  747|      0|					 EXT4_FEATURE_RO_COMPAT_ORPHAN_PRESENT)
  |  |  ------------------
  |  |  |  |  855|      0|#define EXT4_FEATURE_RO_COMPAT_ORPHAN_PRESENT	0x10000
  |  |  ------------------
  ------------------
  |  Branch (292:7): [True: 0, False: 0]
  ------------------
  293|      0|			retval = EXT2_ET_RO_UNSUPP_FEATURE;
  ------------------
  |  |   76|      0|#define EXT2_ET_RO_UNSUPP_FEATURE                (2133571396L)
  ------------------
  294|      0|			goto cleanup;
  295|      0|		}
  296|       |
  297|    701|		if (!(flags & EXT2_FLAG_JOURNAL_DEV_OK) &&
  ------------------
  |  |  207|    701|#define EXT2_FLAG_JOURNAL_DEV_OK	0x1000
  ------------------
  |  Branch (297:7): [True: 701, False: 0]
  ------------------
  298|    701|		    ext2fs_has_feature_journal_dev(fs->super)) {
  ------------------
  |  Branch (298:7): [True: 1, False: 700]
  ------------------
  299|      1|			retval = EXT2_ET_UNSUPP_FEATURE;
  ------------------
  |  |   75|      1|#define EXT2_ET_UNSUPP_FEATURE                   (2133571395L)
  ------------------
  300|      1|			goto cleanup;
  301|      1|		}
  302|    701|	}
  303|       |
  304|    700|	if ((fs->super->s_log_block_size >
  ------------------
  |  Branch (304:6): [True: 30, False: 670]
  ------------------
  305|    700|	     (unsigned) (EXT2_MAX_BLOCK_LOG_SIZE - EXT2_MIN_BLOCK_LOG_SIZE)) ||
  ------------------
  |  |  103|    700|#define EXT2_MAX_BLOCK_LOG_SIZE		16	/* 65536 */
  ------------------
              	     (unsigned) (EXT2_MAX_BLOCK_LOG_SIZE - EXT2_MIN_BLOCK_LOG_SIZE)) ||
  ------------------
  |  |  102|    700|#define EXT2_MIN_BLOCK_LOG_SIZE		10	/* 1024 */
  ------------------
  306|    700|	    (fs->super->s_log_cluster_size >
  ------------------
  |  Branch (306:6): [True: 25, False: 645]
  ------------------
  307|    670|	     (unsigned) (EXT2_MAX_CLUSTER_LOG_SIZE - EXT2_MIN_CLUSTER_LOG_SIZE)) ||
  ------------------
  |  |  126|    670|#define EXT2_MAX_CLUSTER_LOG_SIZE	29	/* 512MB  */
  ------------------
              	     (unsigned) (EXT2_MAX_CLUSTER_LOG_SIZE - EXT2_MIN_CLUSTER_LOG_SIZE)) ||
  ------------------
  |  |  125|    670|#define EXT2_MIN_CLUSTER_LOG_SIZE	EXT2_MIN_BLOCK_LOG_SIZE
  |  |  ------------------
  |  |  |  |  102|    670|#define EXT2_MIN_BLOCK_LOG_SIZE		10	/* 1024 */
  |  |  ------------------
  ------------------
  308|    700|	    (fs->super->s_log_block_size > fs->super->s_log_cluster_size) ||
  ------------------
  |  Branch (308:6): [True: 4, False: 641]
  ------------------
  309|    700|	    (fs->super->s_log_groups_per_flex > 31)) {
  ------------------
  |  Branch (309:6): [True: 4, False: 637]
  ------------------
  310|     63|		retval = EXT2_ET_CORRUPT_SUPERBLOCK;
  ------------------
  |  |   68|     63|#define EXT2_ET_CORRUPT_SUPERBLOCK               (2133571388L)
  ------------------
  311|     63|		goto cleanup;
  312|     63|	}
  313|       |
  314|       |	/*
  315|       |	 * bigalloc requires cluster-aware bitfield operations, which at the
  316|       |	 * moment means we need EXT2_FLAG_64BITS.
  317|       |	 */
  318|    637|	if (ext2fs_has_feature_bigalloc(fs->super) &&
  ------------------
  |  Branch (318:6): [True: 1, False: 636]
  ------------------
  319|    637|	    !(flags & EXT2_FLAG_64BITS)) {
  ------------------
  |  |  212|      1|#define EXT2_FLAG_64BITS		0x20000
  ------------------
  |  Branch (319:6): [True: 1, False: 0]
  ------------------
  320|      1|		retval = EXT2_ET_CANT_USE_LEGACY_BITMAPS;
  ------------------
  |  |  145|      1|#define EXT2_ET_CANT_USE_LEGACY_BITMAPS          (2133571465L)
  ------------------
  321|      1|		goto cleanup;
  322|      1|	}
  323|       |
  324|    636|	if (!ext2fs_has_feature_bigalloc(fs->super) &&
  ------------------
  |  Branch (324:6): [True: 636, False: 0]
  ------------------
  325|    636|	    (fs->super->s_log_block_size != fs->super->s_log_cluster_size)) {
  ------------------
  |  Branch (325:6): [True: 4, False: 632]
  ------------------
  326|      4|		retval = EXT2_ET_CORRUPT_SUPERBLOCK;
  ------------------
  |  |   68|      4|#define EXT2_ET_CORRUPT_SUPERBLOCK               (2133571388L)
  ------------------
  327|      4|		goto cleanup;
  328|      4|	}
  329|    632|	fs->fragsize = fs->blocksize = EXT2_BLOCK_SIZE(fs->super);
  ------------------
  |  |  113|    632|#define EXT2_BLOCK_SIZE(s)	(EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  |  |  ------------------
  |  |  |  |  104|    632|#define EXT2_MIN_BLOCK_SIZE	(1 << EXT2_MIN_BLOCK_LOG_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  102|    632|#define EXT2_MIN_BLOCK_LOG_SIZE		10	/* 1024 */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  330|    632|	inode_size = EXT2_INODE_SIZE(fs->super);
  ------------------
  |  |  115|    632|#define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
  |  |  ------------------
  |  |  |  |  796|    632|#define EXT2_GOOD_OLD_REV	0	/* The good old (original) format */
  |  |  ------------------
  |  |  |  Branch (115:29): [True: 527, False: 105]
  |  |  ------------------
  |  |  116|    632|				 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
  |  |  ------------------
  |  |  |  |  802|    527|#define EXT2_GOOD_OLD_INODE_SIZE 128
  |  |  ------------------
  ------------------
  331|    632|	if ((inode_size < EXT2_GOOD_OLD_INODE_SIZE) ||
  ------------------
  |  |  802|    632|#define EXT2_GOOD_OLD_INODE_SIZE 128
  ------------------
  |  Branch (331:6): [True: 4, False: 628]
  ------------------
  332|    632|	    (inode_size > fs->blocksize) ||
  ------------------
  |  Branch (332:6): [True: 18, False: 610]
  ------------------
  333|    632|	    (inode_size & (inode_size - 1))) {
  ------------------
  |  Branch (333:6): [True: 5, False: 605]
  ------------------
  334|     27|		retval = EXT2_ET_CORRUPT_SUPERBLOCK;
  ------------------
  |  |   68|     27|#define EXT2_ET_CORRUPT_SUPERBLOCK               (2133571388L)
  ------------------
  335|     27|		goto cleanup;
  336|     27|	}
  337|       |
  338|       |	/* Enforce the block group descriptor size */
  339|    605|	if (ext2fs_has_feature_64bit(fs->super)) {
  ------------------
  |  Branch (339:6): [True: 260, False: 345]
  ------------------
  340|    260|		unsigned desc_size = fs->super->s_desc_size;
  341|       |
  342|    260|		if (desc_size == 0 ||
  ------------------
  |  Branch (342:7): [True: 1, False: 259]
  ------------------
  343|    260|		    (!(flags & EXT2_FLAG_IGNORE_SB_ERRORS) &&
  ------------------
  |  |  218|    259|#define EXT2_FLAG_IGNORE_SB_ERRORS	0x800000
  ------------------
  |  Branch (343:8): [True: 259, False: 0]
  ------------------
  344|    259|		     ((desc_size > EXT2_MAX_DESC_SIZE) ||
  ------------------
  |  |  282|    259|#define EXT2_MAX_DESC_SIZE             EXT2_MIN_BLOCK_SIZE
  |  |  ------------------
  |  |  |  |  104|    259|#define EXT2_MIN_BLOCK_SIZE	(1 << EXT2_MIN_BLOCK_LOG_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  102|    259|#define EXT2_MIN_BLOCK_LOG_SIZE		10	/* 1024 */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (344:9): [True: 11, False: 248]
  ------------------
  345|    259|		      (desc_size < EXT2_MIN_DESC_SIZE_64BIT) ||
  ------------------
  |  |  281|    248|#define EXT2_MIN_DESC_SIZE_64BIT       64
  ------------------
  |  Branch (345:9): [True: 6, False: 242]
  ------------------
  346|    259|		      (desc_size & (desc_size - 1)) != 0))) {
  ------------------
  |  Branch (346:9): [True: 8, False: 234]
  ------------------
  347|     26|			retval = EXT2_ET_BAD_DESC_SIZE;
  ------------------
  |  |  153|     26|#define EXT2_ET_BAD_DESC_SIZE                    (2133571473L)
  ------------------
  348|     26|			goto cleanup;
  349|     26|		}
  350|    260|	}
  351|       |
  352|    579|	fs->cluster_ratio_bits = fs->super->s_log_cluster_size -
  353|    579|		fs->super->s_log_block_size;
  354|    579|	if (EXT2_BLOCKS_PER_GROUP(fs->super) !=
  ------------------
  |  |  286|    579|#define EXT2_BLOCKS_PER_GROUP(s)	(EXT2_SB(s)->s_blocks_per_group)
  |  |  ------------------
  |  |  |  |   91|    579|#define EXT2_SB(sb)	(sb)
  |  |  ------------------
  ------------------
  |  Branch (354:6): [True: 46, False: 533]
  ------------------
  355|    579|	    EXT2_CLUSTERS_PER_GROUP(fs->super) << fs->cluster_ratio_bits) {
  ------------------
  |  |  288|    579|#define EXT2_CLUSTERS_PER_GROUP(s)	(EXT2_SB(s)->s_clusters_per_group)
  |  |  ------------------
  |  |  |  |   91|    579|#define EXT2_SB(sb)	(sb)
  |  |  ------------------
  ------------------
  356|     46|		retval = EXT2_ET_CORRUPT_SUPERBLOCK;
  ------------------
  |  |   68|     46|#define EXT2_ET_CORRUPT_SUPERBLOCK               (2133571388L)
  ------------------
  357|     46|		goto cleanup;
  358|     46|	}
  359|    533|	fs->inode_blocks_per_group = ((EXT2_INODES_PER_GROUP(fs->super) *
  ------------------
  |  |  287|    533|#define EXT2_INODES_PER_GROUP(s)	(EXT2_SB(s)->s_inodes_per_group)
  |  |  ------------------
  |  |  |  |   91|    533|#define EXT2_SB(sb)	(sb)
  |  |  ------------------
  ------------------
  360|    533|				       EXT2_INODE_SIZE(fs->super) +
  ------------------
  |  |  115|    533|#define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
  |  |  ------------------
  |  |  |  |  796|    533|#define EXT2_GOOD_OLD_REV	0	/* The good old (original) format */
  |  |  ------------------
  |  |  |  Branch (115:29): [True: 460, False: 73]
  |  |  ------------------
  |  |  116|    533|				 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
  |  |  ------------------
  |  |  |  |  802|    460|#define EXT2_GOOD_OLD_INODE_SIZE 128
  |  |  ------------------
  ------------------
  361|    533|				       EXT2_BLOCK_SIZE(fs->super) - 1) /
  ------------------
  |  |  113|    533|#define EXT2_BLOCK_SIZE(s)	(EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  |  |  ------------------
  |  |  |  |  104|    533|#define EXT2_MIN_BLOCK_SIZE	(1 << EXT2_MIN_BLOCK_LOG_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  102|    533|#define EXT2_MIN_BLOCK_LOG_SIZE		10	/* 1024 */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  362|    533|				      EXT2_BLOCK_SIZE(fs->super));
  ------------------
  |  |  113|    533|#define EXT2_BLOCK_SIZE(s)	(EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  |  |  ------------------
  |  |  |  |  104|    533|#define EXT2_MIN_BLOCK_SIZE	(1 << EXT2_MIN_BLOCK_LOG_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  102|    533|#define EXT2_MIN_BLOCK_LOG_SIZE		10	/* 1024 */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  363|    533|	if (block_size) {
  ------------------
  |  Branch (363:6): [True: 0, False: 533]
  ------------------
  364|      0|		if (block_size != fs->blocksize) {
  ------------------
  |  Branch (364:7): [True: 0, False: 0]
  ------------------
  365|      0|			retval = EXT2_ET_UNEXPECTED_BLOCK_SIZE;
  ------------------
  |  |   42|      0|#define EXT2_ET_UNEXPECTED_BLOCK_SIZE            (2133571362L)
  ------------------
  366|      0|			goto cleanup;
  367|      0|		}
  368|      0|	}
  369|       |	/*
  370|       |	 * Set the blocksize to the filesystem's blocksize.
  371|       |	 */
  372|    533|	io_channel_set_blksize(fs->io, fs->blocksize);
  ------------------
  |  |  117|    533|#define io_channel_set_blksize(c,s)	((c)->manager->set_blksize((c),s))
  ------------------
  373|       |
  374|       |	/*
  375|       |	 * If this is an external journal device, don't try to read
  376|       |	 * the group descriptors, because they're not there.
  377|       |	 */
  378|    533|	if (ext2fs_has_feature_journal_dev(fs->super)) {
  ------------------
  |  Branch (378:6): [True: 0, False: 533]
  ------------------
  379|      0|		fs->group_desc_count = 0;
  380|      0|		*ret_fs = fs;
  381|      0|		return 0;
  382|      0|	}
  383|       |
  384|    533|	if (EXT2_INODES_PER_GROUP(fs->super) == 0) {
  ------------------
  |  |  287|    533|#define EXT2_INODES_PER_GROUP(s)	(EXT2_SB(s)->s_inodes_per_group)
  |  |  ------------------
  |  |  |  |   91|    533|#define EXT2_SB(sb)	(sb)
  |  |  ------------------
  ------------------
  |  Branch (384:6): [True: 1, False: 532]
  ------------------
  385|      1|		retval = EXT2_ET_CORRUPT_SUPERBLOCK;
  ------------------
  |  |   68|      1|#define EXT2_ET_CORRUPT_SUPERBLOCK               (2133571388L)
  ------------------
  386|      1|		goto cleanup;
  387|      1|	}
  388|       |	/* Precompute the FS UUID to seed other checksums */
  389|    532|	ext2fs_init_csum_seed(fs);
  390|       |
  391|       |	/*
  392|       |	 * Read group descriptors
  393|       |	 */
  394|    532|	blocks_per_group = EXT2_BLOCKS_PER_GROUP(fs->super);
  ------------------
  |  |  286|    532|#define EXT2_BLOCKS_PER_GROUP(s)	(EXT2_SB(s)->s_blocks_per_group)
  |  |  ------------------
  |  |  |  |   91|    532|#define EXT2_SB(sb)	(sb)
  |  |  ------------------
  ------------------
  395|    532|	if (blocks_per_group < 8 ||
  ------------------
  |  Branch (395:6): [True: 2, False: 530]
  ------------------
  396|    532|	    blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(fs->super) ||
  ------------------
  |  |  291|  1.06k|#define EXT2_MAX_BLOCKS_PER_GROUP(s)	((((unsigned) 1 << 16) - 8) *	\
  |  |  292|  1.06k|					 (EXT2_CLUSTER_SIZE(s) / \
  |  |  ------------------
  |  |  |  |  129|    530|#define EXT2_CLUSTER_SIZE(s)		(EXT2_MIN_BLOCK_SIZE << \
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|    530|#define EXT2_MIN_BLOCK_SIZE	(1 << EXT2_MIN_BLOCK_LOG_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  102|    530|#define EXT2_MIN_BLOCK_LOG_SIZE		10	/* 1024 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  130|    530|						(s)->s_log_cluster_size)
  |  |  ------------------
  |  |  293|  1.06k|					  EXT2_BLOCK_SIZE(s)))
  |  |  ------------------
  |  |  |  |  113|    530|#define EXT2_BLOCK_SIZE(s)	(EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|    530|#define EXT2_MIN_BLOCK_SIZE	(1 << EXT2_MIN_BLOCK_LOG_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  102|    530|#define EXT2_MIN_BLOCK_LOG_SIZE		10	/* 1024 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (396:6): [True: 2, False: 528]
  ------------------
  397|    532|	    fs->inode_blocks_per_group > EXT2_MAX_INODES_PER_GROUP(fs->super) ||
  ------------------
  |  |  295|  1.06k|#define EXT2_MAX_INODES_PER_GROUP(s)	(((unsigned) 1 << 16) - \
  |  |  296|  1.06k|					 EXT2_INODES_PER_BLOCK(s))
  |  |  ------------------
  |  |  |  |  289|    528|#define EXT2_INODES_PER_BLOCK(s)	(EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
  |  |  |  |  ------------------
  |  |  |  |  |  |  113|    528|#define EXT2_BLOCK_SIZE(s)	(EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  104|    528|#define EXT2_MIN_BLOCK_SIZE	(1 << EXT2_MIN_BLOCK_LOG_SIZE)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  102|    528|#define EXT2_MIN_BLOCK_LOG_SIZE		10	/* 1024 */
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define EXT2_INODES_PER_BLOCK(s)	(EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
  |  |  |  |  ------------------
  |  |  |  |  |  |  115|    528|#define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  796|    528|#define EXT2_GOOD_OLD_REV	0	/* The good old (original) format */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (115:29): [True: 455, False: 73]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  116|    528|				 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  802|    455|#define EXT2_GOOD_OLD_INODE_SIZE 128
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (397:6): [True: 27, False: 501]
  ------------------
  398|    532|           EXT2_DESC_PER_BLOCK(fs->super) == 0 ||
  ------------------
  |  |  301|    501|#define EXT2_DESC_PER_BLOCK(s)		(EXT2_BLOCK_SIZE(s) / EXT2_DESC_SIZE(s))
  |  |  ------------------
  |  |  |  |  113|    501|#define EXT2_BLOCK_SIZE(s)	(EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|    501|#define EXT2_MIN_BLOCK_SIZE	(1 << EXT2_MIN_BLOCK_LOG_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  102|    501|#define EXT2_MIN_BLOCK_LOG_SIZE		10	/* 1024 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define EXT2_DESC_PER_BLOCK(s)		(EXT2_BLOCK_SIZE(s) / EXT2_DESC_SIZE(s))
  |  |  ------------------
  |  |  |  |  284|    501|	(ext2fs_has_feature_64bit(s) ? (s)->s_desc_size : EXT2_MIN_DESC_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  280|    279|#define EXT2_MIN_DESC_SIZE             32
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (284:3): [True: 222, False: 279]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (398:12): [True: 0, False: 501]
  ------------------
  399|    532|           fs->super->s_first_data_block >= ext2fs_blocks_count(fs->super)) {
  ------------------
  |  Branch (399:12): [True: 3, False: 498]
  ------------------
  400|     34|		retval = EXT2_ET_CORRUPT_SUPERBLOCK;
  ------------------
  |  |   68|     34|#define EXT2_ET_CORRUPT_SUPERBLOCK               (2133571388L)
  ------------------
  401|     34|		goto cleanup;
  402|     34|	}
  403|    498|	groups_cnt = ext2fs_div64_ceil(ext2fs_blocks_count(fs->super) -
  404|    498|				       fs->super->s_first_data_block,
  405|    498|				       blocks_per_group);
  406|    498|	if (groups_cnt >> 32) {
  ------------------
  |  Branch (406:6): [True: 57, False: 441]
  ------------------
  407|     57|		retval = EXT2_ET_CORRUPT_SUPERBLOCK;
  ------------------
  |  |   68|     57|#define EXT2_ET_CORRUPT_SUPERBLOCK               (2133571388L)
  ------------------
  408|     57|		goto cleanup;
  409|     57|	}
  410|    441|	fs->group_desc_count = 	groups_cnt;
  411|    441|	if (!(flags & EXT2_FLAG_IGNORE_SB_ERRORS) &&
  ------------------
  |  |  218|    441|#define EXT2_FLAG_IGNORE_SB_ERRORS	0x800000
  ------------------
  |  Branch (411:6): [True: 441, False: 0]
  ------------------
  412|    441|	    (__u64)fs->group_desc_count * EXT2_INODES_PER_GROUP(fs->super) !=
  ------------------
  |  |  287|    441|#define EXT2_INODES_PER_GROUP(s)	(EXT2_SB(s)->s_inodes_per_group)
  |  |  ------------------
  |  |  |  |   91|    441|#define EXT2_SB(sb)	(sb)
  |  |  ------------------
  ------------------
  |  Branch (412:6): [True: 89, False: 352]
  ------------------
  413|    441|	    fs->super->s_inodes_count) {
  414|     89|		retval = EXT2_ET_CORRUPT_SUPERBLOCK;
  ------------------
  |  |   68|     89|#define EXT2_ET_CORRUPT_SUPERBLOCK               (2133571388L)
  ------------------
  415|     89|		goto cleanup;
  416|     89|	}
  417|    352|	fs->desc_blocks = ext2fs_div_ceil(fs->group_desc_count,
  418|    352|					  EXT2_DESC_PER_BLOCK(fs->super));
  ------------------
  |  |  301|    352|#define EXT2_DESC_PER_BLOCK(s)		(EXT2_BLOCK_SIZE(s) / EXT2_DESC_SIZE(s))
  |  |  ------------------
  |  |  |  |  113|    352|#define EXT2_BLOCK_SIZE(s)	(EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
  |  |  |  |  ------------------
  |  |  |  |  |  |  104|    352|#define EXT2_MIN_BLOCK_SIZE	(1 << EXT2_MIN_BLOCK_LOG_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  102|    352|#define EXT2_MIN_BLOCK_LOG_SIZE		10	/* 1024 */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define EXT2_DESC_PER_BLOCK(s)		(EXT2_BLOCK_SIZE(s) / EXT2_DESC_SIZE(s))
  |  |  ------------------
  |  |  |  |  284|    352|	(ext2fs_has_feature_64bit(s) ? (s)->s_desc_size : EXT2_MIN_DESC_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  280|    217|#define EXT2_MIN_DESC_SIZE             32
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (284:3): [True: 135, False: 217]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  419|    352|	if (ext2fs_has_feature_meta_bg(fs->super) &&
  ------------------
  |  Branch (419:6): [True: 36, False: 316]
  ------------------
  420|    352|	    (fs->super->s_first_meta_bg > fs->desc_blocks) &&
  ------------------
  |  Branch (420:6): [True: 27, False: 9]
  ------------------
  421|    352|	    !(flags & EXT2_FLAG_IGNORE_SB_ERRORS)) {
  ------------------
  |  |  218|     27|#define EXT2_FLAG_IGNORE_SB_ERRORS	0x800000
  ------------------
  |  Branch (421:6): [True: 27, False: 0]
  ------------------
  422|     27|		retval = EXT2_ET_CORRUPT_SUPERBLOCK;
  ------------------
  |  |   68|     27|#define EXT2_ET_CORRUPT_SUPERBLOCK               (2133571388L)
  ------------------
  423|     27|		goto cleanup;
  424|     27|	}
  425|    325|	if (flags & EXT2_FLAG_SUPER_ONLY)
  ------------------
  |  |  206|    325|#define EXT2_FLAG_SUPER_ONLY		0x800
  ------------------
  |  Branch (425:6): [True: 0, False: 325]
  ------------------
  426|      0|		goto skip_read_bg;
  427|    325|	retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize,
  428|    325|				&fs->group_desc);
  429|    325|	if (retval)
  ------------------
  |  Branch (429:6): [True: 0, False: 325]
  ------------------
  430|      0|		goto cleanup;
  431|    325|	if (!group_block)
  ------------------
  |  Branch (431:6): [True: 325, False: 0]
  ------------------
  432|    325|		group_block = fs->super->s_first_data_block;
  433|       |	/*
  434|       |	 * On a FS with a 1K blocksize, block 0 is reserved for bootloaders
  435|       |	 * so we must increment block numbers to any group 0 items.
  436|       |	 *
  437|       |	 * However, we cannot touch group_block directly because in the meta_bg
  438|       |	 * case, the ext2fs_descriptor_block_loc2() function will interpret
  439|       |	 * group_block != s_first_data_block to mean that we want to access the
  440|       |	 * backup group descriptors.  This is not what we want if the caller
  441|       |	 * set superblock == 0 (i.e. auto-detect the superblock), which is
  442|       |	 * what's going on here.
  443|       |	 */
  444|    325|	if (group_block == 0 && fs->blocksize == 1024)
  ------------------
  |  Branch (444:6): [True: 6, False: 319]
  |  Branch (444:26): [True: 6, False: 0]
  ------------------
  445|      6|		group_zero_adjust = 1;
  446|    325|	dest = (char *) fs->group_desc;
  447|       |#ifdef WORDS_BIGENDIAN
  448|       |	groups_per_block = EXT2_DESC_PER_BLOCK(fs->super);
  449|       |#endif
  450|    325|	if (ext2fs_has_feature_meta_bg(fs->super) &&
  ------------------
  |  Branch (450:6): [True: 9, False: 316]
  ------------------
  451|    325|	    !(flags & EXT2_FLAG_IMAGE_FILE)) {
  ------------------
  |  |  208|      9|#define EXT2_FLAG_IMAGE_FILE		0x2000
  ------------------
  |  Branch (451:6): [True: 9, False: 0]
  ------------------
  452|      9|		first_meta_bg = fs->super->s_first_meta_bg;
  453|      9|		if (first_meta_bg > fs->desc_blocks)
  ------------------
  |  Branch (453:7): [True: 0, False: 9]
  ------------------
  454|      0|			first_meta_bg = fs->desc_blocks;
  455|      9|	} else
  456|    316|		first_meta_bg = fs->desc_blocks;
  457|    325|	if (first_meta_bg) {
  ------------------
  |  Branch (457:6): [True: 317, False: 8]
  ------------------
  458|    317|		retval = io_channel_read_blk(fs->io, group_block +
  ------------------
  |  |  118|    317|#define io_channel_read_blk(c,b,n,d)	((c)->manager->read_blk((c),b,n,d))
  ------------------
  459|    317|					     group_zero_adjust + 1,
  460|    317|					     first_meta_bg, dest);
  461|    317|		if (retval)
  ------------------
  |  Branch (461:7): [True: 20, False: 297]
  ------------------
  462|     20|			goto cleanup;
  463|       |#ifdef WORDS_BIGENDIAN
  464|       |		gdp = (struct ext2_group_desc *) dest;
  465|       |		for (j=0; j < groups_per_block*first_meta_bg; j++) {
  466|       |			gdp = ext2fs_group_desc(fs, fs->group_desc, j);
  467|       |			if (gdp)
  468|       |				ext2fs_swap_group_desc2(fs, gdp);
  469|       |		}
  470|       |#endif
  471|    297|		dest += fs->blocksize*first_meta_bg;
  472|    297|	}
  473|       |
  474|    313|	for (i = first_meta_bg ; i < fs->desc_blocks; i++) {
  ------------------
  |  Branch (474:27): [True: 8, False: 305]
  ------------------
  475|      8|		blk = ext2fs_descriptor_block_loc2(fs, group_block, i);
  476|      8|		io_channel_cache_readahead(fs->io, blk, 1);
  477|      8|	}
  478|       |
  479|    311|	for (i=first_meta_bg ; i < fs->desc_blocks; i++) {
  ------------------
  |  Branch (479:25): [True: 8, False: 303]
  ------------------
  480|      8|		blk = ext2fs_descriptor_block_loc2(fs, group_block, i);
  481|      8|		retval = io_channel_read_blk64(fs->io, blk, 1, dest);
  482|      8|		if (retval)
  ------------------
  |  Branch (482:7): [True: 2, False: 6]
  ------------------
  483|      2|			goto cleanup;
  484|       |#ifdef WORDS_BIGENDIAN
  485|       |		for (j=0; j < groups_per_block; j++) {
  486|       |			gdp = ext2fs_group_desc(fs, fs->group_desc,
  487|       |						i * groups_per_block + j);
  488|       |			if (gdp)
  489|       |				ext2fs_swap_group_desc2(fs, gdp);
  490|       |		}
  491|       |#endif
  492|      6|		dest += fs->blocksize;
  493|      6|	}
  494|       |
  495|    303|	fs->stride = fs->super->s_raid_stride;
  496|       |
  497|       |	/*
  498|       |	 * If recovery is from backup superblock, Clear _UNININT flags &
  499|       |	 * reset bg_itable_unused to zero
  500|       |	 */
  501|    303|	if (superblock > 1 && ext2fs_has_group_desc_csum(fs)) {
  ------------------
  |  Branch (501:6): [True: 0, False: 303]
  |  Branch (501:24): [True: 0, False: 0]
  ------------------
  502|      0|		dgrp_t group;
  503|       |
  504|      0|		for (group = 0; group < fs->group_desc_count; group++) {
  ------------------
  |  Branch (504:19): [True: 0, False: 0]
  ------------------
  505|      0|			ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
  ------------------
  |  |  224|      0|#define EXT2_BG_BLOCK_UNINIT	0x0002 /* Block bitmap not initialized */
  ------------------
  506|      0|			ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT);
  ------------------
  |  |  223|      0|#define EXT2_BG_INODE_UNINIT	0x0001 /* Inode table/bitmap not initialized */
  ------------------
  507|      0|			ext2fs_bg_itable_unused_set(fs, group, 0);
  508|       |			/* The checksum will be reset later, but fix it here
  509|       |			 * anyway to avoid printing a lot of spurious errors. */
  510|      0|			ext2fs_group_desc_csum_set(fs, group);
  511|      0|		}
  512|      0|		if (fs->flags & EXT2_FLAG_RW)
  ------------------
  |  |  195|      0|#define EXT2_FLAG_RW			0x01
  ------------------
  |  Branch (512:7): [True: 0, False: 0]
  ------------------
  513|      0|			ext2fs_mark_super_dirty(fs);
  514|      0|	}
  515|    303|skip_read_bg:
  516|    303|	if (ext2fs_has_feature_mmp(fs->super) &&
  ------------------
  |  Branch (516:6): [True: 4, False: 299]
  ------------------
  517|    303|	    !(flags & EXT2_FLAG_SKIP_MMP) &&
  ------------------
  |  |  215|      4|#define EXT2_FLAG_SKIP_MMP		0x100000
  ------------------
  |  Branch (517:6): [True: 4, False: 0]
  ------------------
  518|    303|	    (flags & (EXT2_FLAG_RW | EXT2_FLAG_EXCLUSIVE))) {
  ------------------
  |  |  195|      4|#define EXT2_FLAG_RW			0x01
  ------------------
              	    (flags & (EXT2_FLAG_RW | EXT2_FLAG_EXCLUSIVE))) {
  ------------------
  |  |  209|      4|#define EXT2_FLAG_EXCLUSIVE		0x4000
  ------------------
  |  Branch (518:6): [True: 0, False: 4]
  ------------------
  519|      0|		retval = ext2fs_mmp_start(fs);
  520|      0|		if (retval) {
  ------------------
  |  Branch (520:7): [True: 0, False: 0]
  ------------------
  521|      0|			fs->flags |= EXT2_FLAG_SKIP_MMP; /* just do cleanup */
  ------------------
  |  |  215|      0|#define EXT2_FLAG_SKIP_MMP		0x100000
  ------------------
  522|      0|			ext2fs_mmp_stop(fs);
  523|      0|			goto cleanup;
  524|      0|		}
  525|      0|	}
  526|       |
  527|    303|	if (fs->flags & EXT2_FLAG_SHARE_DUP) {
  ------------------
  |  |  217|    303|#define EXT2_FLAG_SHARE_DUP		0x400000
  ------------------
  |  Branch (527:6): [True: 0, False: 303]
  ------------------
  528|      0|		fs->block_sha_map = ext2fs_hashmap_create(ext2fs_djb2_hash,
  529|      0|					block_sha_map_free_entry, 4096);
  530|      0|		if (!fs->block_sha_map) {
  ------------------
  |  Branch (530:7): [True: 0, False: 0]
  ------------------
  531|      0|			retval = EXT2_ET_NO_MEMORY;
  ------------------
  |  |   78|      0|#define EXT2_ET_NO_MEMORY                        (2133571398L)
  ------------------
  532|      0|			goto cleanup;
  533|      0|		}
  534|      0|		ext2fs_set_feature_shared_blocks(fs->super);
  535|      0|	}
  536|       |
  537|    303|	if (ext2fs_has_feature_casefold(fs->super))
  ------------------
  |  Branch (537:6): [True: 25, False: 278]
  ------------------
  538|     25|		fs->encoding = ext2fs_load_nls_table(fs->super->s_encoding);
  539|       |
  540|    303|	fs->flags &= ~EXT2_FLAG_NOFREE_ON_ERROR;
  ------------------
  |  |  211|    303|#define EXT2_FLAG_NOFREE_ON_ERROR	0x10000
  ------------------
  541|    303|	*ret_fs = fs;
  542|       |
  543|    303|	return 0;
  544|    494|cleanup:
  545|    494|	if (!(flags & EXT2_FLAG_NOFREE_ON_ERROR)) {
  ------------------
  |  |  211|    494|#define EXT2_FLAG_NOFREE_ON_ERROR	0x10000
  ------------------
  |  Branch (545:6): [True: 494, False: 0]
  ------------------
  546|    494|		ext2fs_free(fs);
  547|    494|		fs = NULL;
  548|    494|	}
  549|    494|	*ret_fs = fs;
  550|    494|	return retval;
  551|    303|}

ext2fs_open_file:
  658|    797|{
  659|    797|	if (mode)
  ------------------
  |  Branch (659:6): [True: 0, False: 797]
  ------------------
  660|      0|#if defined(HAVE_OPEN64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
  661|      0|		return open64(pathname, flags, mode);
  662|    797|	else
  663|    797|		return open64(pathname, flags);
  664|       |#else
  665|       |		return open(pathname, flags, mode);
  666|       |	else
  667|       |		return open(pathname, flags);
  668|       |#endif
  669|    797|}
ext2fs_fstat:
  681|    797|{
  682|    797|#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
  683|    797|	return fstat64(fd, buf);
  684|       |#else
  685|       |	return fstat(fd, buf);
  686|       |#endif
  687|    797|}
unix_io.c:unix_open:
  909|    797|{
  910|    797|	int fd = -1;
  911|    797|	int open_flags;
  912|       |
  913|    797|	if (name == 0)
  ------------------
  |  Branch (913:6): [True: 0, False: 797]
  ------------------
  914|      0|		return EXT2_ET_BAD_DEVICE_NAME;
  ------------------
  |  |   66|      0|#define EXT2_ET_BAD_DEVICE_NAME                  (2133571386L)
  ------------------
  915|       |
  916|    797|	open_flags = (flags & IO_FLAG_RW) ? O_RDWR : O_RDONLY;
  ------------------
  |  |  106|    797|#define IO_FLAG_RW		0x0001
  ------------------
  |  Branch (916:15): [True: 0, False: 797]
  ------------------
  917|    797|	if (flags & IO_FLAG_EXCLUSIVE)
  ------------------
  |  |  107|    797|#define IO_FLAG_EXCLUSIVE	0x0002
  ------------------
  |  Branch (917:6): [True: 0, False: 797]
  ------------------
  918|      0|		open_flags |= O_EXCL;
  919|    797|#if defined(O_DIRECT)
  920|    797|	if (flags & IO_FLAG_DIRECT_IO)
  ------------------
  |  |  108|    797|#define IO_FLAG_DIRECT_IO	0x0004
  ------------------
  |  Branch (920:6): [True: 0, False: 797]
  ------------------
  921|      0|		open_flags |= O_DIRECT;
  922|    797|#endif
  923|    797|	fd = ext2fs_open_file(name, open_flags, 0);
  924|    797|	if (fd < 0)
  ------------------
  |  Branch (924:6): [True: 0, False: 797]
  ------------------
  925|      0|		return errno;
  926|       |#if defined(F_NOCACHE) && !defined(IO_DIRECT)
  927|       |	if (flags & IO_FLAG_DIRECT_IO) {
  928|       |		if (fcntl(fd, F_NOCACHE, 1) < 0)
  929|       |			return errno;
  930|       |	}
  931|       |#endif
  932|    797|	return unix_open_channel(name, fd, flags, channel, unix_io_manager);
  933|    797|}
unix_io.c:unix_open_channel:
  693|    797|{
  694|    797|	io_channel	io = NULL;
  695|    797|	struct unix_private_data *data = NULL;
  696|    797|	errcode_t	retval;
  697|    797|	ext2fs_struct_stat st;
  698|    797|#ifdef __linux__
  699|    797|	struct		utsname ut;
  700|    797|#endif
  701|       |
  702|    797|	if (ext2fs_safe_getenv("UNIX_IO_FORCE_BOUNCE"))
  ------------------
  |  Branch (702:6): [True: 0, False: 797]
  ------------------
  703|      0|		flags |= IO_FLAG_FORCE_BOUNCE;
  ------------------
  |  |  109|      0|#define IO_FLAG_FORCE_BOUNCE	0x0008
  ------------------
  704|       |
  705|    797|#ifdef __linux__
  706|       |	/*
  707|       |	 * We need to make sure any previous errors in the block
  708|       |	 * device are thrown away, sigh.
  709|       |	 */
  710|    797|	(void) fsync(fd);
  711|    797|#endif
  712|       |
  713|    797|	retval = ext2fs_get_mem(sizeof(struct struct_io_channel), &io);
  714|    797|	if (retval)
  ------------------
  |  Branch (714:6): [True: 0, False: 797]
  ------------------
  715|      0|		goto cleanup;
  716|    797|	memset(io, 0, sizeof(struct struct_io_channel));
  717|    797|	io->magic = EXT2_ET_MAGIC_IO_CHANNEL;
  ------------------
  |  |   13|    797|#define EXT2_ET_MAGIC_IO_CHANNEL                 (2133571333L)
  ------------------
  718|    797|	retval = ext2fs_get_mem(sizeof(struct unix_private_data), &data);
  719|    797|	if (retval)
  ------------------
  |  Branch (719:6): [True: 0, False: 797]
  ------------------
  720|      0|		goto cleanup;
  721|       |
  722|    797|	io->manager = io_mgr;
  723|    797|	retval = ext2fs_get_mem(strlen(name)+1, &io->name);
  724|    797|	if (retval)
  ------------------
  |  Branch (724:6): [True: 0, False: 797]
  ------------------
  725|      0|		goto cleanup;
  726|       |
  727|    797|	strcpy(io->name, name);
  728|    797|	io->private_data = data;
  729|    797|	io->block_size = 1024;
  730|    797|	io->read_error = 0;
  731|    797|	io->write_error = 0;
  732|    797|	io->refcount = 1;
  733|    797|	io->flags = 0;
  734|       |
  735|    797|	if (ext2fs_safe_getenv("UNIX_IO_NOZEROOUT"))
  ------------------
  |  Branch (735:6): [True: 0, False: 797]
  ------------------
  736|      0|		io->flags |= CHANNEL_FLAGS_NOZEROOUT;
  ------------------
  |  |   38|      0|#define CHANNEL_FLAGS_NOZEROOUT		0x20
  ------------------
  737|       |
  738|    797|	memset(data, 0, sizeof(struct unix_private_data));
  739|    797|	data->magic = EXT2_ET_MAGIC_UNIX_IO_CHANNEL;
  ------------------
  |  |   14|    797|#define EXT2_ET_MAGIC_UNIX_IO_CHANNEL            (2133571334L)
  ------------------
  740|    797|	data->io_stats.num_fields = 2;
  741|    797|	data->flags = flags;
  742|    797|	data->dev = fd;
  743|       |
  744|    797|#if defined(O_DIRECT)
  745|    797|	if (flags & IO_FLAG_DIRECT_IO)
  ------------------
  |  |  108|    797|#define IO_FLAG_DIRECT_IO	0x0004
  ------------------
  |  Branch (745:6): [True: 0, False: 797]
  ------------------
  746|      0|		io->align = ext2fs_get_dio_alignment(data->dev);
  747|       |#elif defined(F_NOCACHE)
  748|       |	if (flags & IO_FLAG_DIRECT_IO)
  749|       |		io->align = 4096;
  750|       |#endif
  751|       |
  752|       |	/*
  753|       |	 * If the device is really a block device, then set the
  754|       |	 * appropriate flag, otherwise we can set DISCARD_ZEROES flag
  755|       |	 * because we are going to use punch hole instead of discard
  756|       |	 * and if it succeed, subsequent read from sparse area returns
  757|       |	 * zero.
  758|       |	 */
  759|    797|	if (ext2fs_fstat(data->dev, &st) == 0) {
  ------------------
  |  Branch (759:6): [True: 797, False: 0]
  ------------------
  760|    797|		if (ext2fsP_is_disk_device(st.st_mode)) {
  ------------------
  |  Branch (760:7): [True: 0, False: 797]
  ------------------
  761|      0|#ifdef BLKDISCARDZEROES
  762|      0|			int zeroes = 0;
  763|       |
  764|      0|			if (ioctl(data->dev, BLKDISCARDZEROES, &zeroes) == 0 &&
  ------------------
  |  |  653|      0|#define BLKDISCARDZEROES _IO(0x12,124)
  ------------------
  |  Branch (764:8): [True: 0, False: 0]
  ------------------
  765|      0|			    zeroes)
  ------------------
  |  Branch (765:8): [True: 0, False: 0]
  ------------------
  766|      0|				io->flags |= CHANNEL_FLAGS_DISCARD_ZEROES;
  ------------------
  |  |   34|      0|#define CHANNEL_FLAGS_DISCARD_ZEROES	0x02
  ------------------
  767|      0|#endif
  768|      0|			io->flags |= CHANNEL_FLAGS_BLOCK_DEVICE;
  ------------------
  |  |   35|      0|#define CHANNEL_FLAGS_BLOCK_DEVICE	0x04
  ------------------
  769|    797|		} else {
  770|    797|			io->flags |= CHANNEL_FLAGS_DISCARD_ZEROES;
  ------------------
  |  |   34|    797|#define CHANNEL_FLAGS_DISCARD_ZEROES	0x02
  ------------------
  771|    797|		}
  772|    797|	}
  773|       |
  774|       |#if defined(__CYGWIN__)
  775|       |	/*
  776|       |	 * Some operating systems require that the buffers be aligned,
  777|       |	 * regardless of O_DIRECT
  778|       |	 */
  779|       |	if (!io->align)
  780|       |		io->align = 512;
  781|       |#endif
  782|       |
  783|       |#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
  784|       |	if (io->flags & CHANNEL_FLAGS_BLOCK_DEVICE) {
  785|       |		int dio_align = ext2fs_get_dio_alignment(fd);
  786|       |
  787|       |		if (io->align < dio_align)
  788|       |			io->align = dio_align;
  789|       |	}
  790|       |#endif
  791|       |
  792|    797|	if ((retval = alloc_cache(io, data)))
  ------------------
  |  Branch (792:6): [True: 0, False: 797]
  ------------------
  793|      0|		goto cleanup;
  794|       |
  795|    797|#ifdef BLKROGET
  796|    797|	if (flags & IO_FLAG_RW) {
  ------------------
  |  |  106|    797|#define IO_FLAG_RW		0x0001
  ------------------
  |  Branch (796:6): [True: 0, False: 797]
  ------------------
  797|      0|		int error;
  798|      0|		int readonly = 0;
  799|       |
  800|       |		/* Is the block device actually writable? */
  801|      0|		error = ioctl(data->dev, BLKROGET, &readonly);
  802|      0|		if (!error && readonly) {
  ------------------
  |  Branch (802:7): [True: 0, False: 0]
  |  Branch (802:17): [True: 0, False: 0]
  ------------------
  803|      0|			retval = EPERM;
  804|      0|			goto cleanup;
  805|      0|		}
  806|      0|	}
  807|    797|#endif
  808|       |
  809|    797|#ifdef __linux__
  810|    797|#undef RLIM_INFINITY
  811|       |#if (defined(__alpha__) || ((defined(__sparc__) || defined(__mips__)) && (SIZEOF_LONG == 4)))
  812|       |#define RLIM_INFINITY	((unsigned long)(~0UL>>1))
  813|       |#else
  814|    797|#define RLIM_INFINITY  (~0UL)
  815|    797|#endif
  816|       |	/*
  817|       |	 * Work around a bug in 2.4.10-2.4.18 kernels where writes to
  818|       |	 * block devices are wrongly getting hit by the filesize
  819|       |	 * limit.  This workaround isn't perfect, since it won't work
  820|       |	 * if glibc wasn't built against 2.2 header files.  (Sigh.)
  821|       |	 *
  822|       |	 */
  823|    797|	if ((flags & IO_FLAG_RW) &&
  ------------------
  |  |  106|    797|#define IO_FLAG_RW		0x0001
  ------------------
  |  Branch (823:6): [True: 0, False: 797]
  ------------------
  824|    797|	    (uname(&ut) == 0) &&
  ------------------
  |  Branch (824:6): [True: 0, False: 0]
  ------------------
  825|    797|	    ((ut.release[0] == '2') && (ut.release[1] == '.') &&
  ------------------
  |  Branch (825:7): [True: 0, False: 0]
  |  Branch (825:33): [True: 0, False: 0]
  ------------------
  826|      0|	     (ut.release[2] == '4') && (ut.release[3] == '.') &&
  ------------------
  |  Branch (826:7): [True: 0, False: 0]
  |  Branch (826:33): [True: 0, False: 0]
  ------------------
  827|      0|	     (ut.release[4] == '1') && (ut.release[5] >= '0') &&
  ------------------
  |  Branch (827:7): [True: 0, False: 0]
  |  Branch (827:33): [True: 0, False: 0]
  ------------------
  828|      0|	     (ut.release[5] < '8')) &&
  ------------------
  |  Branch (828:7): [True: 0, False: 0]
  ------------------
  829|    797|	    (ext2fs_fstat(data->dev, &st) == 0) &&
  ------------------
  |  Branch (829:6): [True: 0, False: 0]
  ------------------
  830|    797|	    (ext2fsP_is_disk_device(st.st_mode))) {
  ------------------
  |  Branch (830:6): [True: 0, False: 0]
  ------------------
  831|      0|		struct rlimit	rlim;
  832|       |
  833|      0|		rlim.rlim_cur = rlim.rlim_max = (unsigned long) RLIM_INFINITY;
  ------------------
  |  |  814|      0|#define RLIM_INFINITY  (~0UL)
  ------------------
  834|      0|		setrlimit(RLIMIT_FSIZE, &rlim);
  835|      0|		getrlimit(RLIMIT_FSIZE, &rlim);
  836|      0|		if (((unsigned long) rlim.rlim_cur) <
  ------------------
  |  Branch (836:7): [True: 0, False: 0]
  ------------------
  837|      0|		    ((unsigned long) rlim.rlim_max)) {
  838|      0|			rlim.rlim_cur = rlim.rlim_max;
  839|      0|			setrlimit(RLIMIT_FSIZE, &rlim);
  840|      0|		}
  841|      0|	}
  842|    797|#endif
  843|    797|#ifdef HAVE_PTHREAD
  844|    797|	if (flags & IO_FLAG_THREADS) {
  ------------------
  |  |  110|    797|#define IO_FLAG_THREADS		0x0010
  ------------------
  |  Branch (844:6): [True: 0, False: 797]
  ------------------
  845|      0|		io->flags |= CHANNEL_FLAGS_THREADS;
  ------------------
  |  |   36|      0|#define CHANNEL_FLAGS_THREADS		0x08
  ------------------
  846|      0|		retval = pthread_mutex_init(&data->cache_mutex, NULL);
  847|      0|		if (retval)
  ------------------
  |  Branch (847:7): [True: 0, False: 0]
  ------------------
  848|      0|			goto cleanup;
  849|      0|		retval = pthread_mutex_init(&data->bounce_mutex, NULL);
  850|      0|		if (retval) {
  ------------------
  |  Branch (850:7): [True: 0, False: 0]
  ------------------
  851|      0|			pthread_mutex_destroy(&data->cache_mutex);
  852|      0|			goto cleanup;
  853|      0|		}
  854|      0|		retval = pthread_mutex_init(&data->stats_mutex, NULL);
  855|      0|		if (retval) {
  ------------------
  |  Branch (855:7): [True: 0, False: 0]
  ------------------
  856|      0|			pthread_mutex_destroy(&data->cache_mutex);
  857|      0|			pthread_mutex_destroy(&data->bounce_mutex);
  858|      0|			goto cleanup;
  859|      0|		}
  860|      0|	}
  861|    797|#endif
  862|    797|	*channel = io;
  863|    797|	return 0;
  864|       |
  865|      0|cleanup:
  866|      0|	if (data) {
  ------------------
  |  Branch (866:6): [True: 0, False: 0]
  ------------------
  867|      0|		if (data->dev >= 0)
  ------------------
  |  Branch (867:7): [True: 0, False: 0]
  ------------------
  868|      0|			close(data->dev);
  869|      0|		free_cache(data);
  870|      0|		ext2fs_free_mem(&data);
  871|      0|	}
  872|      0|	if (io) {
  ------------------
  |  Branch (872:6): [True: 0, False: 0]
  ------------------
  873|      0|		if (io->name) {
  ------------------
  |  Branch (873:7): [True: 0, False: 0]
  ------------------
  874|      0|			ext2fs_free_mem(&io->name);
  875|      0|		}
  876|      0|		ext2fs_free_mem(&io);
  877|      0|	}
  878|      0|	return retval;
  879|    797|}
unix_io.c:alloc_cache:
  473|    799|{
  474|    799|	errcode_t		retval;
  475|    799|	struct unix_cache	*cache;
  476|    799|	int			i;
  477|       |
  478|    799|	data->access_time = 0;
  479|  7.19k|	for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) {
  ------------------
  |  |   94|  7.19k|#define CACHE_SIZE 8
  ------------------
  |  Branch (479:33): [True: 6.39k, False: 799]
  ------------------
  480|  6.39k|		cache->block = 0;
  481|  6.39k|		cache->access_time = 0;
  482|  6.39k|		cache->dirty = 0;
  483|  6.39k|		cache->in_use = 0;
  484|  6.39k|		if (cache->buf)
  ------------------
  |  Branch (484:7): [True: 0, False: 6.39k]
  ------------------
  485|      0|			ext2fs_free_mem(&cache->buf);
  486|  6.39k|		retval = io_channel_alloc_buf(channel, 0, &cache->buf);
  487|  6.39k|		if (retval)
  ------------------
  |  Branch (487:7): [True: 0, False: 6.39k]
  ------------------
  488|      0|			return retval;
  489|  6.39k|	}
  490|    799|	if (channel->align || data->flags & IO_FLAG_FORCE_BOUNCE) {
  ------------------
  |  |  109|    799|#define IO_FLAG_FORCE_BOUNCE	0x0008
  ------------------
  |  Branch (490:6): [True: 0, False: 799]
  |  Branch (490:24): [True: 0, False: 799]
  ------------------
  491|      0|		if (data->bounce)
  ------------------
  |  Branch (491:7): [True: 0, False: 0]
  ------------------
  492|      0|			ext2fs_free_mem(&data->bounce);
  493|      0|		retval = io_channel_alloc_buf(channel, 0, &data->bounce);
  494|      0|	}
  495|    799|	return retval;
  496|    799|}
unix_io.c:free_cache:
  500|    799|{
  501|    799|	struct unix_cache	*cache;
  502|    799|	int			i;
  503|       |
  504|    799|	data->access_time = 0;
  505|  7.19k|	for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) {
  ------------------
  |  |   94|  7.19k|#define CACHE_SIZE 8
  ------------------
  |  Branch (505:33): [True: 6.39k, False: 799]
  ------------------
  506|  6.39k|		cache->block = 0;
  507|  6.39k|		cache->access_time = 0;
  508|  6.39k|		cache->dirty = 0;
  509|  6.39k|		cache->in_use = 0;
  510|  6.39k|		if (cache->buf)
  ------------------
  |  Branch (510:7): [True: 6.39k, False: 0]
  ------------------
  511|  6.39k|			ext2fs_free_mem(&cache->buf);
  512|  6.39k|	}
  513|    799|	if (data->bounce)
  ------------------
  |  Branch (513:6): [True: 0, False: 799]
  ------------------
  514|      0|		ext2fs_free_mem(&data->bounce);
  515|    799|}
unix_io.c:unix_close:
  936|    797|{
  937|    797|	struct unix_private_data *data;
  938|    797|	errcode_t	retval = 0;
  939|       |
  940|    797|	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
  ------------------
  |  |   83|    797|	  if ((struct)->magic != (code)) return (code)
  |  |  ------------------
  |  |  |  Branch (83:8): [True: 0, False: 797]
  |  |  ------------------
  ------------------
  941|    797|	data = (struct unix_private_data *) channel->private_data;
  942|    797|	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
  ------------------
  |  |   83|    797|	  if ((struct)->magic != (code)) return (code)
  |  |  ------------------
  |  |  |  Branch (83:8): [True: 0, False: 797]
  |  |  ------------------
  ------------------
  943|       |
  944|    797|	if (--channel->refcount > 0)
  ------------------
  |  Branch (944:6): [True: 0, False: 797]
  ------------------
  945|      0|		return 0;
  946|       |
  947|    797|#ifndef NO_IO_CACHE
  948|    797|	retval = flush_cached_blocks(channel, data, 0);
  949|    797|#endif
  950|       |
  951|    797|	if (close(data->dev) < 0)
  ------------------
  |  Branch (951:6): [True: 0, False: 797]
  ------------------
  952|      0|		retval = errno;
  953|    797|	free_cache(data);
  954|    797|#ifdef HAVE_PTHREAD
  955|    797|	if (data->flags & IO_FLAG_THREADS) {
  ------------------
  |  |  110|    797|#define IO_FLAG_THREADS		0x0010
  ------------------
  |  Branch (955:6): [True: 0, False: 797]
  ------------------
  956|      0|		pthread_mutex_destroy(&data->cache_mutex);
  957|      0|		pthread_mutex_destroy(&data->bounce_mutex);
  958|      0|		pthread_mutex_destroy(&data->stats_mutex);
  959|      0|	}
  960|    797|#endif
  961|       |
  962|    797|	ext2fs_free_mem(&channel->private_data);
  963|    797|	if (channel->name)
  ------------------
  |  Branch (963:6): [True: 797, False: 0]
  ------------------
  964|    797|		ext2fs_free_mem(&channel->name);
  965|    797|	ext2fs_free_mem(&channel);
  966|    797|	return retval;
  967|    797|}
unix_io.c:flush_cached_blocks:
  585|  1.59k|{
  586|  1.59k|	struct unix_cache	*cache;
  587|  1.59k|	errcode_t		retval, retval2 = 0;
  588|  1.59k|	int			i;
  589|  1.59k|	int			errors_found = 0;
  590|       |
  591|  1.59k|	if ((flags & FLUSH_NOLOCK) == 0)
  ------------------
  |  |  577|  1.59k|#define FLUSH_NOLOCK		0x02
  ------------------
  |  Branch (591:6): [True: 1.59k, False: 2]
  ------------------
  592|  1.59k|		mutex_lock(data, CACHE_MTX);
  593|  14.3k|	for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) {
  ------------------
  |  |   94|  14.3k|#define CACHE_SIZE 8
  ------------------
  |  Branch (593:33): [True: 12.7k, False: 1.59k]
  ------------------
  594|  12.7k|		if (!cache->in_use || !cache->dirty)
  ------------------
  |  Branch (594:7): [True: 12.4k, False: 323]
  |  Branch (594:25): [True: 323, False: 0]
  ------------------
  595|  12.7k|			continue;
  596|      0|		retval = raw_write_blk(channel, data,
  597|      0|				       cache->block, 1, cache->buf,
  598|      0|				       RAW_WRITE_NO_HANDLER);
  ------------------
  |  |  311|      0|#define RAW_WRITE_NO_HANDLER	1
  ------------------
  599|      0|		if (retval) {
  ------------------
  |  Branch (599:7): [True: 0, False: 0]
  ------------------
  600|      0|			cache->write_err = 1;
  601|      0|			errors_found = 1;
  602|      0|			retval2 = retval;
  603|      0|		} else {
  604|      0|			cache->dirty = 0;
  605|      0|			cache->write_err = 0;
  606|      0|			if (flags & FLUSH_INVALIDATE)
  ------------------
  |  |  576|      0|#define FLUSH_INVALIDATE	0x01
  ------------------
  |  Branch (606:8): [True: 0, False: 0]
  ------------------
  607|      0|				cache->in_use = 0;
  608|      0|		}
  609|      0|	}
  610|  1.59k|	if ((flags & FLUSH_NOLOCK) == 0)
  ------------------
  |  |  577|  1.59k|#define FLUSH_NOLOCK		0x02
  ------------------
  |  Branch (610:6): [True: 1.59k, False: 2]
  ------------------
  611|  1.59k|		mutex_unlock(data, CACHE_MTX);
  612|  1.59k|retry:
  613|  1.59k|	while (errors_found) {
  ------------------
  |  Branch (613:9): [True: 0, False: 1.59k]
  ------------------
  614|      0|		if ((flags & FLUSH_NOLOCK) == 0)
  ------------------
  |  |  577|      0|#define FLUSH_NOLOCK		0x02
  ------------------
  |  Branch (614:7): [True: 0, False: 0]
  ------------------
  615|      0|			mutex_lock(data, CACHE_MTX);
  616|      0|		errors_found = 0;
  617|      0|		for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) {
  ------------------
  |  |   94|      0|#define CACHE_SIZE 8
  ------------------
  |  Branch (617:34): [True: 0, False: 0]
  ------------------
  618|      0|			if (!cache->in_use || !cache->write_err)
  ------------------
  |  Branch (618:8): [True: 0, False: 0]
  |  Branch (618:26): [True: 0, False: 0]
  ------------------
  619|      0|				continue;
  620|      0|			errors_found = 1;
  621|      0|			if (cache->write_err && channel->write_error) {
  ------------------
  |  Branch (621:8): [True: 0, False: 0]
  |  Branch (621:28): [True: 0, False: 0]
  ------------------
  622|      0|				char *err_buf = NULL;
  623|      0|				unsigned long long err_block = cache->block;
  624|       |
  625|      0|				cache->dirty = 0;
  626|      0|				cache->in_use = 0;
  627|      0|				cache->write_err = 0;
  628|      0|				if (io_channel_alloc_buf(channel, 0,
  ------------------
  |  Branch (628:9): [True: 0, False: 0]
  ------------------
  629|      0|							 &err_buf))
  630|      0|					err_buf = NULL;
  631|      0|				else
  632|      0|					memcpy(err_buf, cache->buf,
  633|      0|					       channel->block_size);
  634|      0|				mutex_unlock(data, CACHE_MTX);
  635|      0|				(channel->write_error)(channel, err_block,
  636|      0|					1, err_buf, channel->block_size, -1,
  637|      0|					retval2);
  638|      0|				if (err_buf)
  ------------------
  |  Branch (638:9): [True: 0, False: 0]
  ------------------
  639|      0|					ext2fs_free_mem(&err_buf);
  640|      0|				goto retry;
  641|      0|			} else
  642|      0|				cache->write_err = 0;
  643|      0|		}
  644|      0|		if ((flags & FLUSH_NOLOCK) == 0)
  ------------------
  |  |  577|      0|#define FLUSH_NOLOCK		0x02
  ------------------
  |  Branch (644:7): [True: 0, False: 0]
  ------------------
  645|      0|			mutex_unlock(data, CACHE_MTX);
  646|      0|	}
  647|  1.59k|	return retval2;
  648|  1.59k|}
unix_io.c:mutex_lock:
  141|  3.72k|{
  142|  3.72k|#ifdef HAVE_PTHREAD
  143|  3.72k|	pthread_mutex_t *mtx = get_mutex(data,kind);
  144|       |
  145|  3.72k|	if (mtx)
  ------------------
  |  Branch (145:6): [True: 0, False: 3.72k]
  ------------------
  146|      0|		pthread_mutex_lock(mtx);
  147|  3.72k|#endif
  148|  3.72k|}
unix_io.c:get_mutex:
  125|  7.45k|{
  126|  7.45k|	if (data->flags & IO_FLAG_THREADS) {
  ------------------
  |  |  110|  7.45k|#define IO_FLAG_THREADS		0x0010
  ------------------
  |  Branch (126:6): [True: 0, False: 7.45k]
  ------------------
  127|      0|		switch (kind) {
  ------------------
  |  Branch (127:11): [True: 0, False: 0]
  ------------------
  128|      0|		case CACHE_MTX:
  ------------------
  |  Branch (128:3): [True: 0, False: 0]
  ------------------
  129|      0|			return &data->cache_mutex;
  130|      0|		case BOUNCE_MTX:
  ------------------
  |  Branch (130:3): [True: 0, False: 0]
  ------------------
  131|      0|			return &data->bounce_mutex;
  132|      0|		case STATS_MTX:
  ------------------
  |  Branch (132:3): [True: 0, False: 0]
  ------------------
  133|      0|			return &data->stats_mutex;
  134|      0|		}
  135|      0|	}
  136|  7.45k|	return NULL;
  137|  7.45k|}
unix_io.c:mutex_unlock:
  151|  3.72k|{
  152|  3.72k|#ifdef HAVE_PTHREAD
  153|  3.72k|	pthread_mutex_t *mtx = get_mutex(data,kind);
  154|       |
  155|  3.72k|	if (mtx)
  ------------------
  |  Branch (155:6): [True: 0, False: 3.72k]
  ------------------
  156|      0|		pthread_mutex_unlock(mtx);
  157|  3.72k|#endif
  158|  3.72k|}
unix_io.c:unix_set_blksize:
  970|  1.33k|{
  971|  1.33k|	struct unix_private_data *data;
  972|  1.33k|	errcode_t		retval = 0;
  973|       |
  974|  1.33k|	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
  ------------------
  |  |   83|  1.33k|	  if ((struct)->magic != (code)) return (code)
  |  |  ------------------
  |  |  |  Branch (83:8): [True: 0, False: 1.33k]
  |  |  ------------------
  ------------------
  975|  1.33k|	data = (struct unix_private_data *) channel->private_data;
  976|  1.33k|	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
  ------------------
  |  |   83|  1.33k|	  if ((struct)->magic != (code)) return (code)
  |  |  ------------------
  |  |  |  Branch (83:8): [True: 0, False: 1.33k]
  |  |  ------------------
  ------------------
  977|       |
  978|  1.33k|	if (channel->block_size != blksize) {
  ------------------
  |  Branch (978:6): [True: 2, False: 1.32k]
  ------------------
  979|      2|		mutex_lock(data, CACHE_MTX);
  980|      2|		mutex_lock(data, BOUNCE_MTX);
  981|      2|#ifndef NO_IO_CACHE
  982|      2|		if ((retval = flush_cached_blocks(channel, data, FLUSH_NOLOCK))){
  ------------------
  |  |  577|      2|#define FLUSH_NOLOCK		0x02
  ------------------
  |  Branch (982:7): [True: 0, False: 2]
  ------------------
  983|      0|			mutex_unlock(data, BOUNCE_MTX);
  984|      0|			mutex_unlock(data, CACHE_MTX);
  985|      0|			return retval;
  986|      0|		}
  987|      2|#endif
  988|       |
  989|      2|		channel->block_size = blksize;
  990|      2|		free_cache(data);
  991|      2|		retval = alloc_cache(channel, data);
  992|      2|		mutex_unlock(data, BOUNCE_MTX);
  993|      2|		mutex_unlock(data, CACHE_MTX);
  994|      2|	}
  995|  1.33k|	return retval;
  996|  1.33k|}
unix_io.c:unix_read_blk:
 1099|  1.11k|{
 1100|  1.11k|	return unix_read_blk64(channel, block, count, buf);
 1101|  1.11k|}
unix_io.c:unix_get_stats:
  161|    165|{
  162|    165|	errcode_t	retval = 0;
  163|       |
  164|    165|	struct unix_private_data *data;
  165|       |
  166|    165|	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
  ------------------
  |  |   83|    165|	  if ((struct)->magic != (code)) return (code)
  |  |  ------------------
  |  |  |  Branch (83:8): [True: 0, False: 165]
  |  |  ------------------
  ------------------
  167|    165|	data = (struct unix_private_data *) channel->private_data;
  168|    165|	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
  ------------------
  |  |   83|    165|	  if ((struct)->magic != (code)) return (code)
  |  |  ------------------
  |  |  |  Branch (83:8): [True: 0, False: 165]
  |  |  ------------------
  ------------------
  169|       |
  170|    165|	if (stats) {
  ------------------
  |  Branch (170:6): [True: 165, False: 0]
  ------------------
  171|    165|		mutex_lock(data, STATS_MTX);
  172|    165|		*stats = &data->io_stats;
  173|    165|		mutex_unlock(data, STATS_MTX);
  174|    165|	}
  175|       |
  176|    165|	return retval;
  177|    165|}
unix_io.c:unix_read_blk64:
 1000|  1.20k|{
 1001|  1.20k|	struct unix_private_data *data;
 1002|  1.20k|	struct unix_cache *cache;
 1003|  1.20k|	errcode_t	retval;
 1004|  1.20k|	char		*cp;
 1005|  1.20k|	int		i, j;
 1006|       |
 1007|  1.20k|	EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL);
  ------------------
  |  |   83|  1.20k|	  if ((struct)->magic != (code)) return (code)
  |  |  ------------------
  |  |  |  Branch (83:8): [True: 0, False: 1.20k]
  |  |  ------------------
  ------------------
 1008|  1.20k|	data = (struct unix_private_data *) channel->private_data;
 1009|  1.20k|	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
  ------------------
  |  |   83|  1.20k|	  if ((struct)->magic != (code)) return (code)
  |  |  ------------------
  |  |  |  Branch (83:8): [True: 0, False: 1.20k]
  |  |  ------------------
  ------------------
 1010|       |
 1011|       |#ifdef NO_IO_CACHE
 1012|       |	return raw_read_blk(channel, data, block, count, buf);
 1013|       |#else
 1014|  1.20k|	if (data->flags & IO_FLAG_NOCACHE)
  ------------------
  |  |  111|  1.20k|#define IO_FLAG_NOCACHE		0x0020
  ------------------
  |  Branch (1014:6): [True: 0, False: 1.20k]
  ------------------
 1015|      0|		return raw_read_blk(channel, data, block, count, buf);
 1016|       |	/*
 1017|       |	 * If we're doing an odd-sized read or a very large read,
 1018|       |	 * flush out the cache and then do a direct read.
 1019|       |	 */
 1020|  1.20k|	if (count < 0 || count > WRITE_DIRECT_SIZE) {
  ------------------
  |  |   95|    412|#define WRITE_DIRECT_SIZE 4	/* Must be smaller than CACHE_SIZE */
  ------------------
  |  Branch (1020:6): [True: 797, False: 412]
  |  Branch (1020:19): [True: 1, False: 411]
  ------------------
 1021|    798|		if ((retval = flush_cached_blocks(channel, data, 0)))
  ------------------
  |  Branch (1021:7): [True: 0, False: 798]
  ------------------
 1022|      0|			return retval;
 1023|    798|		return raw_read_blk(channel, data, block, count, buf);
 1024|    798|	}
 1025|       |
 1026|    411|	cp = buf;
 1027|    411|	mutex_lock(data, CACHE_MTX);
 1028|    777|	while (count > 0) {
  ------------------
  |  Branch (1028:9): [True: 411, False: 366]
  ------------------
 1029|       |		/* If it's in the cache, use it! */
 1030|    411|		if ((cache = find_cached_block(data, block, NULL))) {
  ------------------
  |  Branch (1030:7): [True: 43, False: 368]
  ------------------
 1031|       |#ifdef DEBUG
 1032|       |			printf("Using cached block %lu\n", block);
 1033|       |#endif
 1034|     43|			memcpy(cp, cache->buf, channel->block_size);
 1035|     43|			count--;
 1036|     43|			block++;
 1037|     43|			cp += channel->block_size;
 1038|     43|			continue;
 1039|     43|		}
 1040|       |
 1041|       |		/*
 1042|       |		 * Find the number of uncached blocks so we can do a
 1043|       |		 * single read request
 1044|       |		 */
 1045|    368|		for (i=1; i < count; i++)
  ------------------
  |  Branch (1045:13): [True: 0, False: 368]
  ------------------
 1046|      0|			if (find_cached_block(data, block+i, NULL))
  ------------------
  |  Branch (1046:8): [True: 0, False: 0]
  ------------------
 1047|      0|				break;
 1048|       |#ifdef DEBUG
 1049|       |		printf("Reading %d blocks starting at %lu\n", i, block);
 1050|       |#endif
 1051|    368|		mutex_unlock(data, CACHE_MTX);
 1052|    368|		if ((retval = raw_read_blk(channel, data, block, i, cp)))
  ------------------
  |  Branch (1052:7): [True: 45, False: 323]
  ------------------
 1053|     45|			return retval;
 1054|    323|		mutex_lock(data, CACHE_MTX);
 1055|       |
 1056|       |		/* Save the results in the cache */
 1057|    646|		for (j=0; j < i; j++) {
  ------------------
  |  Branch (1057:13): [True: 323, False: 323]
  ------------------
 1058|    323|			if (!find_cached_block(data, block, &cache)) {
  ------------------
  |  Branch (1058:8): [True: 323, False: 0]
  ------------------
 1059|    323|				retval = reuse_cache(channel, data,
 1060|    323|						     cache, block);
 1061|    323|				if (retval)
  ------------------
  |  Branch (1061:9): [True: 0, False: 323]
  ------------------
 1062|      0|					goto call_write_handler;
 1063|    323|				memcpy(cache->buf, cp, channel->block_size);
 1064|    323|			}
 1065|    323|			count--;
 1066|    323|			block++;
 1067|    323|			cp += channel->block_size;
 1068|    323|		}
 1069|    323|	}
 1070|    366|	mutex_unlock(data, CACHE_MTX);
 1071|    366|	return 0;
 1072|       |
 1073|      0|call_write_handler:
 1074|      0|	if (cache->write_err && channel->write_error) {
  ------------------
  |  Branch (1074:6): [True: 0, False: 0]
  |  Branch (1074:26): [True: 0, False: 0]
  ------------------
 1075|      0|		char *err_buf = NULL;
 1076|      0|		unsigned long long err_block = cache->block;
 1077|       |
 1078|      0|		cache->dirty = 0;
 1079|      0|		cache->in_use = 0;
 1080|      0|		cache->write_err = 0;
 1081|      0|		if (io_channel_alloc_buf(channel, 0, &err_buf))
  ------------------
  |  Branch (1081:7): [True: 0, False: 0]
  ------------------
 1082|      0|			err_buf = NULL;
 1083|      0|		else
 1084|      0|			memcpy(err_buf, cache->buf, channel->block_size);
 1085|      0|		mutex_unlock(data, CACHE_MTX);
 1086|      0|		(channel->write_error)(channel, err_block, 1, err_buf,
 1087|      0|				       channel->block_size, -1,
 1088|      0|				       retval);
 1089|      0|		if (err_buf)
  ------------------
  |  Branch (1089:7): [True: 0, False: 0]
  ------------------
 1090|      0|			ext2fs_free_mem(&err_buf);
 1091|      0|	} else
 1092|      0|		mutex_unlock(data, CACHE_MTX);
 1093|      0|	return retval;
 1094|    411|#endif /* NO_IO_CACHE */
 1095|    411|}
unix_io.c:raw_read_blk:
  186|  1.16k|{
  187|  1.16k|	errcode_t	retval;
  188|  1.16k|	ssize_t		size;
  189|  1.16k|	ext2_loff_t	location;
  190|  1.16k|	int		actual = 0;
  191|  1.16k|	unsigned char	*buf = bufv;
  192|  1.16k|	ssize_t		really_read = 0;
  193|  1.16k|	unsigned long long aligned_blk;
  194|  1.16k|	int		align_size, offset;
  195|       |
  196|  1.16k|	size = (count < 0) ? -count : (ext2_loff_t) count * channel->block_size;
  ------------------
  |  Branch (196:9): [True: 797, False: 369]
  ------------------
  197|  1.16k|	mutex_lock(data, STATS_MTX);
  198|  1.16k|	data->io_stats.bytes_read += size;
  199|  1.16k|	mutex_unlock(data, STATS_MTX);
  200|  1.16k|	location = ((ext2_loff_t) block * channel->block_size) + data->offset;
  201|       |
  202|  1.16k|	if (data->flags & IO_FLAG_FORCE_BOUNCE)
  ------------------
  |  |  109|  1.16k|#define IO_FLAG_FORCE_BOUNCE	0x0008
  ------------------
  |  Branch (202:6): [True: 0, False: 1.16k]
  ------------------
  203|      0|		goto bounce_read;
  204|       |
  205|  1.16k|#ifdef HAVE_PREAD64
  206|       |	/* Try an aligned pread */
  207|  1.16k|	if ((channel->align == 0) ||
  ------------------
  |  Branch (207:6): [True: 1.16k, False: 0]
  ------------------
  208|  1.16k|	    (IS_ALIGNED(buf, channel->align) &&
  ------------------
  |  |  115|      0|#define IS_ALIGNED(n, align) ((((uintptr_t) n) & \
  |  |  ------------------
  |  |  |  Branch (115:30): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|			       ((uintptr_t) ((align)-1))) == 0)
  ------------------
  209|      0|	     IS_ALIGNED(location, channel->align) &&
  ------------------
  |  |  115|      0|#define IS_ALIGNED(n, align) ((((uintptr_t) n) & \
  |  |  ------------------
  |  |  |  Branch (115:30): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|			       ((uintptr_t) ((align)-1))) == 0)
  ------------------
  210|  1.16k|	     IS_ALIGNED(size, channel->align))) {
  ------------------
  |  |  115|      0|#define IS_ALIGNED(n, align) ((((uintptr_t) n) & \
  |  |  ------------------
  |  |  |  Branch (115:30): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|			       ((uintptr_t) ((align)-1))) == 0)
  ------------------
  211|  1.16k|		actual = pread64(data->dev, buf, size, location);
  212|  1.16k|		if (actual == size)
  ------------------
  |  Branch (212:7): [True: 1.10k, False: 65]
  ------------------
  213|  1.10k|			return 0;
  214|     65|		actual = 0;
  215|     65|	}
  216|       |#elif HAVE_PREAD
  217|       |	/* Try an aligned pread */
  218|       |	if ((sizeof(off_t) >= sizeof(ext2_loff_t)) &&
  219|       |	    ((channel->align == 0) ||
  220|       |	     (IS_ALIGNED(buf, channel->align) &&
  221|       |	      IS_ALIGNED(location, channel->align) &&
  222|       |	      IS_ALIGNED(size, channel->align)))) {
  223|       |		actual = pread(data->dev, buf, size, location);
  224|       |		if (actual == size)
  225|       |			return 0;
  226|       |		actual = 0;
  227|       |	}
  228|       |#endif /* HAVE_PREAD */
  229|       |
  230|     65|	if ((channel->align == 0) ||
  ------------------
  |  Branch (230:6): [True: 65, False: 0]
  ------------------
  231|     65|	    (IS_ALIGNED(buf, channel->align) &&
  ------------------
  |  |  115|      0|#define IS_ALIGNED(n, align) ((((uintptr_t) n) & \
  |  |  ------------------
  |  |  |  Branch (115:30): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|			       ((uintptr_t) ((align)-1))) == 0)
  ------------------
  232|      0|	     IS_ALIGNED(location, channel->align) &&
  ------------------
  |  |  115|      0|#define IS_ALIGNED(n, align) ((((uintptr_t) n) & \
  |  |  ------------------
  |  |  |  Branch (115:30): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|			       ((uintptr_t) ((align)-1))) == 0)
  ------------------
  233|     65|	     IS_ALIGNED(size, channel->align))) {
  ------------------
  |  |  115|      0|#define IS_ALIGNED(n, align) ((((uintptr_t) n) & \
  |  |  ------------------
  |  |  |  Branch (115:30): [True: 0, False: 0]
  |  |  ------------------
  |  |  116|      0|			       ((uintptr_t) ((align)-1))) == 0)
  ------------------
  234|     65|		mutex_lock(data, BOUNCE_MTX);
  235|     65|		if (ext2fs_llseek(data->dev, location, SEEK_SET) < 0) {
  ------------------
  |  Branch (235:7): [True: 1, False: 64]
  ------------------
  236|      1|			retval = errno ? errno : EXT2_ET_LLSEEK_FAILED;
  ------------------
  |  |   77|      1|#define EXT2_ET_LLSEEK_FAILED                    (2133571397L)
  ------------------
  237|      1|			goto error_unlock;
  238|      1|		}
  239|     64|		actual = read(data->dev, buf, size);
  240|     64|		if (actual != size) {
  ------------------
  |  Branch (240:7): [True: 64, False: 0]
  ------------------
  241|     64|		short_read:
  242|     64|			if (actual < 0) {
  ------------------
  |  Branch (242:8): [True: 0, False: 64]
  ------------------
  243|      0|				retval = errno;
  244|      0|				actual = 0;
  245|      0|			} else
  246|     64|				retval = EXT2_ET_SHORT_READ;
  ------------------
  |  |   44|     64|#define EXT2_ET_SHORT_READ                       (2133571364L)
  ------------------
  247|     64|			goto error_unlock;
  248|     64|		}
  249|      0|		goto success_unlock;
  250|     64|	}
  251|       |
  252|       |#ifdef ALIGN_DEBUG
  253|       |	printf("raw_read_blk: O_DIRECT fallback: %p %lu\n", buf,
  254|       |	       (unsigned long) size);
  255|       |#endif
  256|       |
  257|       |	/*
  258|       |	 * The buffer or size which we're trying to read isn't aligned
  259|       |	 * to the O_DIRECT rules, so we need to do this the hard way...
  260|       |	 */
  261|      0|bounce_read:
  262|      0|	if (channel->align == 0)
  ------------------
  |  Branch (262:6): [True: 0, False: 0]
  ------------------
  263|      0|		channel->align = 1;
  264|      0|	if ((channel->block_size > channel->align) &&
  ------------------
  |  Branch (264:6): [True: 0, False: 0]
  ------------------
  265|      0|	    (channel->block_size % channel->align) == 0)
  ------------------
  |  Branch (265:6): [True: 0, False: 0]
  ------------------
  266|      0|		align_size = channel->block_size;
  267|      0|	else
  268|      0|		align_size = channel->align;
  269|      0|	aligned_blk = location / align_size;
  270|      0|	offset = location % align_size;
  271|       |
  272|      0|	mutex_lock(data, BOUNCE_MTX);
  273|      0|	if (ext2fs_llseek(data->dev, aligned_blk * align_size, SEEK_SET) < 0) {
  ------------------
  |  Branch (273:6): [True: 0, False: 0]
  ------------------
  274|      0|		retval = errno ? errno : EXT2_ET_LLSEEK_FAILED;
  ------------------
  |  |   77|      0|#define EXT2_ET_LLSEEK_FAILED                    (2133571397L)
  ------------------
  275|      0|		goto error_unlock;
  276|      0|	}
  277|      0|	while (size > 0) {
  ------------------
  |  Branch (277:9): [True: 0, False: 0]
  ------------------
  278|      0|		actual = read(data->dev, data->bounce, align_size);
  279|      0|		if (actual != align_size) {
  ------------------
  |  Branch (279:7): [True: 0, False: 0]
  ------------------
  280|      0|			actual = really_read;
  281|      0|			buf -= really_read;
  282|      0|			size += really_read;
  283|      0|			goto short_read;
  284|      0|		}
  285|      0|		if ((actual + offset) > align_size)
  ------------------
  |  Branch (285:7): [True: 0, False: 0]
  ------------------
  286|      0|			actual = align_size - offset;
  287|      0|		if (actual > size)
  ------------------
  |  Branch (287:7): [True: 0, False: 0]
  ------------------
  288|      0|			actual = size;
  289|      0|		memcpy(buf, (char *)data->bounce + offset, actual);
  290|       |
  291|      0|		really_read += actual;
  292|      0|		size -= actual;
  293|      0|		buf += actual;
  294|      0|		offset = 0;
  295|      0|		aligned_blk++;
  296|      0|	}
  297|      0|success_unlock:
  298|      0|	mutex_unlock(data, BOUNCE_MTX);
  299|      0|	return 0;
  300|       |
  301|     65|error_unlock:
  302|     65|	mutex_unlock(data, BOUNCE_MTX);
  303|     65|	if (actual >= 0 && actual < size)
  ------------------
  |  Branch (303:6): [True: 65, False: 0]
  |  Branch (303:21): [True: 65, False: 0]
  ------------------
  304|     65|		memset((char *) buf+actual, 0, size-actual);
  305|     65|	if (channel->read_error)
  ------------------
  |  Branch (305:6): [True: 0, False: 65]
  ------------------
  306|      0|		retval = (channel->read_error)(channel, block, count, buf,
  307|      0|					       size, actual, retval);
  308|     65|	return retval;
  309|      0|}
unix_io.c:find_cached_block:
  526|    734|{
  527|    734|	struct unix_cache	*cache, *unused_cache, *oldest_cache;
  528|    734|	int			i;
  529|       |
  530|    734|	unused_cache = oldest_cache = 0;
  531|  6.26k|	for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) {
  ------------------
  |  |   94|  6.26k|#define CACHE_SIZE 8
  ------------------
  |  Branch (531:33): [True: 5.57k, False: 691]
  ------------------
  532|  5.57k|		if (!cache->in_use) {
  ------------------
  |  Branch (532:7): [True: 5.46k, False: 107]
  ------------------
  533|  5.46k|			if (!unused_cache)
  ------------------
  |  Branch (533:8): [True: 691, False: 4.77k]
  ------------------
  534|    691|				unused_cache = cache;
  535|  5.46k|			continue;
  536|  5.46k|		}
  537|    107|		if (cache->block == block) {
  ------------------
  |  Branch (537:7): [True: 43, False: 64]
  ------------------
  538|     43|			cache->access_time = ++data->access_time;
  539|     43|			return cache;
  540|     43|		}
  541|     64|		if (!oldest_cache ||
  ------------------
  |  Branch (541:7): [True: 64, False: 0]
  ------------------
  542|     64|		    (cache->access_time < oldest_cache->access_time))
  ------------------
  |  Branch (542:7): [True: 0, False: 0]
  ------------------
  543|     64|			oldest_cache = cache;
  544|     64|	}
  545|    691|	if (eldest)
  ------------------
  |  Branch (545:6): [True: 323, False: 368]
  ------------------
  546|    323|		*eldest = (unused_cache) ? unused_cache : oldest_cache;
  ------------------
  |  Branch (546:13): [True: 323, False: 0]
  ------------------
  547|    691|	return 0;
  548|    734|}
unix_io.c:reuse_cache:
  556|    323|{
  557|    323|	if (cache->dirty && cache->in_use) {
  ------------------
  |  Branch (557:6): [True: 0, False: 323]
  |  Branch (557:22): [True: 0, False: 0]
  ------------------
  558|      0|		errcode_t retval;
  559|       |
  560|      0|		retval = raw_write_blk(channel, data, cache->block, 1,
  561|      0|				       cache->buf, RAW_WRITE_NO_HANDLER);
  ------------------
  |  |  311|      0|#define RAW_WRITE_NO_HANDLER	1
  ------------------
  562|      0|		if (retval) {
  ------------------
  |  Branch (562:7): [True: 0, False: 0]
  ------------------
  563|      0|			cache->write_err = 1;
  564|      0|			return retval;
  565|      0|		}
  566|      0|	}
  567|       |
  568|    323|	cache->in_use = 1;
  569|    323|	cache->dirty = 0;
  570|    323|	cache->write_err = 0;
  571|    323|	cache->block = block;
  572|    323|	cache->access_time = ++data->access_time;
  573|    323|	return 0;
  574|    323|}
unix_io.c:unix_cache_readahead:
 1190|      8|{
 1191|      8|#ifdef POSIX_FADV_WILLNEED
 1192|      8|	struct unix_private_data *data;
 1193|       |
 1194|      8|	data = (struct unix_private_data *)channel->private_data;
 1195|      8|	EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL);
  ------------------
  |  |   83|      8|	  if ((struct)->magic != (code)) return (code)
  |  |  ------------------
  |  |  |  Branch (83:8): [True: 0, False: 8]
  |  |  ------------------
  ------------------
 1196|      8|	return posix_fadvise(data->dev,
 1197|      8|			     (ext2_loff_t)block * channel->block_size + data->offset,
 1198|      8|			     (ext2_loff_t)count * channel->block_size,
 1199|      8|			     POSIX_FADV_WILLNEED);
 1200|       |#else
 1201|       |	return EXT2_ET_OP_NOT_SUPPORTED;
 1202|       |#endif
 1203|      8|}

LLVMFuzzerTestOneInput:
   22|    797|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   23|    797|  static const char* fname = "/tmp/ext2_test_file";
   24|       |
   25|       |  // Write our data to a temp file.
   26|    797|  int fd = open(fname, O_RDWR|O_CREAT|O_TRUNC);
   27|    797|  write(fd, data, size);
   28|    797|  close(fd);
   29|       |
   30|    797|  ext2_filsys fs;
   31|    797|  errcode_t retval = ext2fs_open(
   32|    797|      fname,
   33|    797|      EXT2_FLAG_IGNORE_CSUM_ERRORS, 0, 0,
  ------------------
  |  |  216|    797|#define EXT2_FLAG_IGNORE_CSUM_ERRORS	0x200000
  ------------------
   34|    797|      unix_io_manager,
   35|    797|      &fs);
   36|       |
   37|    797|  if (!retval) {
  ------------------
  |  Branch (37:7): [True: 303, False: 494]
  ------------------
   38|    303|    retval = ext2fs_check_directory(fs, EXT2_ROOT_INO);
  ------------------
  |  |   67|    303|#define EXT2_ROOT_INO		 2	/* Root inode */
  ------------------
   39|    303|    ext2fs_close(fs);
   40|    303|  }
   41|       |
   42|    797|  return 0;
   43|    797|}

