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)
#include <fcntl.h>
#include <libvolume_id.h>
+#include "blkdev.h"
+
#include "fsprobe.h"
#include "realpath.h"
#include "mount_paths.h"
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) {
+++ /dev/null
-/* 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
-
#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
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);
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"