mirror of https://github.com/vitalif/e2fsprogs
debugfs: clean up feature test macros with predicate functions
Create separate predicate functions to test/set/clear feature flags, thereby replacing the wordy old macros. Furthermore, clean out the places where we open-coded feature tests. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>debian
parent
21e37be65b
commit
4ee2669982
|
@ -42,9 +42,8 @@ int main (int argc, char *argv[])
|
||||||
argv[1]);
|
argv[1]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!EXT2_HAS_INCOMPAT_FEATURE(fs->super,
|
if (!ext2fs_has_feature_encrypt(fs->super)) {
|
||||||
EXT4_FEATURE_INCOMPAT_ENCRYPT)) {
|
ext2fs_set_feature_encrypt(fs->super);
|
||||||
fs->super->s_feature_incompat |= EXT4_FEATURE_INCOMPAT_ENCRYPT;
|
|
||||||
fs->super->s_encrypt_algos[0] =
|
fs->super->s_encrypt_algos[0] =
|
||||||
EXT4_ENCRYPTION_MODE_AES_256_XTS;
|
EXT4_ENCRYPTION_MODE_AES_256_XTS;
|
||||||
fs->super->s_encrypt_algos[1] =
|
fs->super->s_encrypt_algos[1] =
|
||||||
|
|
|
@ -436,8 +436,7 @@ void do_show_super_stats(int argc, char *argv[])
|
||||||
return;
|
return;
|
||||||
out = open_pager();
|
out = open_pager();
|
||||||
|
|
||||||
if (EXT2_HAS_RO_COMPAT_FEATURE(current_fs->super,
|
if (ext2fs_has_feature_bigalloc(current_fs->super))
|
||||||
EXT4_FEATURE_RO_COMPAT_BIGALLOC))
|
|
||||||
units = "cluster";
|
units = "cluster";
|
||||||
|
|
||||||
list_super2(current_fs->super, out);
|
list_super2(current_fs->super, out);
|
||||||
|
@ -893,8 +892,7 @@ void internal_dump_inode(FILE *out, const char *prefix,
|
||||||
(struct ext2_inode_large *) inode);
|
(struct ext2_inode_large *) inode);
|
||||||
dump_inode_attributes(out, inode_num);
|
dump_inode_attributes(out, inode_num);
|
||||||
if (current_fs->super->s_creator_os == EXT2_OS_LINUX &&
|
if (current_fs->super->s_creator_os == EXT2_OS_LINUX &&
|
||||||
current_fs->super->s_feature_ro_compat &
|
ext2fs_has_feature_metadata_csum(current_fs->super)) {
|
||||||
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) {
|
|
||||||
__u32 crc = inode->i_checksum_lo;
|
__u32 crc = inode->i_checksum_lo;
|
||||||
if (is_large_inode &&
|
if (is_large_inode &&
|
||||||
large_inode->i_extra_isize >=
|
large_inode->i_extra_isize >=
|
||||||
|
|
|
@ -88,8 +88,7 @@ static errcode_t journal_commit_trans(journal_transaction_t *trans)
|
||||||
commit->h_magic = ext2fs_cpu_to_be32(JFS_MAGIC_NUMBER);
|
commit->h_magic = ext2fs_cpu_to_be32(JFS_MAGIC_NUMBER);
|
||||||
commit->h_blocktype = ext2fs_cpu_to_be32(JFS_COMMIT_BLOCK);
|
commit->h_blocktype = ext2fs_cpu_to_be32(JFS_COMMIT_BLOCK);
|
||||||
commit->h_sequence = ext2fs_cpu_to_be32(trans->tid);
|
commit->h_sequence = ext2fs_cpu_to_be32(trans->tid);
|
||||||
if (JFS_HAS_COMPAT_FEATURE(trans->journal,
|
if (jfs_has_feature_checksum(trans->journal)) {
|
||||||
JFS_FEATURE_COMPAT_CHECKSUM)) {
|
|
||||||
__u32 csum_v1 = ~0;
|
__u32 csum_v1 = ~0;
|
||||||
blk64_t cblk;
|
blk64_t cblk;
|
||||||
|
|
||||||
|
@ -149,7 +148,7 @@ static errcode_t journal_commit_trans(journal_transaction_t *trans)
|
||||||
trans->flags &= ~J_TRANS_OPEN;
|
trans->flags &= ~J_TRANS_OPEN;
|
||||||
trans->block++;
|
trans->block++;
|
||||||
|
|
||||||
trans->fs->super->s_feature_incompat |= EXT3_FEATURE_INCOMPAT_RECOVER;
|
ext2fs_set_feature_journal_needs_recovery(trans->fs->super);
|
||||||
ext2fs_mark_super_dirty(trans->fs);
|
ext2fs_mark_super_dirty(trans->fs);
|
||||||
error:
|
error:
|
||||||
if (cbh)
|
if (cbh)
|
||||||
|
@ -195,8 +194,7 @@ static errcode_t journal_add_revoke_to_trans(journal_transaction_t *trans,
|
||||||
jrb->r_header.h_sequence = ext2fs_cpu_to_be32(trans->tid);
|
jrb->r_header.h_sequence = ext2fs_cpu_to_be32(trans->tid);
|
||||||
offset = sizeof(*jrb);
|
offset = sizeof(*jrb);
|
||||||
|
|
||||||
if (JFS_HAS_INCOMPAT_FEATURE(trans->journal,
|
if (jfs_has_feature_64bit(trans->journal))
|
||||||
JFS_FEATURE_INCOMPAT_64BIT))
|
|
||||||
sz = 8;
|
sz = 8;
|
||||||
else
|
else
|
||||||
sz = 4;
|
sz = 4;
|
||||||
|
@ -229,8 +227,7 @@ static errcode_t journal_add_revoke_to_trans(journal_transaction_t *trans,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JFS_HAS_INCOMPAT_FEATURE(trans->journal,
|
if (jfs_has_feature_64bit(trans->journal))
|
||||||
JFS_FEATURE_INCOMPAT_64BIT))
|
|
||||||
*((__u64 *)(&((char *)buf)[offset])) =
|
*((__u64 *)(&((char *)buf)[offset])) =
|
||||||
ext2fs_cpu_to_be64(revoke_list[i]);
|
ext2fs_cpu_to_be64(revoke_list[i]);
|
||||||
else
|
else
|
||||||
|
@ -364,8 +361,7 @@ static errcode_t journal_add_blocks_to_trans(journal_transaction_t *trans,
|
||||||
*((__u32 *)buf) = 0;
|
*((__u32 *)buf) = 0;
|
||||||
jdbt->t_flags |= ext2fs_cpu_to_be16(JFS_FLAG_ESCAPE);
|
jdbt->t_flags |= ext2fs_cpu_to_be16(JFS_FLAG_ESCAPE);
|
||||||
}
|
}
|
||||||
if (JFS_HAS_INCOMPAT_FEATURE(trans->journal,
|
if (jfs_has_feature_64bit(trans->journal))
|
||||||
JFS_FEATURE_INCOMPAT_64BIT))
|
|
||||||
jdbt->t_blocknr_high = ext2fs_cpu_to_be32(block_list[i] >> 32);
|
jdbt->t_blocknr_high = ext2fs_cpu_to_be32(block_list[i] >> 32);
|
||||||
jbd2_block_tag_csum_set(trans->journal, jdbt, data_bh,
|
jbd2_block_tag_csum_set(trans->journal, jdbt, data_bh,
|
||||||
trans->tid);
|
trans->tid);
|
||||||
|
@ -421,8 +417,7 @@ static blk64_t journal_guess_blocks(journal_t *journal, blk64_t data_blocks,
|
||||||
bs = journal->j_blocksize;
|
bs = journal->j_blocksize;
|
||||||
if (journal_has_csum_v2or3(journal))
|
if (journal_has_csum_v2or3(journal))
|
||||||
bs -= sizeof(struct journal_revoke_tail);
|
bs -= sizeof(struct journal_revoke_tail);
|
||||||
sz = JFS_HAS_INCOMPAT_FEATURE(journal, JFS_FEATURE_INCOMPAT_64BIT) ?
|
sz = jfs_has_feature_64bit(journal) ? sizeof(__u64) : sizeof(__u32);
|
||||||
sizeof(__u64) : sizeof(__u32);
|
|
||||||
ret += revoke_blocks * sz / bs;
|
ret += revoke_blocks * sz / bs;
|
||||||
|
|
||||||
/* Estimate # of data blocks */
|
/* Estimate # of data blocks */
|
||||||
|
@ -489,10 +484,8 @@ static errcode_t journal_close_trans(journal_transaction_t *trans)
|
||||||
trans->magic = 0;
|
trans->magic = 0;
|
||||||
|
|
||||||
/* Mark ourselves as needing recovery */
|
/* Mark ourselves as needing recovery */
|
||||||
if (!(EXT2_HAS_INCOMPAT_FEATURE(trans->fs->super,
|
if (!ext2fs_has_feature_journal_needs_recovery(trans->fs->super)) {
|
||||||
EXT3_FEATURE_INCOMPAT_RECOVER))) {
|
ext2fs_set_feature_journal_needs_recovery(trans->fs->super);
|
||||||
trans->fs->super->s_feature_incompat |=
|
|
||||||
EXT3_FEATURE_INCOMPAT_RECOVER;
|
|
||||||
ext2fs_mark_super_dirty(trans->fs);
|
ext2fs_mark_super_dirty(trans->fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,8 +503,7 @@ static errcode_t journal_write(journal_t *journal,
|
||||||
errcode_t err;
|
errcode_t err;
|
||||||
|
|
||||||
if (revoke_len > 0) {
|
if (revoke_len > 0) {
|
||||||
journal->j_superblock->s_feature_incompat |=
|
jfs_set_feature_revoke(journal);
|
||||||
ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_REVOKE);
|
|
||||||
mark_buffer_dirty(journal->j_sb_buffer);
|
mark_buffer_dirty(journal->j_sb_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -774,33 +766,26 @@ static void update_journal_csum(journal_t *journal, int ver)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (journal->j_tail != 0 ||
|
if (journal->j_tail != 0 ||
|
||||||
EXT2_HAS_INCOMPAT_FEATURE(journal->j_fs_dev->k_fs->super,
|
ext2fs_has_feature_journal_needs_recovery(
|
||||||
EXT3_FEATURE_INCOMPAT_RECOVER)) {
|
journal->j_fs_dev->k_fs->super)) {
|
||||||
printf("Journal needs recovery, will not add csums.\n");
|
printf("Journal needs recovery, will not add csums.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* metadata_csum implies journal csum v3 */
|
/* metadata_csum implies journal csum v3 */
|
||||||
jsb = journal->j_superblock;
|
jsb = journal->j_superblock;
|
||||||
if (EXT2_HAS_RO_COMPAT_FEATURE(journal->j_fs_dev->k_fs->super,
|
if (ext2fs_has_feature_metadata_csum(journal->j_fs_dev->k_fs->super)) {
|
||||||
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
|
|
||||||
printf("Setting csum v%d\n", ver);
|
printf("Setting csum v%d\n", ver);
|
||||||
switch (ver) {
|
switch (ver) {
|
||||||
case 2:
|
case 2:
|
||||||
journal->j_superblock->s_feature_incompat &=
|
jfs_clear_feature_csum3(journal);
|
||||||
ext2fs_cpu_to_be32(~JFS_FEATURE_INCOMPAT_CSUM_V3);
|
jfs_set_feature_csum2(journal);
|
||||||
journal->j_superblock->s_feature_incompat |=
|
jfs_clear_feature_checksum(journal);
|
||||||
ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_CSUM_V2);
|
|
||||||
journal->j_superblock->s_feature_compat &=
|
|
||||||
ext2fs_cpu_to_be32(~JFS_FEATURE_COMPAT_CHECKSUM);
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
journal->j_superblock->s_feature_incompat &=
|
jfs_set_feature_csum3(journal);
|
||||||
ext2fs_cpu_to_be32(~JFS_FEATURE_INCOMPAT_CSUM_V2);
|
jfs_clear_feature_csum2(journal);
|
||||||
journal->j_superblock->s_feature_incompat |=
|
jfs_clear_feature_checksum(journal);
|
||||||
ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_CSUM_V3);
|
|
||||||
journal->j_superblock->s_feature_compat &=
|
|
||||||
ext2fs_cpu_to_be32(~JFS_FEATURE_COMPAT_CHECKSUM);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("Unknown checksum v%d\n", ver);
|
printf("Unknown checksum v%d\n", ver);
|
||||||
|
@ -810,11 +795,9 @@ static void update_journal_csum(journal_t *journal, int ver)
|
||||||
journal->j_csum_seed = jbd2_chksum(journal, ~0, jsb->s_uuid,
|
journal->j_csum_seed = jbd2_chksum(journal, ~0, jsb->s_uuid,
|
||||||
sizeof(jsb->s_uuid));
|
sizeof(jsb->s_uuid));
|
||||||
} else {
|
} else {
|
||||||
journal->j_superblock->s_feature_compat |=
|
jfs_clear_feature_csum3(journal);
|
||||||
ext2fs_cpu_to_be32(JFS_FEATURE_COMPAT_CHECKSUM);
|
jfs_clear_feature_csum2(journal);
|
||||||
journal->j_superblock->s_feature_incompat &=
|
jfs_set_feature_checksum(journal);
|
||||||
ext2fs_cpu_to_be32(~(JFS_FEATURE_INCOMPAT_CSUM_V2 |
|
|
||||||
JFS_FEATURE_INCOMPAT_CSUM_V3));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -833,18 +816,15 @@ static void update_uuid(journal_t *journal)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fs = journal->j_fs_dev->k_fs;
|
fs = journal->j_fs_dev->k_fs;
|
||||||
if (!EXT2_HAS_INCOMPAT_FEATURE(fs->super,
|
if (!ext2fs_has_feature_64bit(fs->super))
|
||||||
EXT4_FEATURE_INCOMPAT_64BIT))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (JFS_HAS_INCOMPAT_FEATURE(journal, JFS_FEATURE_INCOMPAT_64BIT) &&
|
if (jfs_has_feature_64bit(journal) &&
|
||||||
EXT2_HAS_INCOMPAT_FEATURE(fs->super,
|
ext2fs_has_feature_64bit(fs->super))
|
||||||
EXT4_FEATURE_INCOMPAT_64BIT))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (journal->j_tail != 0 ||
|
if (journal->j_tail != 0 ||
|
||||||
EXT2_HAS_INCOMPAT_FEATURE(fs->super,
|
ext2fs_has_feature_journal_needs_recovery(fs->super)) {
|
||||||
EXT3_FEATURE_INCOMPAT_RECOVER)) {
|
|
||||||
printf("Journal needs recovery, will not set 64bit.\n");
|
printf("Journal needs recovery, will not set 64bit.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -858,24 +838,21 @@ static void update_64bit_flag(journal_t *journal)
|
||||||
if (journal->j_format_version < 2)
|
if (journal->j_format_version < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!EXT2_HAS_INCOMPAT_FEATURE(journal->j_fs_dev->k_fs->super,
|
if (!ext2fs_has_feature_64bit(journal->j_fs_dev->k_fs->super))
|
||||||
EXT4_FEATURE_INCOMPAT_64BIT))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (JFS_HAS_INCOMPAT_FEATURE(journal, JFS_FEATURE_INCOMPAT_64BIT) &&
|
if (jfs_has_feature_64bit(journal) &&
|
||||||
EXT2_HAS_INCOMPAT_FEATURE(journal->j_fs_dev->k_fs->super,
|
ext2fs_has_feature_64bit(journal->j_fs_dev->k_fs->super))
|
||||||
EXT4_FEATURE_INCOMPAT_64BIT))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (journal->j_tail != 0 ||
|
if (journal->j_tail != 0 ||
|
||||||
EXT2_HAS_INCOMPAT_FEATURE(journal->j_fs_dev->k_fs->super,
|
ext2fs_has_feature_journal_needs_recovery(
|
||||||
EXT3_FEATURE_INCOMPAT_RECOVER)) {
|
journal->j_fs_dev->k_fs->super)) {
|
||||||
printf("Journal needs recovery, will not set 64bit.\n");
|
printf("Journal needs recovery, will not set 64bit.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
journal->j_superblock->s_feature_incompat |=
|
jfs_set_feature_64bit(journal);
|
||||||
ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_64BIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_journal_open(int argc, char *argv[])
|
void do_journal_open(int argc, char *argv[])
|
||||||
|
@ -894,8 +871,7 @@ void do_journal_open(int argc, char *argv[])
|
||||||
printf("Journal is already open.\n");
|
printf("Journal is already open.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!EXT2_HAS_COMPAT_FEATURE(current_fs->super,
|
if (!ext2fs_has_feature_journal(current_fs->super)) {
|
||||||
EXT3_FEATURE_COMPAT_HAS_JOURNAL)) {
|
|
||||||
printf("Journalling is not enabled on this filesystem.\n");
|
printf("Journalling is not enabled on this filesystem.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -978,8 +954,7 @@ void do_journal_run(int argc EXT2FS_ATTR((unused)), char *argv[])
|
||||||
if (err)
|
if (err)
|
||||||
com_err("journal_run", err, "while recovering journal");
|
com_err("journal_run", err, "while recovering journal");
|
||||||
else {
|
else {
|
||||||
current_fs->super->s_feature_incompat &=
|
ext2fs_clear_feature_journal_needs_recovery(current_fs->super);
|
||||||
~EXT3_FEATURE_INCOMPAT_RECOVER;
|
|
||||||
ext2fs_mark_super_dirty(current_fs);
|
ext2fs_mark_super_dirty(current_fs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,8 +145,7 @@ static void filefrag(ext2_ino_t ino, struct ext2_inode *inode,
|
||||||
if (fs->options & VERBOSE_OPT) {
|
if (fs->options & VERBOSE_OPT) {
|
||||||
blk64_t num_blocks = ext2fs_inode_i_blocks(current_fs, inode);
|
blk64_t num_blocks = ext2fs_inode_i_blocks(current_fs, inode);
|
||||||
|
|
||||||
if (!(current_fs->super->s_feature_ro_compat &
|
if (!ext2fs_has_feature_huge_file(current_fs->super) ||
|
||||||
EXT4_FEATURE_RO_COMPAT_HUGE_FILE) ||
|
|
||||||
!(inode->i_flags & EXT4_HUGE_FILE_FL))
|
!(inode->i_flags & EXT4_HUGE_FILE_FL))
|
||||||
num_blocks /= current_fs->blocksize / 512;
|
num_blocks /= current_fs->blocksize / 512;
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,7 @@ static void htree_dump_leaf_node(ext2_filsys fs, ext2_ino_t ino,
|
||||||
int hash_alg;
|
int hash_alg;
|
||||||
int csum_size = 0;
|
int csum_size = 0;
|
||||||
|
|
||||||
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
|
if (ext2fs_has_feature_metadata_csum(fs->super))
|
||||||
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
|
|
||||||
csum_size = sizeof(struct ext2_dir_entry_tail);
|
csum_size = sizeof(struct ext2_dir_entry_tail);
|
||||||
|
|
||||||
errcode = ext2fs_bmap2(fs, ino, inode, buf, 0, blk, 0, &pblk);
|
errcode = ext2fs_bmap2(fs, ino, inode, buf, 0, blk, 0, &pblk);
|
||||||
|
@ -156,8 +155,7 @@ static void htree_dump_int_node(ext2_filsys fs, ext2_ino_t ino,
|
||||||
remainder -= sizeof(struct ext2_dx_root_info) + 24;
|
remainder -= sizeof(struct ext2_dx_root_info) + 24;
|
||||||
else
|
else
|
||||||
remainder -= 8;
|
remainder -= 8;
|
||||||
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
|
if (ext2fs_has_feature_metadata_csum(fs->super) &&
|
||||||
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) &&
|
|
||||||
remainder == sizeof(struct ext2_dx_tail)) {
|
remainder == sizeof(struct ext2_dx_tail)) {
|
||||||
tail = (struct ext2_dx_tail *)(ent + limit);
|
tail = (struct ext2_dx_tail *)(ent + limit);
|
||||||
fprintf(pager, "Checksum: 0x%08x\n",
|
fprintf(pager, "Checksum: 0x%08x\n",
|
||||||
|
|
|
@ -245,7 +245,7 @@ void wait_on_buffer(struct buffer_head *bh)
|
||||||
|
|
||||||
static void ext2fs_clear_recover(ext2_filsys fs, int error)
|
static void ext2fs_clear_recover(ext2_filsys fs, int error)
|
||||||
{
|
{
|
||||||
fs->super->s_feature_incompat &= ~EXT3_FEATURE_INCOMPAT_RECOVER;
|
ext2fs_clear_feature_journal_needs_recovery(fs->super);
|
||||||
|
|
||||||
/* if we had an error doing journal recovery, we need a full fsck */
|
/* if we had an error doing journal recovery, we need a full fsck */
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -451,8 +451,7 @@ try_backup_journal:
|
||||||
ext2fs_swap_super(&jsuper);
|
ext2fs_swap_super(&jsuper);
|
||||||
#endif
|
#endif
|
||||||
if (jsuper.s_magic != EXT2_SUPER_MAGIC ||
|
if (jsuper.s_magic != EXT2_SUPER_MAGIC ||
|
||||||
!(jsuper.s_feature_incompat &
|
!ext2fs_has_feature_journal_dev(&jsuper)) {
|
||||||
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) {
|
|
||||||
retval = EXT2_ET_LOAD_EXT_JOURNAL;
|
retval = EXT2_ET_LOAD_EXT_JOURNAL;
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
goto errout;
|
goto errout;
|
||||||
|
@ -466,8 +465,7 @@ try_backup_journal:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check the superblock checksum */
|
/* Check the superblock checksum */
|
||||||
if (jsuper.s_feature_ro_compat &
|
if (ext2fs_has_feature_metadata_csum(&jsuper)) {
|
||||||
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) {
|
|
||||||
struct struct_ext2_filsys fsx;
|
struct struct_ext2_filsys fsx;
|
||||||
struct ext2_super_block superx;
|
struct ext2_super_block superx;
|
||||||
void *p;
|
void *p;
|
||||||
|
@ -476,8 +474,7 @@ try_backup_journal:
|
||||||
memcpy(&fsx, fs, sizeof(fsx));
|
memcpy(&fsx, fs, sizeof(fsx));
|
||||||
memcpy(&superx, fs->super, sizeof(superx));
|
memcpy(&superx, fs->super, sizeof(superx));
|
||||||
fsx.super = &superx;
|
fsx.super = &superx;
|
||||||
fsx.super->s_feature_ro_compat |=
|
ext2fs_set_feature_metadata_csum(fsx.super);
|
||||||
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM;
|
|
||||||
if (!ext2fs_superblock_csum_verify(&fsx, p)) {
|
if (!ext2fs_superblock_csum_verify(&fsx, p)) {
|
||||||
retval = EXT2_ET_LOAD_EXT_JOURNAL;
|
retval = EXT2_ET_LOAD_EXT_JOURNAL;
|
||||||
brelse(bh);
|
brelse(bh);
|
||||||
|
@ -522,10 +519,8 @@ errout:
|
||||||
static errcode_t ext2fs_journal_fix_bad_inode(ext2_filsys fs)
|
static errcode_t ext2fs_journal_fix_bad_inode(ext2_filsys fs)
|
||||||
{
|
{
|
||||||
struct ext2_super_block *sb = fs->super;
|
struct ext2_super_block *sb = fs->super;
|
||||||
int recover = fs->super->s_feature_incompat &
|
int recover = ext2fs_has_feature_journal_needs_recovery(fs->super);
|
||||||
EXT3_FEATURE_INCOMPAT_RECOVER;
|
int has_journal = ext2fs_has_feature_journal(fs->super);
|
||||||
int has_journal = fs->super->s_feature_compat &
|
|
||||||
EXT3_FEATURE_COMPAT_HAS_JOURNAL;
|
|
||||||
|
|
||||||
if (has_journal || sb->s_journal_inum) {
|
if (has_journal || sb->s_journal_inum) {
|
||||||
/* The journal inode is bogus, remove and force full fsck */
|
/* The journal inode is bogus, remove and force full fsck */
|
||||||
|
@ -604,12 +599,11 @@ static errcode_t ext2fs_journal_load(journal_t *journal)
|
||||||
return EXT2_ET_RO_UNSUPP_FEATURE;
|
return EXT2_ET_RO_UNSUPP_FEATURE;
|
||||||
|
|
||||||
/* Checksum v1-3 are mutually exclusive features. */
|
/* Checksum v1-3 are mutually exclusive features. */
|
||||||
if (JFS_HAS_INCOMPAT_FEATURE(journal, JFS_FEATURE_INCOMPAT_CSUM_V2) &&
|
if (jfs_has_feature_csum2(journal) && jfs_has_feature_csum3(journal))
|
||||||
JFS_HAS_INCOMPAT_FEATURE(journal, JFS_FEATURE_INCOMPAT_CSUM_V3))
|
|
||||||
return EXT2_ET_CORRUPT_SUPERBLOCK;
|
return EXT2_ET_CORRUPT_SUPERBLOCK;
|
||||||
|
|
||||||
if (journal_has_csum_v2or3(journal) &&
|
if (journal_has_csum_v2or3(journal) &&
|
||||||
JFS_HAS_COMPAT_FEATURE(journal, JFS_FEATURE_COMPAT_CHECKSUM))
|
jfs_has_feature_checksum(journal))
|
||||||
return EXT2_ET_CORRUPT_SUPERBLOCK;
|
return EXT2_ET_CORRUPT_SUPERBLOCK;
|
||||||
|
|
||||||
if (!ext2fs_journal_verify_csum_type(journal, jsb) ||
|
if (!ext2fs_journal_verify_csum_type(journal, jsb) ||
|
||||||
|
@ -680,12 +674,11 @@ static errcode_t ext2fs_check_ext3_journal(ext2_filsys fs)
|
||||||
{
|
{
|
||||||
struct ext2_super_block *sb = fs->super;
|
struct ext2_super_block *sb = fs->super;
|
||||||
journal_t *journal;
|
journal_t *journal;
|
||||||
int recover = fs->super->s_feature_incompat &
|
int recover = ext2fs_has_feature_journal_needs_recovery(fs->super);
|
||||||
EXT3_FEATURE_INCOMPAT_RECOVER;
|
|
||||||
errcode_t retval;
|
errcode_t retval;
|
||||||
|
|
||||||
/* If we don't have any journal features, don't do anything more */
|
/* If we don't have any journal features, don't do anything more */
|
||||||
if (!(sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
|
if (!ext2fs_has_feature_journal(sb) &&
|
||||||
!recover && sb->s_journal_inum == 0 && sb->s_journal_dev == 0 &&
|
!recover && sb->s_journal_inum == 0 && sb->s_journal_dev == 0 &&
|
||||||
uuid_is_null(sb->s_journal_uuid))
|
uuid_is_null(sb->s_journal_uuid))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -703,13 +696,13 @@ static errcode_t ext2fs_check_ext3_journal(ext2_filsys fs)
|
||||||
* needs_recovery set but has_journal clear. We can't get in a loop
|
* needs_recovery set but has_journal clear. We can't get in a loop
|
||||||
* with -y, -n, or -p, only if a user isn't making up their mind.
|
* with -y, -n, or -p, only if a user isn't making up their mind.
|
||||||
*/
|
*/
|
||||||
if (!(sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL)) {
|
if (!ext2fs_has_feature_journal(sb)) {
|
||||||
retval = EXT2_ET_JOURNAL_FLAGS_WRONG;
|
retval = EXT2_ET_JOURNAL_FLAGS_WRONG;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL &&
|
if (ext2fs_has_feature_journal(sb) &&
|
||||||
!(sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) &&
|
!ext2fs_has_feature_journal_needs_recovery(sb) &&
|
||||||
journal->j_superblock->s_start != 0) {
|
journal->j_superblock->s_start != 0) {
|
||||||
retval = EXT2_ET_JOURNAL_FLAGS_WRONG;
|
retval = EXT2_ET_JOURNAL_FLAGS_WRONG;
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -720,7 +713,7 @@ static errcode_t ext2fs_check_ext3_journal(ext2_filsys fs)
|
||||||
* the journal's errno is set; if so, we need to mark the file
|
* the journal's errno is set; if so, we need to mark the file
|
||||||
* system as being corrupt and clear the journal's s_errno.
|
* system as being corrupt and clear the journal's s_errno.
|
||||||
*/
|
*/
|
||||||
if (!(sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) &&
|
if (!ext2fs_has_feature_journal_needs_recovery(sb) &&
|
||||||
journal->j_superblock->s_errno) {
|
journal->j_superblock->s_errno) {
|
||||||
fs->super->s_state |= EXT2_ERROR_FS;
|
fs->super->s_state |= EXT2_ERROR_FS;
|
||||||
ext2fs_mark_super_dirty(fs);
|
ext2fs_mark_super_dirty(fs);
|
||||||
|
@ -929,7 +922,7 @@ void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag,
|
||||||
csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
|
csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
|
||||||
csum32 = jbd2_chksum(j, csum32, bh->b_data, bh->b_size);
|
csum32 = jbd2_chksum(j, csum32, bh->b_data, bh->b_size);
|
||||||
|
|
||||||
if (JFS_HAS_INCOMPAT_FEATURE(j, JFS_FEATURE_INCOMPAT_CSUM_V3))
|
if (jfs_has_feature_csum3(j))
|
||||||
tag3->t_checksum = ext2fs_cpu_to_be32(csum32);
|
tag3->t_checksum = ext2fs_cpu_to_be32(csum32);
|
||||||
else
|
else
|
||||||
tag->t_checksum = ext2fs_cpu_to_be16(csum32);
|
tag->t_checksum = ext2fs_cpu_to_be16(csum32);
|
||||||
|
|
|
@ -364,7 +364,7 @@ static void dump_journal(char *cmdname, FILE *out_file,
|
||||||
|
|
||||||
if ((be32_to_cpu(jsb->s_header.h_magic) != JFS_MAGIC_NUMBER) &&
|
if ((be32_to_cpu(jsb->s_header.h_magic) != JFS_MAGIC_NUMBER) &&
|
||||||
(sb->s_magic == EXT2_SUPER_MAGIC) &&
|
(sb->s_magic == EXT2_SUPER_MAGIC) &&
|
||||||
(sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) {
|
ext2fs_has_feature_journal_dev(sb)) {
|
||||||
blocksize = EXT2_BLOCK_SIZE(sb);
|
blocksize = EXT2_BLOCK_SIZE(sb);
|
||||||
blocknr = (blocksize == 1024) ? 2 : 1;
|
blocknr = (blocksize == 1024) ? 2 : 1;
|
||||||
uuid_unparse(sb->s_uuid, jsb_buffer);
|
uuid_unparse(sb->s_uuid, jsb_buffer);
|
||||||
|
|
|
@ -34,8 +34,7 @@ static int load_quota_ctx(char *progname)
|
||||||
if (check_fs_open(progname))
|
if (check_fs_open(progname))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!EXT2_HAS_RO_COMPAT_FEATURE(current_fs->super,
|
if (!ext2fs_has_feature_quota(current_fs->super)) {
|
||||||
EXT4_FEATURE_RO_COMPAT_QUOTA)) {
|
|
||||||
com_err(progname, 0, "quota feature not enabled");
|
com_err(progname, 0, "quota feature not enabled");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue