mkfs.f2fs: match uid/gid/projid between root inode and quota info

This patch fixes mismatched root inode and quota info.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Jaegeuk Kim 2017-11-30 11:35:48 -08:00
parent 567aaf2ae2
commit 6d8aeb2f07

View File

@ -1061,7 +1061,8 @@ static int f2fs_write_root_inode(void)
return 0;
}
static int f2fs_write_default_quota(int qtype, unsigned int blkaddr)
static int f2fs_write_default_quota(int qtype, unsigned int blkaddr,
__le32 raw_id)
{
char *filebuf = calloc(F2FS_BLKSIZE, 2);
int file_magics[] = INITQMAGICS;
@ -1098,7 +1099,7 @@ static int f2fs_write_default_quota(int qtype, unsigned int blkaddr)
filebuf[5120 + 8] = 1;
dqblk.dqb_id = cpu_to_le32(0);
dqblk.dqb_id = raw_id;
dqblk.dqb_pad = cpu_to_le32(0);
dqblk.dqb_ihardlimit = cpu_to_le64(0);
dqblk.dqb_isoftlimit = cpu_to_le64(0);
@ -1129,6 +1130,7 @@ static int f2fs_write_qf_inode(int qtype)
struct f2fs_node *raw_node = NULL;
u_int64_t data_blk_nor;
u_int64_t main_area_node_seg_blk_offset = 0;
__le32 raw_id;
int i;
raw_node = calloc(F2FS_BLKSIZE, 1);
@ -1180,9 +1182,17 @@ static int f2fs_write_qf_inode(int qtype)
for (i = 0; i < qtype; i++)
if (sb->qf_ino[i])
data_blk_nor += QUOTA_DATA(i);
if (qtype == 0)
raw_id = raw_node->i.i_uid;
else if (qtype == 1)
raw_id = raw_node->i.i_gid;
else if (qtype == 2)
raw_id = raw_node->i.i_projid;
else
ASSERT(0);
/* write two blocks */
if (f2fs_write_default_quota(qtype, data_blk_nor)) {
if (f2fs_write_default_quota(qtype, data_blk_nor, raw_id)) {
free(raw_node);
return -1;
}