summaryrefslogtreecommitdiffstats
path: root/mount/mount.c
diff options
context:
space:
mode:
authorKarel Zak2007-11-08 00:54:58 +0100
committerKarel Zak2007-11-08 00:54:58 +0100
commit461311047bf28ea838ab63e5a5e5b2003af2f377 (patch)
tree5adcb50b7e4f542d65b6fb6bb71d437d77dd66fe /mount/mount.c
parentsfdisk: use get_linux_version() (diff)
downloadkernel-qcow2-util-linux-461311047bf28ea838ab63e5a5e5b2003af2f377.tar.gz
kernel-qcow2-util-linux-461311047bf28ea838ab63e5a5e5b2003af2f377.tar.xz
kernel-qcow2-util-linux-461311047bf28ea838ab63e5a5e5b2003af2f377.zip
mount: use blkdev_get_size()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount/mount.c')
-rw-r--r--mount/mount.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/mount/mount.c b/mount/mount.c
index 154f0da54..7a6ae004a 100644
--- a/mount/mount.c
+++ b/mount/mount.c
@@ -37,11 +37,11 @@
#include "fstab.h"
#include "lomount.h"
#include "loop.h"
-#include "linux_fs.h" /* for BLKGETSIZE */
#include "getusername.h"
#include "mount_paths.h"
#include "env.h"
#include "nls.h"
+#include "blkdev.h"
#include "realpath.h"
#define DO_PS_FIDDLING
@@ -1219,8 +1219,7 @@ try_mount_one (const char *spec0, const char *node0, const char *types0,
break;
case EINVAL:
{ int fd;
- unsigned long size;
- int warned=0;
+ unsigned long long size = 0;
if (flags & MS_REMOUNT) {
error (_("mount: %s not mounted already, or bad option"), node);
@@ -1230,32 +1229,21 @@ try_mount_one (const char *spec0, const char *node0, const char *types0,
spec);
if (stat(spec, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)
- && (fd = open(spec, O_RDONLY | O_NONBLOCK)) >= 0) {
- if (ioctl(fd, BLKGETSIZE, &size) == 0) {
- if (size == 0 && !loop) {
- warned++;
+ && (fd = open(spec, O_RDONLY | O_NONBLOCK)) >= 0) {
+
+ if (blkdev_get_size(fd, &size) == 0) {
+ if (size == 0 && !loop)
error(_(
" (could this be the IDE device where you in fact use\n"
" ide-scsi so that sr0 or sda or so is needed?)"));
- }
- if (size && size <= 2) {
- warned++;
+
+ if (size && size <= 2)
error(_(
" (aren't you trying to mount an extended partition,\n"
" instead of some logical partition inside?)"));
- }
- close(fd);
- }
-#if 0
- /* 0xf for SCSI, 0x3f for IDE. One might check /proc/partitions
- to see whether this thing really is partitioned.
- Do not suggest partitions for /dev/fd0. */
- if (!warned && (statbuf.st_rdev & 0xf) == 0) {
- warned++;
- error (" (could this be the whole disk device\n"
- " where you need a partition?)");
+
+ close(fd);
}
-#endif
}
error(_(
" In some cases useful info is found in syslog - try\n"