Received: by 10.192.165.148 with SMTP id m20csp552103imm; Fri, 4 May 2018 02:22:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrFvx04hcGLxhqRE0QWeGk/xQY9yhbEKpYHat+AehddiFcXcDg7n/C9rPkvqwVasqJsxC9V X-Received: by 2002:a17:902:9890:: with SMTP id s16-v6mr27239695plp.132.1525425774286; Fri, 04 May 2018 02:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525425774; cv=none; d=google.com; s=arc-20160816; b=vbPDBBOVYk22RxqyGNHU8KOOHJtKpN5Tqh70FbwPDU94461xDxhxcA9UDABkNBWOmN rkOBR3yvheYbmfTijt4Uf2oknaO4h6Zbm797ETaOJl/mTypEScq0jMGgzpmA9s1S+DJ9 qe+t2tjfPHKZnCmduYn7RbvWq9ZY/KvXdN/92T42CQIBF3nmqY/dxVAtmiJ1a80liAVI Rk4Al9Y/dg9pUEZkoIFRfHU/s5muoZeoMTe9+fkdaF9Kx8rmUwuKv/7TYj0AQR3N0A5E V1NzX8LN2vwuowTXTZfKwk6BBH8dG+sg2tsCyilXrbT6V9R0WaFC+pz8znoyQmqKZDKO PcPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=Py/bPWey+GD3w4WdmXisPnVlCKrLh4KUhuVxOWU1dK8=; b=mFOiuwuux4pys491j/F4WOM3k9TBv2v74khVvlRaM3xn4hANyX+kNe5hx2qyf4mMb0 G8z3kQKoZ2IHabxZ9NF+H5TXAJ4ULwNILrSIhDLra03Q3u6iWBLMUJg2ZdAUnhpjsy6+ Co1h+cId6QsderByH6WaIWm1dpzGF20cOkYTd0HxQDYIH0ICwA1xZEbH8xsVEs2f2WHY JPwJ5GXW+5p4cN9HPT8CCI/SnmVHTulFbGlpB3ljeO0F6zK1BfXbuxMrpo8Ru9eO0HT7 UB0dsb2F3PbNNx4DNa2syj3W4WNi5LZWQ3MqYCq9Ejowi/NPfWIICLuvcWjpzdSWgo0J OQtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o7-v6si12645009pgp.525.2018.05.04.02.22.39; Fri, 04 May 2018 02:22:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751673AbeEDJVS (ORCPT + 99 others); Fri, 4 May 2018 05:21:18 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7652 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751124AbeEDJVN (ORCPT ); Fri, 4 May 2018 05:21:13 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 029AEA5AC98B8; Fri, 4 May 2018 17:21:00 +0800 (CST) Received: from huawei.com (10.113.189.234) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.361.1; Fri, 4 May 2018 17:20:51 +0800 From: Yunlong Song To: , , , , CC: , , , , , Subject: [PATCH] f2fs-tools: fix the sector_size to default value Date: Fri, 4 May 2018 17:20:45 +0800 Message-ID: <1525425645-127945-1-git-send-email-yunlong.song@huawei.com> X-Mailer: git-send-email 1.8.5.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.113.189.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org f2fs-tools uses ioctl BLKSSZGET to get sector_size, however, this ioctl will return a value which may be larger than 512 (according to the value of q->limits.logical_block_size), then this will be inconsistent with the start_sector, since start_sector is got from ioctl HDIO_GETGEO and is always in 512 size unit for a sector. To fix this problem, just set the sector_size to the default value 512. Signed-off-by: Yunlong Song --- lib/libf2fs.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/libf2fs.c b/lib/libf2fs.c index 102e579..e160f2a 100644 --- a/lib/libf2fs.c +++ b/lib/libf2fs.c @@ -768,7 +768,6 @@ void get_kernel_uname_version(__u8 *version) int get_device_info(int i) { int32_t fd = 0; - uint32_t sector_size; #ifndef BLKGETSIZE64 uint32_t total_sectors; #endif @@ -822,12 +821,6 @@ int get_device_info(int i) } else if (S_ISREG(stat_buf->st_mode)) { dev->total_sectors = stat_buf->st_size / dev->sector_size; } else if (S_ISBLK(stat_buf->st_mode)) { -#ifdef BLKSSZGET - if (ioctl(fd, BLKSSZGET, §or_size) < 0) - MSG(0, "\tError: Using the default sector size\n"); - else if (dev->sector_size < sector_size) - dev->sector_size = sector_size; -#endif #ifdef BLKGETSIZE64 if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) { MSG(0, "\tError: Cannot get the device size\n"); -- 1.8.5.2