public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: xfs-oss <xfs@oss.sgi.com>
Subject: [PATCH] mkfs: get size of device properly
Date: Fri, 15 Jan 2010 16:57:52 -0600	[thread overview]
Message-ID: <4B50F2F0.4050909@sandeen.net> (raw)

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@sandeen.net>
---

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;
 	}

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

             reply	other threads:[~2010-01-15 22:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-15 22:57 Eric Sandeen [this message]
2010-01-17 11:40 ` [PATCH] mkfs: get size of device properly Christoph Hellwig
2010-01-17 15:49   ` 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=4B50F2F0.4050909@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=xfs@oss.sgi.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox