From mboxrd@z Thu Jan 1 00:00:00 1970 From: Junling Zheng Subject: Re: [PATCH 4/4] f2fs: unify the length of versions Date: Sat, 8 Oct 2016 09:08:54 +0800 Message-ID: <57F84726.9020207@huawei.com> References: <1475145517-18366-1-git-send-email-zhengjunling@huawei.com> <1475145517-18366-4-git-send-email-zhengjunling@huawei.com> <20160930162528.GA46477@jaegeuk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1bsg8c-0006Qs-Qu for linux-f2fs-devel@lists.sourceforge.net; Sat, 08 Oct 2016 01:09:18 +0000 Received: from szxga01-in.huawei.com ([58.251.152.64]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1bsg8Z-0000qu-4N for linux-f2fs-devel@lists.sourceforge.net; Sat, 08 Oct 2016 01:09:18 +0000 In-Reply-To: <20160930162528.GA46477@jaegeuk> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: Jaegeuk Kim Cc: linux-f2fs-devel@lists.sourceforge.net 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); ... Thanks, Junling >> >> Signed-off-by: Junling Zheng >> --- >> 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