Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 666657 | Differences between
and this patch

Collapse All | Expand All

(-)a/fsck/fsck.c (-10 / +10 lines)
Lines 199-205 static int is_valid_ssa_node_blk(struct f2fs_sb_info *sbi, u32 nid, Link Here
199
			need_fix = 1;
199
			need_fix = 1;
200
		}
200
		}
201
	}
201
	}
202
	if (need_fix && !c.ro) {
202
	if (need_fix && f2fs_dev_is_writable()) {
203
		u64 ssa_blk;
203
		u64 ssa_blk;
204
		int ret2;
204
		int ret2;
205
205
Lines 325-331 static int is_valid_ssa_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr, Link Here
325
			need_fix = 1;
325
			need_fix = 1;
326
		}
326
		}
327
	}
327
	}
328
	if (need_fix && !c.ro) {
328
	if (need_fix && f2fs_dev_is_writable()) {
329
		u64 ssa_blk;
329
		u64 ssa_blk;
330
		int ret2;
330
		int ret2;
331
331
Lines 1015-1021 skip_blkcnt_fix: Link Here
1015
	}
1015
	}
1016
1016
1017
	/* drop extent information to avoid potential wrong access */
1017
	/* drop extent information to avoid potential wrong access */
1018
	if (need_fix && !c.ro)
1018
	if (need_fix && f2fs_dev_is_writable())
1019
		node_blk->i.i_ext.len = 0;
1019
		node_blk->i.i_ext.len = 0;
1020
1020
1021
	if ((c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CHKSUM)) &&
1021
	if ((c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CHKSUM)) &&
Lines 1038-1044 skip_blkcnt_fix: Link Here
1038
		}
1038
		}
1039
	}
1039
	}
1040
1040
1041
	if (need_fix && !c.ro) {
1041
	if (need_fix && f2fs_dev_is_writable()) {
1042
		ret = dev_write_block(node_blk, ni->blk_addr);
1042
		ret = dev_write_block(node_blk, ni->blk_addr);
1043
		ASSERT(ret >= 0);
1043
		ASSERT(ret >= 0);
1044
	}
1044
	}
Lines 1073-1079 int fsck_chk_dnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode, Link Here
1073
			FIX_MSG("[0x%x] dn.addr[%d] = 0", nid, idx);
1073
			FIX_MSG("[0x%x] dn.addr[%d] = 0", nid, idx);
1074
		}
1074
		}
1075
	}
1075
	}
1076
	if (need_fix && !c.ro) {
1076
	if (need_fix && f2fs_dev_is_writable()) {
1077
		ret = dev_write_block(node_blk, ni->blk_addr);
1077
		ret = dev_write_block(node_blk, ni->blk_addr);
1078
		ASSERT(ret >= 0);
1078
		ASSERT(ret >= 0);
1079
	}
1079
	}
Lines 1110-1116 skip: Link Here
1110
		}
1110
		}
1111
	}
1111
	}
1112
1112
1113
	if (need_fix && !c.ro) {
1113
	if (need_fix && f2fs_dev_is_writable()) {
1114
		struct node_info ni;
1114
		struct node_info ni;
1115
		nid_t nid = le32_to_cpu(node_blk->footer.nid);
1115
		nid_t nid = le32_to_cpu(node_blk->footer.nid);
1116
1116
Lines 1152-1158 skip: Link Here
1152
		}
1152
		}
1153
	}
1153
	}
1154
1154
1155
	if (need_fix && !c.ro) {
1155
	if (need_fix && f2fs_dev_is_writable()) {
1156
		struct node_info ni;
1156
		struct node_info ni;
1157
		nid_t nid = le32_to_cpu(node_blk->footer.nid);
1157
		nid_t nid = le32_to_cpu(node_blk->footer.nid);
1158
1158
Lines 1595-1601 int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi, u32 blk_addr, Link Here
1595
			de_blk->dentry, de_blk->filename,
1595
			de_blk->dentry, de_blk->filename,
1596
			NR_DENTRY_IN_BLOCK, last_blk, enc_name);
1596
			NR_DENTRY_IN_BLOCK, last_blk, enc_name);
