aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.bp1
-rw-r--r--METADATA4
-rw-r--r--fsck/dir.c1
-rw-r--r--fsck/dump.c3
-rw-r--r--fsck/f2fs.h3
-rw-r--r--fsck/fsck.c21
-rw-r--r--fsck/fsck.h2
-rw-r--r--fsck/mkquota.c1
-rw-r--r--fsck/mount.c102
-rw-r--r--fsck/node.c1
-rw-r--r--fsck/node.h11
-rw-r--r--fsck/quotaio.c10
-rw-r--r--fsck/quotaio.h13
-rw-r--r--fsck/quotaio_tree.c14
-rw-r--r--fsck/quotaio_v2.c53
-rw-r--r--fsck/segment.c20
-rw-r--r--mkfs/Makefile.am3
-rw-r--r--mkfs/f2fs_format.c2
-rw-r--r--mkfs/f2fs_format_main.c4
-rw-r--r--tools/Makefile.am2
-rw-r--r--tools/f2fscrypt.c2
21 files changed, 220 insertions, 53 deletions
diff --git a/Android.bp b/Android.bp
index 0fa3305..bae9279 100644
--- a/Android.bp
+++ b/Android.bp
@@ -25,6 +25,7 @@ cc_defaults {
],
include_dirs: [
"external/e2fsprogs/lib/",
+ "external/e2fsprogs/lib/uuid",
"system/core/libsparse/include",
],
target: {
diff --git a/METADATA b/METADATA
index 1df79dd..4f6ab57 100644
--- a/METADATA
+++ b/METADATA
@@ -12,7 +12,7 @@ third_party {
license_type: RESTRICTED
last_upgrade_date {
year: 2020
- month: 03
- day: 31
+ month: 07
+ day: 09
}
}
diff --git a/fsck/dir.c b/fsck/dir.c
index 5f4f75e..dc03c98 100644
--- a/fsck/dir.c
+++ b/fsck/dir.c
@@ -522,6 +522,7 @@ static void init_inode_block(struct f2fs_sb_info *sbi,
node_blk->footer.nid = cpu_to_le32(de->ino);
node_blk->footer.flag = 0;
node_blk->footer.cp_ver = ckpt->checkpoint_ver;
+ set_cold_node(node_blk, S_ISDIR(mode));
if (S_ISDIR(mode)) {
make_empty_dir(sbi, node_blk);
diff --git a/fsck/dump.c b/fsck/dump.c
index 001b7cb..e472eb7 100644
--- a/fsck/dump.c
+++ b/fsck/dump.c
@@ -424,7 +424,8 @@ static void dump_file(struct f2fs_sb_info *sbi, struct node_info *ni,
return;
}
- if (!S_ISREG(imode) || namelen == 0 || namelen > F2FS_NAME_LEN) {
+ if ((!S_ISREG(imode) && !S_ISLNK(imode)) ||
+ namelen == 0 || namelen > F2FS_NAME_LEN) {
MSG(force, "Not a regular file or wrong name info\n\n");
return;
}
diff --git a/fsck/f2fs.h b/fsck/f2fs.h
index 2a00d35..76e8272 100644
--- a/fsck/f2fs.h
+++ b/fsck/f2fs.h
@@ -273,6 +273,9 @@ struct f2fs_sb_info {
u32 free_segments;
int cp_backuped; /* backup valid checkpoint */
+
+ /* true if late_build_segment_manger() is called */
+ bool seg_manager_done;
};
static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi)
diff --git a/fsck/fsck.c b/fsck/fsck.c
index c249dfa..e110f3d 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -792,6 +792,8 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
if ((node_blk->i.i_inline & F2FS_INLINE_DATA)) {
unsigned int inline_size = MAX_INLINE_DATA(node_blk);
+ if (cur_qtype != -1)
+ qf_szchk_type[cur_qtype] = QF_SZCHK_INLINE;
block_t blkaddr = le32_to_cpu(node_blk->i.i_addr[ofs]);
if (blkaddr != 0) {
@@ -860,6 +862,15 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
}
/* check data blocks in inode */
+ if (cur_qtype != -1) {
+ qf_szchk_type[cur_qtype] = QF_SZCHK_REGFILE;
+ qf_maxsize[cur_qtype] = (ADDRS_PER_INODE(&node_blk->i) +
+ 2 * ADDRS_PER_BLOCK(&node_blk->i) +
+ 2 * ADDRS_PER_BLOCK(&node_blk->i) *
+ NIDS_PER_BLOCK +
+ (u64) ADDRS_PER_BLOCK(&node_blk->i) *
+ NIDS_PER_BLOCK * NIDS_PER_BLOCK) * F2FS_BLKSIZE;
+ }
for (idx = 0; idx < ADDRS_PER_INODE(&node_blk->i);
idx++, child.pgofs++) {
block_t blkaddr = le32_to_cpu(node_blk->i.i_addr[ofs + idx]);
@@ -884,6 +895,8 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
file_is_encrypt(&node_blk->i));
if (!ret) {
*blk_cnt = *blk_cnt + 1;
+ if (cur_qtype != -1 && blkaddr != NEW_ADDR)
+ qf_last_blkofs[cur_qtype] = child.pgofs;
} else if (c.fix_on) {
node_blk->i.i_addr[ofs + idx] = 0;
need_fix = 1;
@@ -1126,6 +1139,8 @@ int fsck_chk_dnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,
file_is_encrypt(inode));
if (!ret) {
*blk_cnt = *blk_cnt + 1;
+ if (cur_qtype != -1 && blkaddr != NEW_ADDR)
+ qf_last_blkofs[cur_qtype] = child->pgofs;
} else if (c.fix_on) {
node_blk->dn.addr[idx] = 0;
need_fix = 1;
@@ -1794,6 +1809,7 @@ int fsck_chk_quota_node(struct f2fs_sb_info *sbi)
u32 blk_cnt = 0;
for (qtype = 0; qtype < F2FS_MAX_QUOTAS; qtype++) {
+ cur_qtype = qtype;
if (sb->qf_ino[qtype] == 0)
continue;
nid_t ino = QUOTA_INO(sb, qtype);
@@ -1811,10 +1827,13 @@ int fsck_chk_quota_node(struct f2fs_sb_info *sbi)
}
ret = fsck_chk_node_blk(sbi, NULL, ino,
F2FS_FT_REG_FILE, TYPE_INODE, &blk_cnt, NULL);
- if (ret)
+ if (ret) {
ASSERT_MSG("wrong quota inode, qtype [%d] ino [0x%x]",
qtype, ino);
+ qf_szchk_type[qtype] = QF_SZCHK_ERR;
+ }
}
+ cur_qtype = -1;
return ret;
}
diff --git a/fsck/fsck.h b/fsck/fsck.h
index 2de6f62..bc6a435 100644
--- a/fsck/fsck.h
+++ b/fsck/fsck.h
@@ -266,6 +266,8 @@ block_t new_node_block(struct f2fs_sb_info *,
struct dnode_of_data *, unsigned int);
/* segment.c */
+struct quota_file;
+u64 f2fs_quota_size(struct quota_file *);
u64 f2fs_read(struct f2fs_sb_info *, nid_t, u8 *, u64, pgoff_t);
u64 f2fs_write(struct f2fs_sb_info *, nid_t, u8 *, u64, pgoff_t);
void f2fs_filesize_update(struct f2fs_sb_info *, nid_t, u64);
diff --git a/fsck/mkquota.c b/fsck/mkquota.c
index 84f9d3d..c419a0f 100644
--- a/fsck/mkquota.c
+++ b/fsck/mkquota.c
@@ -378,6 +378,7 @@ errcode_t quota_compare_and_update(struct f2fs_sb_info *sbi,
err = quota_file_open(sbi, &qh, qtype, 0);
if (err) {
log_debug("Open quota file failed");
+ *usage_inconsistent = 1;
goto out;
}
diff --git a/fsck/mount.c b/fsck/mount.c
index fb45941..6d467c8 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1288,15 +1288,14 @@ pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start, int *pack)
return block_addr;
}
-static int f2fs_init_nid_bitmap(struct f2fs_sb_info *sbi)
+/* will not init nid_bitmap from nat */
+static int f2fs_early_init_nid_bitmap(struct f2fs_sb_info *sbi)
{
struct f2fs_nm_info *nm_i = NM_I(sbi);
int nid_bitmap_size = (nm_i->max_nid + BITS_PER_BYTE - 1) / BITS_PER_BYTE;
struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
struct f2fs_summary_block *sum = curseg->sum_blk;
struct f2fs_journal *journal = &sum->journal;
- struct f2fs_nat_block *nat_block;
- block_t start_blk;
nid_t nid;
int i;
@@ -1310,28 +1309,6 @@ static int f2fs_init_nid_bitmap(struct f2fs_sb_info *sbi)
/* arbitrarily set 0 bit */
f2fs_set_bit(0, nm_i->nid_bitmap);
- nat_block = malloc(F2FS_BLKSIZE);
- if (!nat_block) {
- free(nm_i->nid_bitmap);
- return -ENOMEM;
- }
-
- f2fs_ra_meta_pages(sbi, 0, NAT_BLOCK_OFFSET(nm_i->max_nid),
- META_NAT);
-
- for (nid = 0; nid < nm_i->max_nid; nid++) {
- if (!(nid % NAT_ENTRY_PER_BLOCK)) {
- int ret;
-
- start_blk = current_nat_addr(sbi, nid, NULL);
- ret = dev_read_block(nat_block, start_blk);
- ASSERT(ret >= 0);
- }
-
- if (nat_block->entries[nid % NAT_ENTRY_PER_BLOCK].block_addr)
- f2fs_set_bit(nid, nm_i->nid_bitmap);
- }
-
if (nats_in_cursum(journal) > NAT_JOURNAL_ENTRIES) {
MSG(0, "\tError: f2fs_init_nid_bitmap truncate n_nats(%u) to "
"NAT_JOURNAL_ENTRIES(%lu)\n",
@@ -1361,6 +1338,41 @@ static int f2fs_init_nid_bitmap(struct f2fs_sb_info *sbi)
if (addr != NULL_ADDR)
f2fs_set_bit(nid, nm_i->nid_bitmap);
}
+ return 0;
+}
+
+/* will init nid_bitmap from nat */
+static int f2fs_late_init_nid_bitmap(struct f2fs_sb_info *sbi)
+{
+ struct f2fs_nm_info *nm_i = NM_I(sbi);
+ struct f2fs_nat_block *nat_block;
+ block_t start_blk;
+ nid_t nid;
+
+ if (!(c.func == SLOAD || c.func == FSCK))
+ return 0;
+
+ nat_block = malloc(F2FS_BLKSIZE);
+ if (!nat_block) {
+ free(nm_i->nid_bitmap);
+ return -ENOMEM;
+ }
+
+ f2fs_ra_meta_pages(sbi, 0, NAT_BLOCK_OFFSET(nm_i->max_nid),
+ META_NAT);
+ for (nid = 0; nid < nm_i->max_nid; nid++) {
+ if (!(nid % NAT_ENTRY_PER_BLOCK)) {
+ int ret;
+
+ start_blk = current_nat_addr(sbi, nid, NULL);
+ ret = dev_read_block(nat_block, start_blk);
+ ASSERT(ret >= 0);
+ }
+
+ if (nat_block->entries[nid % NAT_ENTRY_PER_BLOCK].block_addr)
+ f2fs_set_bit(nid, nm_i->nid_bitmap);
+ }
+
free(nat_block);
return 0;
}
@@ -1565,7 +1577,7 @@ int init_node_manager(struct f2fs_sb_info *sbi)
/* copy version bitmap */
memcpy(nm_i->nat_bitmap, version_bitmap, nm_i->bitmap_size);
- return f2fs_init_nid_bitmap(sbi);
+ return f2fs_early_init_nid_bitmap(sbi);
}
int build_node_manager(struct f2fs_sb_info *sbi)
@@ -2272,7 +2284,7 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
return 0;
}
-static int build_segment_manager(struct f2fs_sb_info *sbi)
+static int early_build_segment_manager(struct f2fs_sb_info *sbi)
{
struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi);
struct f2fs_checkpoint *cp = F2FS_CKPT(sbi);
@@ -2294,7 +2306,7 @@ static int build_segment_manager(struct f2fs_sb_info *sbi)
sm_info->main_segments = get_sb(segment_count_main);
sm_info->ssa_blkaddr = get_sb(ssa_blkaddr);
- if (build_sit_info(sbi) || build_curseg(sbi) || build_sit_entries(sbi)) {
+ if (build_sit_info(sbi) || build_curseg(sbi)) {
free(sm_info);
return -ENOMEM;
}
@@ -2302,6 +2314,20 @@ static int build_segment_manager(struct f2fs_sb_info *sbi)
return 0;
}
+static int late_build_segment_manager(struct f2fs_sb_info *sbi)
+{
+ if (sbi->seg_manager_done)
+ return 1; /* this function was already called */
+
+ sbi->seg_manager_done = true;
+ if (build_sit_entries(sbi)) {
+ free (sbi->sm_info);
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
void build_sit_area_bitmap(struct f2fs_sb_info *sbi)
{
struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
@@ -3375,6 +3401,12 @@ static int record_fsync_data(struct f2fs_sb_info *sbi)
if (ret)
goto out;
+ ret = late_build_segment_manager(sbi);
+ if (ret < 0) {
+ ERR_MSG("late_build_segment_manager failed\n");
+ goto out;
+ }
+
ret = traverse_dnodes(sbi, &inode_list);
out:
destroy_fsync_dnodes(&inode_list);
@@ -3445,8 +3477,8 @@ int f2fs_do_mount(struct f2fs_sb_info *sbi)
sbi->last_valid_block_count = sbi->total_valid_block_count;
sbi->alloc_valid_block_count = 0;
- if (build_segment_manager(sbi)) {
- ERR_MSG("build_segment_manager failed\n");
+ if (early_build_segment_manager(sbi)) {
+ ERR_MSG("early_build_segment_manager failed\n");
return -1;
}
@@ -3463,6 +3495,16 @@ int f2fs_do_mount(struct f2fs_sb_info *sbi)
if (!f2fs_should_proceed(sb, get_cp(ckpt_flags)))
return 1;
+ if (late_build_segment_manager(sbi) < 0) {
+ ERR_MSG("late_build_segment_manager failed\n");
+ return -1;
+ }
+
+ if (f2fs_late_init_nid_bitmap(sbi)) {
+ ERR_MSG("f2fs_late_init_nid_bitmap failed\n");
+ return -1;
+ }
+
/* Check nat_bits */
if (c.func == FSCK && is_set_ckpt_flags(cp, CP_NAT_BITS_FLAG)) {
if (check_nat_bits(sbi, sb, cp) && c.fix_on)
diff --git a/fsck/node.c b/fsck/node.c
index 229a99c..1d291ca 100644
--- a/fsck/node.c
+++ b/fsck/node.c
@@ -79,6 +79,7 @@ block_t new_node_block(struct f2fs_sb_info *sbi,
node_blk->footer.ino = f2fs_inode->footer.ino;
node_blk->footer.flag = cpu_to_le32(ofs << OFFSET_BIT_SHIFT);
node_blk->footer.cp_ver = ckpt->checkpoint_ver;
+ set_cold_node(node_blk, S_ISDIR(le16_to_cpu(f2fs_inode->i.i_mode)));
type = CURSEG_COLD_NODE;
if (IS_DNODE(node_blk)) {
diff --git a/fsck/node.h b/fsck/node.h
index 6bce1fb..99139b1 100644
--- a/fsck/node.h
+++ b/fsck/node.h
@@ -161,6 +161,17 @@ static inline int is_node(struct f2fs_node *node_blk, int type)
return le32_to_cpu(node_blk->footer.flag) & (1 << type);
}
+static inline void set_cold_node(struct f2fs_node *rn, bool is_dir)
+{
+ unsigned int flag = le32_to_cpu(rn->footer.flag);
+
+ if (is_dir)
+ flag &= ~(0x1 << COLD_BIT_SHIFT);
+ else
+ flag |= (0x1 << COLD_BIT_SHIFT);
+ rn->footer.flag = cpu_to_le32(flag);
+}
+
#define is_fsync_dnode(node_blk) is_node(node_blk, FSYNC_BIT_SHIFT)
#define is_dent_dnode(node_blk) is_node(node_blk, DENT_BIT_SHIFT)
diff --git a/fsck/quotaio.c b/fsck/quotaio.c
index cc517bd..51abbb7 100644
--- a/fsck/quotaio.c
+++ b/fsck/quotaio.c
@@ -33,6 +33,14 @@ struct disk_dqheader {
__le32 dqh_version;
} __attribute__ ((packed));
+int cur_qtype = -1;
+u32 qf_last_blkofs[MAXQUOTAS] = {0, 0, 0};
+enum qf_szchk_type_t qf_szchk_type[MAXQUOTAS] =
+{
+ QF_SZCHK_NONE, QF_SZCHK_NONE, QF_SZCHK_NONE
+};
+u64 qf_maxsize[MAXQUOTAS];
+
/**
* Convert type of quota to written representation
*/
@@ -140,7 +148,7 @@ errcode_t quota_file_open(struct f2fs_sb_info *sbi, struct quota_handle *h,
goto errout;
}
- if (h->qh_ops->init_io && (h->qh_ops->init_io(h) < 0)) {
+ if (h->qh_ops->init_io && (h->qh_ops->init_io(h, qtype) < 0)) {
log_err("qh_ops->init_io failed");
err = EIO;
goto errout;
diff --git a/fsck/quotaio.h b/fsck/quotaio.h
index 8087309..999e800 100644
--- a/fsck/quotaio.h
+++ b/fsck/quotaio.h
@@ -46,6 +46,17 @@ enum quota_type {
#error "cannot have more than 32 quota types to fit in qtype_bits"
#endif
+enum qf_szchk_type_t {
+ QF_SZCHK_NONE,
+ QF_SZCHK_ERR,
+ QF_SZCHK_INLINE,
+ QF_SZCHK_REGFILE,
+};
+
+extern int cur_qtype;
+extern u32 qf_last_blkofs[];
+extern enum qf_szchk_type_t qf_szchk_type[];
+extern u64 qf_maxsize[];
#define QUOTA_USR_BIT (1 << USRQUOTA)
#define QUOTA_GRP_BIT (1 << GRPQUOTA)
@@ -154,7 +165,7 @@ struct quotafile_ops {
/* Check whether quotafile is in our format */
int (*check_file) (struct quota_handle *h, int type);
/* Open quotafile */
- int (*init_io) (struct quota_handle *h);
+ int (*init_io) (struct quota_handle *h, enum quota_type qtype);
/* Create new quotafile */
int (*new_io) (struct quota_handle *h);
/* Write all changes and close quotafile */
diff --git a/fsck/quotaio_tree.c b/fsck/quotaio_tree.c
index de25a60..c203400 100644
--- a/fsck/quotaio_tree.c
+++ b/fsck/quotaio_tree.c
@@ -568,7 +568,7 @@ static int report_block(struct dquot *dquot, unsigned int blk, char *bitmap,
int entries, i;
if (!buf)
- return 0;
+ return -1;
set_bit(bitmap, blk);
read_blk(dquot->dq_h, blk, buf);
@@ -593,9 +593,7 @@ static int report_block(struct dquot *dquot, unsigned int blk, char *bitmap,
static int check_reference(struct quota_handle *h, unsigned int blk)
{
if (blk >= h->qh_info.u.v2_mdqi.dqi_qtree.dqi_blocks) {
- log_err("Illegal reference (%u >= %u) in %s quota file. "
- "Quota file is probably corrupted.\n"
- "Please run fsck (8) to fix it.",
+ log_err("Illegal reference (%u >= %u) in %s quota file",
blk,
h->qh_info.u.v2_mdqi.dqi_qtree.dqi_blocks,
quota_type2name(h->qh_type));
@@ -627,9 +625,13 @@ static int report_tree(struct dquot *dquot, unsigned int blk, int depth,
break;
if (depth == QT_TREEDEPTH - 1) {
- if (!get_bit(bitmap, blk))
- *entries += report_block(dquot, blk, bitmap,
+ if (!get_bit(bitmap, blk)) {
+ int num_entry = report_block(dquot, blk, bitmap,
process_dquot, data);
+ if (num_entry < 0)
+ break;
+ *entries += num_entry;
+ }
} else {
if (report_tree(dquot, blk, depth + 1, bitmap, entries,
process_dquot, data))
diff --git a/fsck/quotaio_v2.c b/fsck/quotaio_v2.c
index 1404332..9353f85 100644
--- a/fsck/quotaio_v2.c
+++ b/fsck/quotaio_v2.c
@@ -20,7 +20,7 @@
#include "quotaio_tree.h"
static int v2_check_file(struct quota_handle *h, int type);
-static int v2_init_io(struct quota_handle *h);
+static int v2_init_io(struct quota_handle *h, enum quota_type qtype);
static int v2_new_io(struct quota_handle *h);
static int v2_write_info(struct quota_handle *h);
static struct dquot *v2_read_dquot(struct quota_handle *h, qid_t id);
@@ -170,19 +170,64 @@ static int v2_check_file(struct quota_handle *h, int type)
/*
* Open quotafile
*/
-static int v2_init_io(struct quota_handle *h)
+static int v2_init_io(struct quota_handle *h, enum quota_type qtype)
{
struct v2_disk_dqinfo ddqinfo;
+ struct v2_mem_dqinfo *info;
+ u64 filesize;
+ struct quota_file *qf = &h->qh_qf;
+ u32 last_blkofs = qf_last_blkofs[qtype];
h->qh_info.u.v2_mdqi.dqi_qtree.dqi_entry_size =
sizeof(struct v2r1_disk_dqblk);
h->qh_info.u.v2_mdqi.dqi_qtree.dqi_ops = &v2r1_fmt_ops;
/* Read information about quotafile */
- if (h->read(&h->qh_qf, V2_DQINFOOFF, &ddqinfo,
- sizeof(ddqinfo)) != sizeof(ddqinfo))
+ if (h->read(qf, V2_DQINFOOFF, &ddqinfo,
+ sizeof(ddqinfo)) != sizeof(ddqinfo))
return -1;
v2_disk2memdqinfo(&h->qh_info, &ddqinfo);
+
+ /* Check to make sure quota file info is sane */
+ info = &h->qh_info.u.v2_mdqi;
+ filesize = qf->filesize = f2fs_quota_size(qf);
+ if (qf_szchk_type[qtype] == QF_SZCHK_REGFILE &&
+ ((filesize + F2FS_BLKSIZE - 1) >> F2FS_BLKSIZE_BITS <
+ last_blkofs + 1 || filesize > qf_maxsize[qtype])) {
+ /*
+ * reqular: qf_szchk is now the last block index,
+ * including the hole's index
+ */
+ log_err("Quota inode %u corrupted: file size %" PRIu64
+ " does not match page offset %" PRIu32,
+ h->qh_qf.ino,
+ filesize,
+ last_blkofs);
+ filesize = (last_blkofs + 1) << F2FS_BLKSIZE_BITS;
+ f2fs_filesize_update(qf->sbi, qf->ino, filesize);
+ }
+
+ if ((info->dqi_qtree.dqi_blocks >
+ (filesize + QT_BLKSIZE - 1) >> QT_BLKSIZE_BITS)) {
+ log_err("Quota inode %u corrupted: file size %" PRId64 "; "
+ "dqi_blocks %u", h->qh_qf.ino,
+ filesize, info->dqi_qtree.dqi_blocks);
+ return -1;
+ }
+ if (info->dqi_qtree.dqi_free_blk >= info->dqi_qtree.dqi_blocks) {
+ log_err("Quota inode %u corrupted: free_blk %u;"
+ " dqi_blocks %u",
+ h->qh_qf.ino, info->dqi_qtree.dqi_free_blk,
+ info->dqi_qtree.dqi_blocks);
+ return -1;
+ }
+ if (info->dqi_qtree.dqi_free_entry >= info->dqi_qtree.dqi_blocks) {
+ log_err("Quota inode %u corrupted: free_entry %u; "
+ "dqi_blocks %u", h->qh_qf.ino,
+ info->dqi_qtree.dqi_free_entry,
+ info->dqi_qtree.dqi_blocks);
+ return -1;
+ }
return 0;
}
diff --git a/fsck/segment.c b/fsck/segment.c
index b7cf245..0487f41 100644
--- a/fsck/segment.c
+++ b/fsck/segment.c
@@ -15,6 +15,7 @@
*/
#include "fsck.h"
#include "node.h"
+#include "quotaio.h"
int reserve_new_block(struct f2fs_sb_info *sbi, block_t *to,
struct f2fs_summary *sum, int type, bool is_inode)
@@ -124,6 +125,25 @@ int new_data_block(struct f2fs_sb_info *sbi, void *block,
return 0;
}
+u64 f2fs_quota_size(struct quota_file *qf)
+{
+ struct node_info ni;
+ struct f2fs_node *inode;
+ u64 filesize;
+
+ inode = (struct f2fs_node *) calloc(BLOCK_SZ, 1);
+ ASSERT(inode);
+
+ /* Read inode */
+ get_node_info(qf->sbi, qf->ino, &ni);
+ ASSERT(dev_read_block(inode, ni.blk_addr) >= 0);
+ ASSERT(S_ISREG(le16_to_cpu(inode->i.i_mode)));
+
+ filesize = le64_to_cpu(inode->i.i_size);
+ free(inode);
+ return filesize;
+}
+
u64 f2fs_read(struct f2fs_sb_info *sbi, nid_t ino, u8 *buffer,
u64 count, pgoff_t offset)
{
diff --git a/mkfs/Makefile.am b/mkfs/Makefile.am
index 83e2389..af5b1c7 100644
--- a/mkfs/Makefile.am
+++ b/mkfs/Makefile.am
@@ -11,8 +11,7 @@ mkfs_f2fs_LDADD = ${libuuid_LIBS} ${libblkid_LIBS} $(top_builddir)/lib/libf2fs.l
lib_LTLIBRARIES = libf2fs_format.la
libf2fs_format_la_SOURCES = f2fs_format_main.c f2fs_format.c f2fs_format_utils.c
libf2fs_format_la_CFLAGS = -DWITH_BLKDISCARD
-libf2fs_format_la_CPPFLAGS = -I$(top_srcdir)/include
-libf2fs_format_la_LDFLAGS = ${libblkid_LIBS} -luuid -L$(top_builddir)/lib -lf2fs \
+libf2fs_format_la_LDFLAGS = ${libblkid_LIBS} ${libuuid_LIBS} -L$(top_builddir)/lib -lf2fs \
-version-info $(FMT_CURRENT):$(FMT_REVISION):$(FMT_AGE)
install-exec-hook:
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 44575e0..4999cac 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -18,7 +18,7 @@
#include <sys/mount.h>
#endif
#include <time.h>
-#include <uuid/uuid.h>
+#include <uuid.h>
#include "f2fs_fs.h"
#include "quota.h"
diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c
index 204a410..3d86c44 100644
--- a/mkfs/f2fs_format_main.c
+++ b/mkfs/f2fs_format_main.c
@@ -18,12 +18,12 @@
#include <sys/mount.h>
#endif
#include <time.h>
-#include <uuid/uuid.h>
+#include <uuid.h>
#include <errno.h>
#include "config.h"
#ifdef HAVE_LIBBLKID
-# include <blkid/blkid.h>
+# include <blkid.h>
#endif
#include "f2fs_fs.h"
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 446bb39..56bf2e4 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -10,7 +10,7 @@ parse_f2fs_SOURCES = f2fs_io_parse.c
if LINUX
sbin_PROGRAMS += f2fscrypt
f2fscrypt_SOURCES = f2fscrypt.c sha512.c
-f2fscrypt_LDFLAGS = -luuid
+f2fscrypt_LDFLAGS = ${libuuid_LIBS}
dist_man_MANS = f2fscrypt.8
endif
diff --git a/tools/f2fscrypt.c b/tools/f2fscrypt.c
index fe3e0ff..d5bc3c5 100644
--- a/tools/f2fscrypt.c
+++ b/tools/f2fscrypt.c
@@ -43,7 +43,7 @@
#ifdef __KERNEL__
#include <linux/fs.h>
#endif
-#include <uuid/uuid.h>
+#include <uuid.h>
#if !defined(HAVE_ADD_KEY) || !defined(HAVE_KEYCTL)
#include <sys/syscall.h>