All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Eric Sandeen <sandeen@redhat.com>, linux-xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH 2/3] xfs_io: get foreign blocksize & sector size in openfile
Date: Tue, 22 Aug 2017 16:16:48 -0500	[thread overview]
Message-ID: <e8e53975-5482-3846-f528-08fc5db97517@sandeen.net> (raw)
In-Reply-To: <2b5a5742-5343-671f-8b89-9d1dc9841c17@redhat.com>

Use statvfs to fill in geometry block size and sector
size in openfile() for "foreign" (non-xfs) files.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

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 <sys/statvfs.h>
 #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)) {

  parent reply	other threads:[~2017-08-22 21:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-22 21:11 [PATCH 0/3] libxfs: tidy up cvtnum junk Eric Sandeen
2017-08-22 21:12 ` [PATCH 1/3] libxfs: handle 0 blocksize or sectorsize in cvtnum Eric Sandeen
2017-08-23  1:01   ` Dave Chinner
2017-08-23  2:13     ` Eric Sandeen
2017-08-23 20:14       ` Darrick J. Wong
2017-08-23 20:18         ` Eric Sandeen
2017-08-23 20:24           ` Darrick J. Wong
2017-08-22 21:16 ` Eric Sandeen [this message]
2017-08-22 21:19 ` [PATCH 3/3] xfs_io: add io_cvtnum wrapper Eric Sandeen
2017-08-22 21:22 ` [PATCH 4/3] xfs_quota: remove dodgy init_cvtnum Eric Sandeen

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=e8e53975-5482-3846-f528-08fc5db97517@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.