1597
1597
1598
	if (dentries < 0 && !c.ro) {
1598
	if (dentries < 0 && f2fs_dev_is_writable()) {
1599
		ret = dev_write_block(de_blk, blk_addr);
1599
		ret = dev_write_block(de_blk, blk_addr);
1600
		ASSERT(ret >= 0);
1600
		ASSERT(ret >= 0);
1601
		DBG(1, "[%3d] Dentry Block [0x%x] Fixed hash_codes\n\n",
1601
		DBG(1, "[%3d] Dentry Block [0x%x] Fixed hash_codes\n\n",
Lines 1708-1714 int fsck_chk_orphan_node(struct f2fs_sb_info *sbi) Link Here
1708
			else if (ret)
1708
			else if (ret)
1709
				ASSERT_MSG("[0x%x] wrong orphan inode", ino);
1709
				ASSERT_MSG("[0x%x] wrong orphan inode", ino);
1710
		}
1710
		}
1711
		if (!c.ro && c.fix_on &&
1711
		if (f2fs_dev_is_writable() && c.fix_on &&
1712
				entry_count != new_entry_count) {
1712
				entry_count != new_entry_count) {
1713
			new_blk->entry_count = cpu_to_le32(new_entry_count);
1713
			new_blk->entry_count = cpu_to_le32(new_entry_count);
1714
			ret = dev_write_block(new_blk, start_blk + i);
1714
			ret = dev_write_block(new_blk, start_blk + i);
Lines 2719-2725 int fsck_verify(struct f2fs_sb_info *sbi) Link Here
2719
	}
2719
	}
2720
#endif
2720
#endif
2721
	/* fix global metadata */
2721
	/* fix global metadata */
2722
	if (force || (c.fix_on && !c.ro)) {
2722
	if (force || (c.fix_on && f2fs_dev_is_writable())) {
2723
		struct f2fs_checkpoint *cp = F2FS_CKPT(sbi);
2723
		struct f2fs_checkpoint *cp = F2FS_CKPT(sbi);
2724
2724
2725
		if (force || c.bug_on || c.bug_nat_bits) {
2725
		if (force || c.bug_on || c.bug_nat_bits) {
(-)a/fsck/main.c (-3 / +7 lines)
Lines 759-767 int main(int argc, char **argv) Link Here
759
		}
759
		}
760
760
761
		/* allow ro-mounted partition */
761
		/* allow ro-mounted partition */
762
		MSG(0, "Info: Check FS only due to RO\n");
762
		if (c.force) {
763
		c.fix_on = 0;
763
			MSG(0, "Info: Force to check/repair FS on RO mounted device\n");
764
		c.auto_fix = 0;
764
		} else {
765
			MSG(0, "Info: Check FS only on RO mounted device\n");
766
			c.fix_on = 0;
767
			c.auto_fix = 0;
768
		}
765
	}
769
	}
766
770
767
	/* Get device */
771
	/* Get device */
(-)a/include/f2fs_fs.h (+1 lines)
Lines 1155-1160 extern int f2fs_crc_valid(u_int32_t blk_crc, void *buf, int len); Link Here
1155
1155
1156
extern void f2fs_init_configuration(void);
1156
extern void f2fs_init_configuration(void);
1157
extern int f2fs_devs_are_umounted(void);
1157
extern int f2fs_devs_are_umounted(void);
1158
extern int f2fs_dev_is_writable(void);
1158
extern int f2fs_dev_is_umounted(char *);
1159
extern int f2fs_dev_is_umounted(char *);
1159
extern int f2fs_get_device_info(void);
1160
extern int f2fs_get_device_info(void);
1160
extern int get_device_info(int);
1161
extern int get_device_info(int);
(-)a/lib/libf2fs.c (-1 / +5 lines)
Lines 644-649 void f2fs_init_configuration(void) Link Here
644
	c.root_gid = getgid();
644
	c.root_gid = getgid();
645
}
645
}
646
646
647
int f2fs_dev_is_writable(void)
648
{
649
	return !c.ro || c.force;
650
}
651
647
#ifdef HAVE_SETMNTENT
652
#ifdef HAVE_SETMNTENT
648
static int is_mounted(const char *mpt, const char *device)
653
static int is_mounted(const char *mpt, const char *device)
649
{
654
{
650
- 

Return to bug 666657