xfs
[Top] [All Lists]

[PATCH] mkfs: get size of device properly

To: xfs-oss <xfs@xxxxxxxxxxx>
Subject: [PATCH] mkfs: get size of device properly
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Fri, 15 Jan 2010 16:57:52 -0600
User-agent: Thunderbird 2.0.0.23 (Macintosh/20090812)
Ok, one more.

I've been having too many problems w/ xfstests today to have run
the last patch through xfstests but should have at least run
032.  :(

Anyway, last change wasn't valid to test the size of a device
node; total brain fart.  After this I'm testing the hell out
of the next patch I send, I promise!

--------

Test device node size properly in check_overwrite, st_size
is only valid for regular files.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxxx>
---

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 0743976..689425d 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -297,18 +297,23 @@ check_overwrite(
        const char      *type;
        blkid_probe     pr = NULL;
        int             ret;
-       struct stat     statbuf;
+       int             fd;
+       long long       size;
+       int             bsz;
 
        if (!device || !*device)
                return 0;
 
        ret = -1; /* will reset on success of all setup calls */
 
-       if (stat(device, &statbuf) < 0)
+       fd = open(device, O_RDONLY);
+       if (fd < 0)
                goto out;
+       platform_findsizes(device, fd, &size, &bsz);
+       close(fd);
 
        /* nothing to overwrite on a 0-length device */
-       if (statbuf.st_size == 0) {
+       if (size == 0) {
                ret = 0;
                goto out;
        }

<Prev in Thread] Current Thread [Next in Thread>