linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Junling Zheng <zhengjunling@huawei.com>
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [PATCH 4/4] f2fs: unify the length of versions
Date: Mon, 10 Oct 2016 09:49:57 -0700	[thread overview]
Message-ID: <20161010164957.GA69914@jaegeuk> (raw)
In-Reply-To: <57F84726.9020207@huawei.com>

On Sat, Oct 08, 2016 at 09:08:54AM +0800, Junling Zheng wrote:
> On 2016/10/1 0:25, Jaegeuk Kim wrote:
> > On Thu, Sep 29, 2016 at 06:38:37PM +0800, Junling Zheng wrote:
> >> Currently, versions in f2fs_configuration have one more byte, so versions
> >> in f2fs_super_block may not end with '\0', which will cause errors while
> >> printing it in print_raw_sb_info(). Unify the length of versions to fix it.
> > 
> > This is to handle non-zero terminated version characters in f2fs_super_block.
> > What is your point?
> > 
> > Thanks,
> > 
> 
> If version characters are non-zero terminated in f2fs_super_block, it will get
> incorrect results while printing it in print_raw_sb_info():
> ...
> DISP("%s", sb, version);
> ...

Then, I think we need to fix this line to avoid garbage when printing out.

Thanks,

> 
> Thanks,
> Junling
> 
> >>
> >> Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
> >> ---
> >>  include/f2fs_fs.h | 6 +++---
> >>  lib/libf2fs.c     | 4 ++--
> >>  2 files changed, 5 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
> >> index 1345e2d..e666076 100644
> >> --- a/include/f2fs_fs.h
> >> +++ b/include/f2fs_fs.h
> >> @@ -270,9 +270,9 @@ struct f2fs_configuration {
> >>  	u_int64_t target_sectors;
> >>  	u_int32_t sectors_per_blk;
> >>  	u_int32_t blks_per_seg;
> >> -	__u8 init_version[VERSION_LEN + 1];
> >> -	__u8 sb_version[VERSION_LEN + 1];
> >> -	__u8 version[VERSION_LEN + 1];
> >> +	__u8 init_version[VERSION_LEN];
> >> +	__u8 sb_version[VERSION_LEN];
> >> +	__u8 version[VERSION_LEN];
> >>  	char *vol_label;
> >>  	int heap;
> >>  	int32_t fd, kd;
> >> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> >> index 706cc34..0a9436b 100644
> >> --- a/lib/libf2fs.c
> >> +++ b/lib/libf2fs.c
> >> @@ -570,11 +570,11 @@ int f2fs_dev_is_umounted(struct f2fs_configuration *c)
> >>  void get_kernel_version(__u8 *version)
> >>  {
> >>  	int i;
> >> -	for (i = 0; i < VERSION_LEN; i++) {
> >> +	for (i = 0; i < VERSION_LEN - 1; i++) {
> >>  		if (version[i] == '\n')
> >>  			break;
> >>  	}
> >> -	memset(version + i, 0, VERSION_LEN + 1 - i);
> >> +	memset(version + i, 0, VERSION_LEN - i);
> >>  }
> >>  
> >>  int f2fs_get_device_info(struct f2fs_configuration *c)
> >> -- 
> >> 2.7.4
> >>
> >>
> >> ------------------------------------------------------------------------------
> >> _______________________________________________
> >> Linux-f2fs-devel mailing list
> >> Linux-f2fs-devel@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> > 
> > .
> > 
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

      reply	other threads:[~2016-10-10 16:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-29 10:38 [PATCH 1/4] fsck.f2fs: free cp_page_1 in validate_checkpoint Junling Zheng
2016-09-29 10:38 ` [PATCH 2/4] fsck.f2fs: fix incorrect ERR_MSG in f2fs_do_mount Junling Zheng
2016-09-29 10:38 ` [PATCH 3/4] fsck.f2fs: fix a typo in check_sector_size Junling Zheng
2016-09-29 10:38 ` [PATCH 4/4] f2fs: unify the length of versions Junling Zheng
2016-09-30 16:25   ` Jaegeuk Kim
2016-10-08  1:08     ` Junling Zheng
2016-10-10 16:49       ` Jaegeuk Kim [this message]

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=20161010164957.GA69914@jaegeuk \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=zhengjunling@huawei.com \
    /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;
as well as URLs for NNTP newsgroup(s).