From patchwork Tue Aug 22 21:16:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 9916191 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7FD5A60381 for ; Tue, 22 Aug 2017 21:16:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73C4C288F8 for ; Tue, 22 Aug 2017 21:16:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68919288FD; Tue, 22 Aug 2017 21:16:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19443288F8 for ; Tue, 22 Aug 2017 21:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751979AbdHVVQv (ORCPT ); Tue, 22 Aug 2017 17:16:51 -0400 Received: from sandeen.net ([63.231.237.45]:34596 "EHLO sandeen.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751290AbdHVVQt (ORCPT ); Tue, 22 Aug 2017 17:16:49 -0400 Received: from [10.0.0.4] (liberator [10.0.0.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sandeen.net (Postfix) with ESMTPSA id A357987A; Tue, 22 Aug 2017 16:15:27 -0500 (CDT) Subject: [PATCH 2/3] xfs_io: get foreign blocksize & sector size in openfile To: Eric Sandeen , linux-xfs References: <2b5a5742-5343-671f-8b89-9d1dc9841c17@redhat.com> From: Eric Sandeen Message-ID: Date: Tue, 22 Aug 2017 16:16:48 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <2b5a5742-5343-671f-8b89-9d1dc9841c17@redhat.com> Content-Language: en-US Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use statvfs to fill in geometry block size and sector size in openfile() for "foreign" (non-xfs) files. Signed-off-by: Eric Sandeen --- -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/io/open.c b/io/open.c index f2ea7c3..b0dcabc 100644 --- a/io/open.c +++ b/io/open.c @@ -16,6 +16,7 @@ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include "command.h" #include "input.h" #include "init.h" @@ -94,13 +95,25 @@ openfile( } } - if (!geom || !platform_test_xfs_fd(fd)) + if (!geom) return fd; - if (xfsctl(path, fd, XFS_IOC_FSGEOMETRY, geom) < 0) { - perror("XFS_IOC_FSGEOMETRY"); - close(fd); - return -1; + if (platform_test_xfs_fd(fd)) { + if (xfsctl(path, fd, XFS_IOC_FSGEOMETRY, geom) < 0) { + perror("XFS_IOC_FSGEOMETRY"); + close(fd); + return -1; + } + } else { /* Fill in block & sector size for cvtnum */ + struct statvfs statbuf; + + if (fstatvfs(fd, &statbuf) < 0) { + perror("fstatvfs"); + close(fd); + return -1; + } + geom->blocksize = statbuf.f_bsize; + geom->sectsize = 512; } if (!(flags & IO_READONLY) && (flags & IO_REALTIME)) {