From: Eric Sandeen <sandeen@sandeen.net>
To: Eric Sandeen <sandeen@redhat.com>
Cc: Jim Meyering <meyering@redhat.com>, xfs mailing list <xfs@oss.sgi.com>
Subject: [PATCH V2] mkfs: don't try to detect filesystems on regular files via blkid
Date: Thu, 04 Feb 2010 11:48:47 -0600 [thread overview]
Message-ID: <4B6B087F.80901@sandeen.net> (raw)
In-Reply-To: <4B6AF6FC.6030101@redhat.com>
from RH bug
https://bugzilla.redhat.com/show_bug.cgi?id=561870
# dd if=/dev/zero of=k bs=1MB count=2 seek=20; mkfs.xfs k
# mkfs.xfs: probe of k failed, cannot detect existing filesystem.
# mkfs.xfs: Use the -f option to force overwrite.
blkid fails to do a probe of a regular file.
I wish blkid would cope with this, but for now it might
be better to just turn it off.
I kept the size==0 check just in case we stumble on a 0-sized
device, blkid doesn't like that either...
Reported-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
V2: use fstat after the open
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 9baf116..219c81e 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -300,6 +300,7 @@ check_overwrite(
int fd;
long long size;
int bsz;
+ struct stat statbuf;
if (!device || !*device)
return 0;
@@ -309,6 +310,14 @@ check_overwrite(
fd = open(device, O_RDONLY);
if (fd < 0)
goto out;
+
+ /* blkid can't get info from a regular file */
+ if (!fstat(fd, &statbuf) && S_ISREG(statbuf.st_mode)) {
+ close(fd);
+ ret = 0;
+ goto out;
+ }
+
platform_findsizes(device, fd, &size, &bsz);
close(fd);
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2010-02-04 17:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-04 16:34 [PATCH] mkfs: don't try to detect filesystems on regular files via blkid Eric Sandeen
2010-02-04 16:46 ` Jim Meyering
2010-02-04 16:54 ` Eric Sandeen
2010-02-04 17:48 ` Eric Sandeen [this message]
2010-02-04 19:43 ` [PATCH V2] " Eric Sandeen
2010-02-04 19:40 ` [PATCH] mkfs.xfs fix detection of empty devices Christoph Hellwig
2010-02-04 20:15 ` Eric Sandeen
2010-02-04 22:18 ` [PATCH v2] " Christoph Hellwig
2010-02-05 3:41 ` 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=4B6B087F.80901@sandeen.net \
--to=sandeen@sandeen.net \
--cc=meyering@redhat.com \
--cc=sandeen@redhat.com \
--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 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.