]> err.no Git - util-linux/commitdiff
mount: use blkdev_get_size()
authorKarel Zak <kzak@redhat.com>
Wed, 7 Nov 2007 23:54:58 +0000 (00:54 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 7 Nov 2007 23:54:58 +0000 (00:54 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
mount/Makefile.am
mount/fsprobe.c
mount/fsprobe_volumeid.c
mount/linux_fs.h [deleted file]
mount/mount.c

index 45674faf6834e316710c7e7cbe6764220462aa61..4ba8f56f6dce3df1eeaeed48ab874db79634618f 100644 (file)
@@ -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)
index b874f9d7f3117bbd17177bc2da2ad3ed92d201cb..0be73ac3a2a5208b0ffc4491afb58a6b126a1e21 100644 (file)
@@ -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"
index 6b47392bc1535ba9843ef88cd4f0bc9e5c2263b4..efdacc7d3d71fb5972af5eb4b5e9a9beccd4ccf4 100644 (file)
@@ -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 (file)
index e47da2f..0000000
+++ /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
-
index 154f0da546b4763b6d7fe33a98b5dfeffcf03dfe..7a6ae004a95a225cb6b27a74dfc2e1d4b37dbbc2 100644 (file)
 #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"