summaryrefslogtreecommitdiffstats
path: root/mount
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
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')
-rw-r--r--mount/Makefile.am5
-rw-r--r--mount/fsprobe.c1
-rw-r--r--mount/fsprobe_volumeid.c5
-rw-r--r--mount/linux_fs.h15
-rw-r--r--mount/mount.c32
5 files changed, 16 insertions, 42 deletions
diff --git a/mount/Makefile.am b/mount/Makefile.am
index 45674faf6..4ba8f56f6 100644
--- a/mount/Makefile.am
+++ b/mount/Makefile.am
@@ -8,12 +8,13 @@ man_MANS = fstab.5 mount.8 swapoff.8 swapon.8 umount.8 losetup.8
utils_common = sundries.c xmalloc.c realpath.c fsprobe.c
-headers_common = fstab.h linux_fs.h mount_mntent.h mount_constants.h \
+headers_common = fstab.h mount_mntent.h mount_constants.h \
mount_paths.h lomount.h fsprobe.h realpath.h xmalloc.h \
getusername.h loop.h sundries.h
mount_common = fstab.c mount_mntent.c getusername.c lomount.c \
- $(utils_common) $(headers_common) ../lib/env.c
+ $(utils_common) $(headers_common) ../lib/env.c ../lib/linux_version.c \
+ ../lib/blkdev.c
mount_SOURCES = mount.c $(mount_common) ../lib/setproctitle.c
mount_CFLAGS = $(SUID_CFLAGS) $(AM_CFLAGS)
diff --git a/mount/fsprobe.c b/mount/fsprobe.c
index b874f9d7f..0be73ac3a 100644
--- a/mount/fsprobe.c
+++ b/mount/fsprobe.c
@@ -6,7 +6,6 @@
#include <sys/stat.h>
#include <sys/types.h>
#include "mount_paths.h"
-#include "linux_fs.h"
#include "fsprobe.h"
#include "sundries.h" /* for xstrdup */
#include "nls.h"
diff --git a/mount/fsprobe_volumeid.c b/mount/fsprobe_volumeid.c
index 6b47392bc..efdacc7d3 100644
--- a/mount/fsprobe_volumeid.c
+++ b/mount/fsprobe_volumeid.c
@@ -8,6 +8,8 @@
#include <fcntl.h>
#include <libvolume_id.h>
+#include "blkdev.h"
+
#include "fsprobe.h"
#include "realpath.h"
#include "mount_paths.h"
@@ -39,8 +41,7 @@ static char
return NULL;
}
- /* TODO: use blkdev_get_size() */
- if (ioctl(fd, BLKGETSIZE64, &size) != 0)
+ if (blkdev_get_size(fd, &size) != 0)
size = 0;
if (volume_id_probe_all(id, 0, size) == 0) {
diff --git a/mount/linux_fs.h b/mount/linux_fs.h
deleted file mode 100644
index e47da2f54..000000000
--- a/mount/linux_fs.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Including <linux/fs.h> became more and more painful.
- Below a very abbreviated version of some declarations,
- only designed to be able to check a magic number
- in case no filesystem type was given. */
-
-#ifndef BLKGETSIZE
-#ifndef _IO
-/* pre-1.3.45 */
-#define BLKGETSIZE 0x1260 /* return device size */
-#else
-/* same on i386, m68k, arm; different on alpha, mips, sparc, ppc */
-#define BLKGETSIZE _IO(0x12,96)
-#endif
-#endif
-
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"