From: Yue Hu <zbestahu@gmail.com>
To: linux-erofs@lists.ozlabs.org
Cc: Yue Hu <huyue2@coolpad.com>
Subject: [PATCH 2/2] AOSP: erofs-utils: add a variable to validate tail block map in block list
Date: Tue, 15 Aug 2023 12:55:25 +0800 [thread overview]
Message-ID: <20230815045525.17990-2-zbestahu@gmail.com> (raw)
In-Reply-To: <20230815045525.17990-1-zbestahu@gmail.com>
From: Yue Hu <huyue2@coolpad.com>
We write the block map directly before the tail, as this applies only to
regular files. However, the tail block map does not follow the rule.
Therefore, introduce a variable to track whether the tail block is safe
to write before its map if it exists rather than separately check the
file type when mapping.
Signed-off-by: Yue Hu <huyue2@coolpad.com>
---
lib/block_list.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/lib/block_list.c b/lib/block_list.c
index a1c719d..e59a8d7 100644
--- a/lib/block_list.c
+++ b/lib/block_list.c
@@ -12,6 +12,7 @@
#include "erofs/print.h"
static FILE *block_list_fp;
+static bool regular_tail = false;
int erofs_droid_blocklist_fopen(void)
{
@@ -77,22 +78,23 @@ void erofs_droid_blocklist_write_extent(struct erofs_inode *inode,
void erofs_droid_blocklist_write(struct erofs_inode *inode,
erofs_blk_t blk_start, erofs_blk_t nblocks)
{
- if (!block_list_fp || !cfg.mount_point || !nblocks)
+ if (!block_list_fp || !cfg.mount_point)
return;
- blocklist_write(inode->i_srcpath, blk_start, nblocks,
- true, !inode->idata_size);
+ if (nblocks)
+ blocklist_write(inode->i_srcpath, blk_start, nblocks, true,
+ !inode->idata_size);
+ if (inode->idata_size)
+ regular_tail = true;
}
void erofs_droid_blocklist_write_tail_end(struct erofs_inode *inode,
erofs_blk_t blkaddr, bool first_block)
{
- if (!block_list_fp || !cfg.mount_point)
+ if (!block_list_fp || !cfg.mount_point || !regular_tail)
return;
- /* XXX: a bit hacky.. may need a better approach */
- if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
- return;
+ regular_tail = false;
if (!first_block) {
if (blkaddr == NULL_ADDR)
--
2.17.1
next prev parent reply other threads:[~2023-08-15 4:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-15 4:55 [PATCH 1/2 v2] AOSP: erofs-utils: pass a parameter to write tail end in block list Yue Hu
2023-08-15 4:55 ` Yue Hu [this message]
2023-08-15 4:59 ` Gao Xiang
2023-08-15 5:40 ` Yue Hu
2023-08-15 5:36 ` Gao Xiang
2023-08-15 6:21 ` Yue Hu
2023-08-15 6:18 ` Gao Xiang
2023-08-15 6:45 ` Yue Hu
2023-08-15 6:44 ` Gao Xiang
2023-08-15 7:00 ` Yue Hu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230815045525.17990-2-zbestahu@gmail.com \
--to=zbestahu@gmail.com \
--cc=huyue2@coolpad.com \
--cc=linux-erofs@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox