[PATCH] mount: libvolume_id support and removal of old fs detection code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

this patch adds libvolume_id support and removes the old fs detection code.
Since I had to clean up the original patch I decided to remove the old fs 
detection code also in this patch. 
I hope this does not bloat the patch too much.

Matthias

===================================================================
add libvolume_id support and remove old fs detection code.

add --with-libvolume_id configure option for libvolume_id support.
Default is to build against libblkid.

Signed-off-by: Matthias Koenig <mkoenig@xxxxxxx>

Index: util-linux-devel/mount/fstab.c
===================================================================
--- util-linux-devel.orig/mount/fstab.c
+++ util-linux-devel/mount/fstab.c
@@ -313,6 +313,7 @@ has_uuid(const char *device, const char 
 struct mntentchn *
 getfsspecfile (const char *spec, const char *file) {
 	struct mntentchn *mc, *mc0;
+	char *nspec;
 
 	mc0 = fstab_head();
 
@@ -323,11 +324,12 @@ getfsspecfile (const char *spec, const c
 			return mc;
 
 	/* second attempt: names found after symlink resolution */
+	nspec = canonicalize(spec);
 	for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt)
 		if ((streq(mc->m.mnt_dir, file) ||
 		     streq(canonicalize(mc->m.mnt_dir), file))
 		    && (streq(mc->m.mnt_fsname, spec) ||
-			streq(canonicalize(mc->m.mnt_fsname), spec)))
+			streq(canonicalize(mc->m.mnt_fsname), nspec)))
 			return mc;
 
 	/* third attempt: names found after LABEL= or UUID= resolution */
@@ -364,11 +366,21 @@ getfsfile (const char *file) {
 struct mntentchn *
 getfsspec (const char *spec) {
 	struct mntentchn *mc, *mc0;
+	const char *nspec, *fsname;
 
 	mc0 = fstab_head();
-	for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt)
-		if (streq(mc->m.mnt_fsname, spec))
+	for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) {
+		if (!strncmp (mc->m.mnt_fsname, "LABEL=", 6)) {
+			fsname = mount_get_devname_by_label(mc->m.mnt_fsname + 6);
+		} else if (!strncmp(mc->m.mnt_fsname, "UUID=", 5)) {
+			fsname = mount_get_devname_by_uuid(mc->m.mnt_fsname + 5);
+		} else {
+			fsname = mc->m.mnt_fsname;
+		}
+		nspec = canonicalize(fsname);
+		if (streq(nspec, spec))
 			return mc;
+	}
 	return NULL;
 }
 
@@ -747,6 +759,8 @@ char *progname;
 
 const char *mount_get_volume_label_by_spec(const char *spec) { return NULL; }
 const char *mount_get_devname_by_uuid(const char *uuid) { return NULL; }
+const char *mount_get_devname_by_label(const char *label) { return NULL; }
+const char *mount_get_volume_uuid_by_spec(const char *spec) { return NULL; }
 struct my_mntent *my_getmntent (mntFILE *mfp) { return NULL; }
 mntFILE *my_setmntent (const char *file, char *mode) { return NULL; }
 void my_endmntent (mntFILE *mfp) { }
Index: util-linux-devel/mount/mount.c
===================================================================
--- util-linux-devel.orig/mount/mount.c
+++ util-linux-devel/mount/mount.c
@@ -35,7 +35,7 @@
 #include "linux_fs.h"		/* for BLKGETSIZE */
 #include "mount_guess_rootdev.h"
 #include "mount_guess_fstype.h"
-#include "mount_by_label.h"
+//#include "mount_by_label.h"
 #include "getusername.h"
 #include "mount_paths.h"
 #include "env.h"
@@ -1764,6 +1764,8 @@ main(int argc, char *argv[]) {
 			if (mc == NULL)
 				mc = getfsspec (spec);
 			if (mc == NULL)
+				mc = getfsspec (canonicalize(spec));
+			if (mc == NULL)
 				die (EX_USAGE,
 				     _("mount: cannot find %s in %s"),
 				     spec, _PATH_FSTAB);
Index: util-linux-devel/mount/mount_blkid.c
===================================================================
--- util-linux-devel.orig/mount/mount_blkid.c
+++ util-linux-devel/mount/mount_blkid.c
@@ -1,111 +1,48 @@
 #include <stdio.h>
 #include "mount_blkid.h"
 
-#ifdef HAVE_LIBBLKID
-
 blkid_cache blkid;
 
 void
-mount_blkid_get_cache(void) {
+mount_blkid_get_cache(void)
+{
 	blkid_get_cache(&blkid, NULL);
 }
 
 void
-mount_blkid_put_cache(void) {
+mount_blkid_put_cache(void)
+{
 	blkid_put_cache(blkid);
 }
 
 const char *
-mount_get_volume_label_by_spec(const char *spec) {
+mount_get_volume_label_by_spec(const char *spec)
+{
 	return blkid_get_tag_value(blkid, "LABEL", spec);
 }
 
 const char *
-mount_get_devname(const char *spec) {
+mount_get_devname(const char *spec)
+{
 	return blkid_get_devname(blkid, spec, 0);
 }
 
 const char *
-mount_get_devname_by_uuid(const char *uuid) {
+mount_get_devname_by_uuid(const char *uuid)
+{
 	return blkid_get_devname(blkid, "UUID", uuid);
 }
 
 const char *
-mount_get_devname_by_label(const char *label) {
+mount_get_devname_by_label(const char *label)
+{
 	return blkid_get_devname(blkid, "LABEL", label);
 }
 
 /* Also when no UUID= or LABEL= occur? No verbose? No warnings? */
 const char *
-mount_get_devname_for_mounting(const char *spec) {
+mount_get_devname_for_mounting(const char *spec)
+{
 	return blkid_get_devname(blkid, spec, 0);
 }
 
-#else
-#include <string.h>
-#include "sundries.h"
-#include "mount_by_label.h"
-#include "nls.h"
-
-void
-mount_blkid_get_cache(void) {
-}
-
-void
-mount_blkid_put_cache(void) {
-}
-
-const char *
-mount_get_volume_label_by_spec(const char *spec) {
-	return xstrdup(get_volume_label_by_spec(spec));
-}
-
-const char *
-mount_get_devname(const char *spec) {
-	if (!strncmp(spec, "UUID=", 5))
-		return get_spec_by_uuid(spec+5);
-	if (!strncmp(spec, "LABEL=", 6))
-		return get_spec_by_volume_label(spec+6);
-	return spec;
-}
-
-const char *
-mount_get_devname_by_uuid(const char *uuid) {
-	return get_spec_by_uuid(uuid);
-}
-
-extern char *progname;
-
-const char *
-mount_get_devname_by_label(const char *volumelabel) {
-	const char *spec, *spec2;
-
-	spec = get_spec_by_volume_label(volumelabel);
-	spec2 = second_occurrence_of_vol_label(volumelabel);
-	if (spec2)
-		die (EX_FAIL,
-		     _("%s: error: the label %s occurs on both %s and %s\n"),
-		     progname, volumelabel, spec, spec2);
-	return spec;
-}
-
-const char *
-mount_get_devname_for_mounting(const char *spec) {
-	const char *nspec;
-
-	if (!strncmp(spec, "UUID=", 5)) {
-		nspec = mount_get_devname_by_uuid(spec+5);
-		if (nspec && verbose > 1)
-			printf(_("mount: going to mount %s by UUID\n"), spec);
-	} else if (!strncmp(spec, "LABEL=", 6)) {
-		nspec = mount_get_devname_by_label(spec+6);
-		if (nspec && verbose > 1)
-			printf(_("mount: going to mount %s by label\n"), spec);
-	} else
-		nspec = spec;
-
-	return nspec;
-}
-
-
-#endif
Index: util-linux-devel/mount/mount_blkid.h
===================================================================
--- util-linux-devel.orig/mount/mount_blkid.h
+++ util-linux-devel/mount/mount_blkid.h
@@ -10,3 +10,5 @@ extern const char *mount_get_devname_by_
 extern const char *mount_get_volume_label_by_spec(const char *spec);
 extern const char *mount_get_devname(const char *spec);
 extern const char *mount_get_devname_for_mounting(const char *spec);
+
+extern const char *volume_id_get_tag(const char *spec, const char *token);
Index: util-linux-devel/mount/mount_by_label.c
===================================================================
--- util-linux-devel.orig/mount/mount_by_label.c
+++ /dev/null
@@ -1,363 +0,0 @@
-#ifndef HAVE_LIBBLKID
-/*
- * mount_by_label.c - aeb
- *
- * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@xxxxxxxxxx>
- * - added Native Language Support
- * 2000-01-20 James Antill <james@xxxxxxx>
- * - Added error message if /proc/partitions cannot be opened
- * 2000-05-09 Erik Troan <ewt@xxxxxxxxxx>
- * - Added cache for UUID and disk labels
- * 2000-11-07 Nathan Scott <nathans@xxxxxxx>
- * - Added XFS support
- * 2001-11-22 Kirby Bohling <kbohling@xxxxxxxxxxx>
- * - Added support of labels on LVM
- * 2002-03-21 Christoph Hellwig <hch@xxxxxxxxxxxxx>
- * - Added JFS support
- * 2002-07-11 Christoph Hellwig <hch@xxxxxxxxxxxxx>
- * - Added JFS v2 format support
- * 2002-07-26 Luciano Chavez <lnx1138@xxxxxxxxxx>
- * - Added EVMS support
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/types.h>   /* needed for opendir */
-#include <dirent.h>
-#include "sundries.h"		/* for xstrdup */
-#include "linux_fs.h"
-#include "get_label_uuid.h"
-#include "mount_by_label.h"
-#include "nls.h"
-
-#define PROC_PARTITIONS "/proc/partitions"
-#define DEVLABELDIR	"/dev"
-#define VG_DIR          "/proc/lvm/VGs"
-#define EVMS_VOLUME_NAME_SIZE  127
-#define PROC_EVMS_VOLUMES "/proc/evms/volumes"
-
-extern char *progname;
-
-static struct uuidCache_s {
-	struct uuidCache_s *next;
-	char uuid[16];
-	char *label;
-	char *device;
-} *uuidCache = NULL;
-
-static void
-uuidcache_addentry(char *device, char *label, char *uuid) {
-	struct uuidCache_s *last;
-
-	if (!uuidCache) {
-		last = uuidCache = malloc(sizeof(*uuidCache));
-	} else {
-		for (last = uuidCache; last->next; last = last->next);
-		last->next = malloc(sizeof(*uuidCache));
-		last = last->next;
-	}
-	last->next = NULL;
-	last->device = device;
-	last->label = label;
-	memcpy(last->uuid, uuid, sizeof(last->uuid));
-}
-
-/* LVM support - Kirby Bohling */
-static void
-uuidcache_init_lvm(void) {
-	char buffer[PATH_MAX];
-	char lvm_device[PATH_MAX];
-	DIR *vg_dir, *lv_list;
-	struct dirent *vg_iter, *lv_iter;
-	char uuid[16], *label;
-
-	vg_dir = opendir(VG_DIR);
-	if (vg_dir == NULL)	/* to be expected */
-		return;
-
-	seekdir(vg_dir, 2);
-	while ((vg_iter = readdir(vg_dir)) != 0) {
-		sprintf(buffer, "%s/%s/LVs", VG_DIR, vg_iter->d_name);
-		lv_list = opendir(buffer);
-		if (lv_list == NULL) {
-			perror("uuidcache_init_lvm");
-			continue;
-		}
-		seekdir(lv_list, 2);
-		while ((lv_iter = readdir(lv_list)) != 0) {
-			/* Now we have the file.. could open it and read out
-			 * where the device is, read the first line, second
-			 * field... Instead we guess.
-			 */
-			sprintf(lvm_device, "%s/%s/%s", DEVLABELDIR,
-				vg_iter->d_name, lv_iter->d_name);
-			if (!get_label_uuid(lvm_device, &label, uuid))
-				uuidcache_addentry(xstrdup(lvm_device),
-						   label, uuid);
-		}
-		closedir(lv_list);
-	}
-	closedir(vg_dir);
-}
-
-static int
-uuidcache_init_evms(void) {
-	FILE *procvol;
-	char *label;
-	char uuid[16];
-	char volname[EVMS_VOLUME_NAME_SIZE+1];
-	char line[EVMS_VOLUME_NAME_SIZE+80];
-
-	procvol = fopen(PROC_EVMS_VOLUMES, "r");
-	if (!procvol)
-		return 0;
-
-	while (fgets(line, sizeof(line), procvol)) {
-		if (sscanf(line, "%*d %*d %*d %*s %*s %[^\n]", volname) == 1) {
-			if (!get_label_uuid(volname, &label, uuid))
-				uuidcache_addentry(xstrdup(volname), label, uuid);
-		}
-	}
-	
-	fclose(procvol);
-	
-	return 1;
-}
-
-/*
- * xvm is a proprietary sgi volume manager, it goes into /proc/partitions
- * like this:
- *
- *   4     0    2210817 xvm/local/vol/myvolume/data/block
- *   4     1    2210817 xvm/local/vol/myvolume/rt/block
- *   4     2    2210817 xvm/local/vol/myvolume/log/block
- *   4     3    2210818 xvm/local/vol/discs3/data/block
- *
- * The heuristics here are that the device should start with "xvm,"
- * but should not end in "log/block" or "rt/block" - those are
- * special devices for the xfs filesystem external log & realtime device.
- */
-
-/* Return 1 if this looks like an xvm device that should be scanned */
-static int
-is_xvm(char *ptname)
-{
-	int len;
-
-	/* if it doesn't start with "xvm," we're done. */
-	if (strncmp(ptname, "xvm", 3))
-		return 0;
-
-	len = strlen(ptname);
-	/*
-	 * check for "log/block" or "rt/block" on the end,
-	 * these are special - don't scan.
-	 */
-	if (!strncmp(ptname+(len-9), "log/block", 9) ||
-	    !strncmp(ptname+(len-8), "rt/block", 8))
-	    	return 0;
-
-	return 1;
-}
-
-static void
-uuidcache_init(void) {
-	char line[100];
-	char *s;
-	int ma, mi, sz;
-	static char ptname[100];
-	FILE *procpt;
-	char uuid[16], *label;
-	char device[110];
-	int firstPass;
-	int handleOnFirst;
-#if 0
-	char iobuf[32*1024];	/* For setvbuf */
-#endif
-
-	if (uuidCache)
-		return;
-
-	if (uuidcache_init_evms())
-		return;
-
-	procpt = fopen(PROC_PARTITIONS, "r");
-	if (!procpt) {
-		static int warn = 0;
-		if (!warn++)
-		    error (_("%s: could not open %s, so UUID and LABEL "
-			     "conversion cannot be done.\n"),
-			   progname, PROC_PARTITIONS);
-		return;
-	}
-#if 0
-/* Ugly kludge - the contents of /proc/partitions change in time,
-   and this causes failures when the file is not read in one go.
-   In particular, one cannot use stdio on /proc/partitions.
-   Doing this ourselves is not easy either, since stat returns 0
-   so the size is unknown. We might try increasing buffer sizes
-   until a single read gets all. For now only pick a largish buffer size. */
-/* All these troubles are mainly caused by people who patch the kernel
-   to keep statistics in /proc/partitions. Of course, statistics belong
-   in some /proc/diskstats, not in some /proc file that happened to
-   exist already. */
-
-	setvbuf(procpt, iobuf, _IOFBF, sizeof(iobuf));
-#endif
-
-	for (firstPass = 1; firstPass >= 0; firstPass--) {
-	    fseek(procpt, 0, SEEK_SET);
-
-	    while (fgets(line, sizeof(line), procpt)) {
-		if (!index(line, '\n'))
-			break;
-
-		if (sscanf (line, " %d %d %d %[^\n ]",
-			    &ma, &mi, &sz, ptname) != 4)
-			continue;
-
-		/* skip extended partitions (heuristic: size 1) */
-		if (sz == 1)
-			continue;
-
-		/* look only at md devices on first pass */
-		handleOnFirst = !strncmp(ptname, "md", 2);
-		if (firstPass != handleOnFirst)
-			continue;
-
-		/* skip entire disk (minor 0, 64, ... on ide;
-		   0, 16, ... on sd) */
-		/* heuristic: partition name ends in a digit */
-		/* devfs has .../disc and .../part1 etc. */
-
-		for (s = ptname; *s; s++);
-		if (isdigit(s[-1]) || is_xvm(ptname)) {
-			
-		/*
-		 * Note: this is a heuristic only - there is no reason
-		 * why these devices should live in /dev.
-		 * Perhaps this directory should be specifiable by option.
-		 * One might for example have /devlabel with links to /dev
-		 * for the devices that may be accessed in this way.
-		 * (This is useful, if the cdrom on /dev/hdc must not
-		 * be accessed.)
-		 */
-			sprintf(device, "%s/%s", DEVLABELDIR, ptname);
-			if (!get_label_uuid(device, &label, uuid))
-				uuidcache_addentry(xstrdup(device), label, uuid);
-		}
-	    }
-	}
-
-	fclose(procpt);
-
-	uuidcache_init_lvm();
-}
-
-#define UUID   1
-#define VOL    2
-
-static const char *
-get_spec_by_x(int n, const char *t) {
-	struct uuidCache_s *uc;
-
-	uuidcache_init();
-	uc = uuidCache;
-
-	while (uc) {
-		switch (n) {
-		case UUID:
-			if (!memcmp(t, uc->uuid, sizeof(uc->uuid)))
-				return xstrdup(uc->device);
-			break;
-		case VOL:
-			if (uc->label && !strcmp(t, uc->label))
-				return xstrdup(uc->device);
-			break;
-		}
-		uc = uc->next;
-	}
-	return NULL;
-}
-
-static u_char
-fromhex(char c) {
-	if (isdigit(c))
-		return (c - '0');
-	else if (islower(c))
-		return (c - 'a' + 10);
-	else
-		return (c - 'A' + 10);
-}
-
-const char *
-get_spec_by_uuid(const char *s) {
-	u_char uuid[16];
-	int i;
-
-	if (strlen(s) != 36 ||
-	    s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-')
-		goto bad_uuid;
-	for (i=0; i<16; i++) {
-	    if (*s == '-') s++;
-	    if (!isxdigit(s[0]) || !isxdigit(s[1]))
-		    goto bad_uuid;
-	    uuid[i] = ((fromhex(s[0])<<4) | fromhex(s[1]));
-	    s += 2;
-	}
-	return get_spec_by_x(UUID, uuid);
-
- bad_uuid:
-	die(EX_USAGE, _("%s: bad UUID"), progname);
-	return NULL;		/* just for gcc */
-}
-
-const char *
-get_spec_by_volume_label(const char *s) {
-	return get_spec_by_x(VOL, s);
-}
-
-const char *
-get_volume_label_by_spec(const char *spec) {
-        struct uuidCache_s *uc;
-
-        uuidcache_init();
-        uc = uuidCache;
-
-	while(uc) {
-		if (!strcmp(spec, uc->device))
-			return uc->label;
- 		uc = uc->next;
-	}
-	return NULL;
-}
-
-/*
- * second_occurrence_of_vol_label()
- * As labels are user defined they are not necessarily 
- * system-wide unique. Make sure that they are.
- */
-const char *
-second_occurrence_of_vol_label (const char *label) {
-  	struct uuidCache_s *last;
-        int occurrences = 0;
-
-        uuidcache_init();
-
-        for (last = uuidCache; last; last = last->next) {
-		if (last->label && !strcmp(last->label, label)) {
-			occurrences++;
-			if (occurrences == 2)
-				return last->device;
-		}
-        }
-        
-        return NULL;
-}
-
-          
-#endif
Index: util-linux-devel/mount/mount_guess_fstype.c
===================================================================
--- util-linux-devel.orig/mount/mount_guess_fstype.c
+++ util-linux-devel/mount/mount_guess_fstype.c
@@ -46,452 +46,37 @@
 #define ETC_FILESYSTEMS		"/etc/filesystems"
 #define PROC_FILESYSTEMS	"/proc/filesystems"
 
-#ifdef HAVE_LIBBLKID
-
-char *
-do_guess_fstype(const char *device) 
-{
-	return blkid_get_tag_value(blkid, "TYPE", device);
-}
+#ifdef HAVE_LIBVOLUME_ID
 
 static int
-known_fstype(const char *fstype) 
+known_fstype(const char *fstype)
 {
-	return blkid_known_fstype(fstype);
-}
-	
-#else
-#define SIZE(a) (sizeof(a)/sizeof(a[0]))
-
-/* Most file system types can be recognized by a `magic' number
-   in the superblock.  Note that the order of the tests is
-   significant: by coincidence a filesystem can have the
-   magic numbers for several file system types simultaneously.
-   For example, the romfs magic lives in the 1st sector;
-   xiafs does not touch the 1st sector and has its magic in
-   the 2nd sector; ext2 does not touch the first two sectors. */
-
-static inline unsigned short
-swapped(unsigned short a) {
-     return (a>>8) | (a<<8);
-}
-
-/*
-    char *guess_fstype(const char *device);
-
-    Probes the device and attempts to determine the type of filesystem
-    contained within.
-
-    Original routine by <jmorriso@xxxxxxxxxxxxxxxxxx>; made into a function
-    for mount(8) by Mike Grupenhoff <kashmir@xxxxxxxxxxxxxx>.
-    Corrected the test for xiafs - aeb
-    Read the superblock only once - aeb
-    Added a very weak heuristic for vfat - aeb
-    Added efs, iso9660, minix-v2, romfs, qnx4, udf, vxfs, swap - aeb
-    Added a test for high sierra (iso9660) - quinlan@xxxxxxxxxxxx
-    Added ufs from a patch by jj. But maybe there are several types of ufs?
-    Added ntfs from a patch by Richard Russon.
-    Added xfs - 2000-03-21 Martin K. Petersen <mkp@xxxxxxxxxxxxx>
-    Added cramfs, hfs, hpfs, adfs - Sepp Wijnands <mrrazz@xxxxxxxxxxxxxxxxxx>
-    Added ext3 - Andrew Morton
-    Added jfs - Christoph Hellwig
-    Added sysv - Tim Launchbury
-    Added udf - Bryce Nesbitt
-    Added ocfs, ocfs2 - Manish Singh - http://oss.oracle.com/projects/ocfs2/
-*/
-static char
-*magic_known[] = {
-	"adfs", "bfs", "cramfs", "efs", "ext", "ext2", "ext3",
-	"hfs", "hpfs", "iso9660", "jfs", "minix", "ntfs", "ocfs", "ocfs2",
-	"qnx4", "reiserfs", "romfs", "swap", "sysv", "udf", "ufs",
-	"vxfs", "xfs", "xiafs"
-};
-
-static int
-known_fstype(const char *fstype) {
-	char **m;
-
-	for (m = magic_known; m - magic_known < SIZE(magic_known); m++)
-		if (!strcmp(*m, fstype))
-			return 1;
 	return 0;
 }
 
-/*
- * udf magic - I find that trying to mount garbage as an udf fs
- * causes a very large kernel delay, almost killing the machine.
- * So, we do not try udf unless there is positive evidence that it
- * might work. Strings below taken from ECMA 167.
- */
-/*
- * It seems that before udf 2.00 the volume descriptor was not well
- * defined.  For 2.00 you're supposed to keep scanning records until
- * you find one NOT in this list.  (See ECMA 2/8.3.1).
- */
-static char
-*udf_magic[] = { "BEA01", "BOOT2", "CD001", "CDW02", "NSR02",
-		 "NSR03", "TEA01" };
-
-
-static int
-may_be_udf(const char *id) {
-    char **m;
-
-    for (m = udf_magic; m - udf_magic < SIZE(udf_magic); m++)
-       if (!strncmp(*m, id, 5))
-	  return 1;
-    return 0;
+const char *
+do_guess_fstype(const char *spec)
+{
+	return volume_id_get_tag(spec, "TYPE");
 }
 
-/* we saw "CD001" - may be iso9660 or udf - Bryce Nesbitt */
-static int
-is_really_udf(int fd) {
-	int j, bs;
-	struct iso_volume_descriptor isosb;
-
-	/* determine the block size by scanning in 2K increments
-	   (block sizes larger than 2K will be null padded) */
-	for (bs = 1; bs < 16; bs++) {
-		lseek(fd, bs*2048+32768, SEEK_SET);
-		if (read(fd, (char *)&isosb, sizeof(isosb)) != sizeof(isosb))
-			return 0;
-		if (isosb.id[0])
-			break;
-	}
-
-	/* Scan up to another 64 blocks looking for additional VSD's */
-	for (j = 1; j < 64; j++) {
-		if (j > 1) {
-			lseek(fd, j*bs*2048+32768, SEEK_SET);
-			if (read(fd, (char *)&isosb, sizeof(isosb))
-			    != sizeof(isosb))
-				return 0;
-		}
-		/* If we find NSR0x then call it udf:
-		   NSR01 for UDF 1.00
-		   NSR02 for UDF 1.50
-		   NSR03 for UDF 2.00 */
-		if (!strncmp(isosb.id, "NSR0", 4))
-			return 1;
-		if (!may_be_udf(isosb.id))
-			return 0;
-	}
-
-	return 0;
-}
+#else
+#ifdef HAVE_LIBBLKID
 
-static int
-may_be_swap(const char *s) {
-	return (strncmp(s-10, "SWAP-SPACE", 10) == 0 ||
-		strncmp(s-10, "SWAPSPACE2", 10) == 0);
+const char *
+do_guess_fstype(const char *device)
+{
+	return blkid_get_tag_value(blkid, "TYPE", device);
 }
 
-/* rather weak necessary condition */
-static int
-may_be_adfs(const u_char *s) {
-	u_char *p;
-	int sum;
-
-	p = (u_char *) s + 511;
-	sum = 0;
-	while (--p != s)
-		sum = (sum >> 8) + (sum & 0xff) + *p;
-
-	return (sum == p[511]);
-}
-
-char *
-do_guess_fstype(const char *device) {
-    int fd;
-    char *type = NULL;
-    union {
-	struct xiafs_super_block xiasb;
-	char romfs_magic[8];
-	char qnx4fs_magic[10];	/* ignore first 4 bytes */
-	long bfs_magic;
-	struct ntfs_super_block ntfssb;
-	struct fat_super_block fatsb;
-	struct xfs_super_block xfsb;
-	struct cramfs_super_block cramfssb;
-	struct ocfs_volume_header ovh;
-	struct efs_volume_header efsvh;
-	struct efs_super efssb;
-    } xsb;			/* stuff at 0 */
-    union {
-	struct minix_super_block ms;
-	struct ext_super_block es;
-	struct ext2_super_block e2s;
-	struct vxfs_super_block vs;
-    } sb;			/* stuff at 1024 */
-    struct ufs_super_block ufssb;
-    union {
-	struct iso_volume_descriptor iso;
-	struct hs_volume_descriptor hs;
-    } isosb;
-    struct reiserfs_super_block reiserfssb;	/* block 64 or 8 */
-    struct jfs_super_block jfssb;		/* block 32 */
-    struct hfs_super_block hfssb;
-    struct hpfs_super_block hpfssb;
-    struct adfs_super_block adfssb;
-    struct sysv_super_block svsb;
-    struct ocfs2_super_block osb;
-    struct stat statbuf;
-
-    /* opening and reading an arbitrary unknown path can have
-       undesired side effects - first check that `device' refers
-       to a block device or ordinary file */
-    if (stat (device, &statbuf) ||
-	!(S_ISBLK(statbuf.st_mode) || S_ISREG(statbuf.st_mode)))
-      return 0;
-
-    fd = open(device, O_RDONLY);
-    if (fd < 0)
-      return 0;
-
-    /* do seeks and reads in disk order, otherwise a very short
-       partition may cause a failure because of read error */
-
-    if (!type) {
-	 /* block 0 */
-	 if (lseek(fd, 0, SEEK_SET) != 0
-	     || read(fd, (char *) &xsb, sizeof(xsb)) != sizeof(xsb))
-	      goto try_iso9660;
-	 /* Gyorgy Kovesdi: none of my photocds has a readable block 0 */
-
-	 if (xiafsmagic(xsb.xiasb) == _XIAFS_SUPER_MAGIC)
-	      type = "xiafs";
-	 else if(!strncmp(xsb.romfs_magic, "-rom1fs-", 8))
-	      type = "romfs";
-	 else if(!strncmp(xsb.xfsb.s_magic, XFS_SUPER_MAGIC, 4))
-	      type = "xfs";
-	 else if(!strncmp(xsb.ovh.signature, OCFS_MAGIC, sizeof(OCFS_MAGIC)))
-	      type = "ocfs";
-	 else if(!strncmp(xsb.qnx4fs_magic+4, "QNX4FS", 6))
-	      type = "qnx4";
-	 else if(xsb.bfs_magic == 0x1badface)
-	      type = "bfs";
-	 else if(!strncmp(xsb.ntfssb.s_magic, NTFS_SUPER_MAGIC,
-			  sizeof(xsb.ntfssb.s_magic)))
-	      type = "ntfs";
-	 else if(cramfsmagic(xsb.cramfssb) == CRAMFS_SUPER_MAGIC ||
-		 cramfsmagic(xsb.cramfssb) == CRAMFS_SUPER_MAGIC_BE)
-	      type = "cramfs";
-	 else if (assemble4be(xsb.efsvh.vh_magic) == EFS_VHMAGIC)
-	      type = "efs";		/* EFS volume header */
-	 				/* might check checksum here */
-	 else if (assemble4be(xsb.efssb.fs_magic) == EFS_SBMAGIC ||
-		  assemble4be(xsb.efssb.fs_magic) == EFS_SBMAGIC2)
-		 type = "efs";		/* EFS partition */
-	 else if ((!strncmp(xsb.fatsb.s_os, "MSDOS", 5) ||
-		   !strncmp(xsb.fatsb.s_os, "MSWIN", 5) ||
-		   !strncmp(xsb.fatsb.s_os, "MTOOL", 5) ||
-		   !strncmp(xsb.fatsb.s_os, "IBM", 3) ||
-		   !strncmp(xsb.fatsb.s_os, "DRDOS", 5) ||
-		   !strncmp(xsb.fatsb.s_os, "mkdosfs", 7) ||
-		   !strncmp(xsb.fatsb.s_os, "kmkdosfs", 8) ||
-		   /* Michal Svec: created by fdformat, old msdos utility for
-		      formatting large (1.7) floppy disks. */
-		   !strncmp(xsb.fatsb.s_os, "CH-FOR18", 8))
-		  && (!strncmp(xsb.fatsb.s_fs, "FAT12   ", 8) ||
-		      !strncmp(xsb.fatsb.s_fs, "FAT16   ", 8) ||
-		      !strncmp(xsb.fatsb.s_fs2, "FAT32   ", 8)))
-	      type = "vfat";	/* only guessing - might as well be fat or umsdos */
-    }
-
-    if (!type) {
-	    /* sector 1 */
-	    if (lseek(fd, 512 , SEEK_SET) != 512
-		|| read(fd, (char *) &svsb, sizeof(svsb)) != sizeof(svsb))
-		    goto io_error;
-	    if (sysvmagic(svsb) == SYSV_SUPER_MAGIC )
-		    type = "sysv";
-    }
-
-    if (!type) {
-	/* block 1 */
-	if (lseek(fd, 1024, SEEK_SET) != 1024 ||
-	    read(fd, (char *) &sb, sizeof(sb)) != sizeof(sb))
-		goto io_error;
-
-	/* ext2 has magic in little-endian on disk, so "swapped" is
-	   superfluous; however, there have existed strange byteswapped
-	   PPC ext2 systems */
-	if (ext2magic(sb.e2s) == EXT2_SUPER_MAGIC ||
-	    ext2magic(sb.e2s) == EXT2_PRE_02B_MAGIC ||
-	    ext2magic(sb.e2s) == swapped(EXT2_SUPER_MAGIC)) {
-		type = "ext2";
-
-	     /* maybe even ext3? */
-	     if ((assemble4le(sb.e2s.s_feature_compat)
-		  & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
-		 assemble4le(sb.e2s.s_journal_inum) != 0)
-		     type = "ext3";	/* "ext3,ext2" */
-	}
-
-	else if (minixmagic(sb.ms) == MINIX_SUPER_MAGIC ||
-		 minixmagic(sb.ms) == MINIX_SUPER_MAGIC2 ||
-		 minixmagic(sb.ms) == swapped(MINIX_SUPER_MAGIC2) ||
-		 minixmagic(sb.ms) == MINIX2_SUPER_MAGIC ||
-		 minixmagic(sb.ms) == MINIX2_SUPER_MAGIC2)
-		type = "minix";
-
-	else if (extmagic(sb.es) == EXT_SUPER_MAGIC)
-		type = "ext";
-
-	else if (vxfsmagic(sb.vs) == VXFS_SUPER_MAGIC)
-		type = "vxfs";
-    }
-
-    if (!type) {
-	/* block 1 */
-        if (lseek(fd, 0x400, SEEK_SET) != 0x400
-            || read(fd, (char *) &hfssb, sizeof(hfssb)) != sizeof(hfssb))
-             goto io_error;
-
-        /* also check if block size is equal to 512 bytes,
-	   or a multiple. (I see 1536 here.) */
-        if (hfsmagic(hfssb) == HFS_SUPER_MAGIC &&	/* always BE */
-	    hfsblksize(hfssb) != 0 &&
-	    (hfsblksize(hfssb) & 0x1ff) == 0)
-             type = "hfs";
-    }
-
-    if (!type) {
-	/* block 3 */
-        if (lseek(fd, 0xc00, SEEK_SET) != 0xc00
-            || read(fd, (char *) &adfssb, sizeof(adfssb)) != sizeof(adfssb))
-             goto io_error;
-
-	/* only a weak test */
-        if (may_be_adfs((u_char *) &adfssb)
-            && (adfsblksize(adfssb) >= 8 &&
-                adfsblksize(adfssb) <= 10))
-             type = "adfs";
-    }
-
-    if (!type) {
-	 int mag;
-
-	 /* block 8 */
-	 if (lseek(fd, 8192, SEEK_SET) != 8192
-	     || read(fd, (char *) &ufssb, sizeof(ufssb)) != sizeof(ufssb))
-	      goto io_error;
-
-	 mag = ufsmagic(ufssb);
-	 if (mag == UFS_SUPER_MAGIC_LE || mag == UFS_SUPER_MAGIC_BE)
-	      type = "ufs";
-    }
-
-    if (!type) {
-	/* block 8 */
-	if (lseek(fd, REISERFS_OLD_DISK_OFFSET_IN_BYTES, SEEK_SET) !=
-				REISERFS_OLD_DISK_OFFSET_IN_BYTES
-	    || read(fd, (char *) &reiserfssb, sizeof(reiserfssb)) !=
-		sizeof(reiserfssb))
-	    goto io_error;
-	if (reiserfs_magic_version(reiserfssb.s_magic))
-	    type = "reiserfs";
-    }
-
-    if (!type) {
-	/* block 8 */
-        if (lseek(fd, 0x2000, SEEK_SET) != 0x2000
-            || read(fd, (char *) &hpfssb, sizeof(hpfssb)) != sizeof(hpfssb))
-             goto io_error;
-
-        if (hpfsmagic(hpfssb) == HPFS_SUPER_MAGIC)
-             type = "hpfs";
-    }
-
-    if (!type) {
-	 /* block 32 */
-	 if (lseek(fd, JFS_SUPER1_OFF, SEEK_SET) != JFS_SUPER1_OFF
-	     || read(fd, (char *) &jfssb, sizeof(jfssb)) != sizeof(jfssb))
-	      goto io_error;
-	 if (!strncmp(jfssb.s_magic, JFS_MAGIC, 4))
-	      type = "jfs";
-    }
-
-    if (!type) {
-	 /* block 32 */
-    try_iso9660:
-	 if (lseek(fd, 0x8000, SEEK_SET) != 0x8000
-	     || read(fd, (char *) &isosb, sizeof(isosb)) != sizeof(isosb))
-	      goto io_error;
-
-	 if (strncmp(isosb.hs.id, HS_STANDARD_ID, sizeof(isosb.hs.id)) == 0) {
-		 /* "CDROM" */
-		 type = "iso9660";
-	 } else if (strncmp(isosb.iso.id, ISO_STANDARD_ID,
-			  sizeof(isosb.iso.id)) == 0) {
-		 /* CD001 */
-		 type = "iso9660";
-		 if (is_really_udf(fd))
-			 type = "udf";
-	 } else if (may_be_udf(isosb.iso.id))
-		 type = "udf";
-    }
-
-    if (!type) {
-	/* block 64 */
-	if (lseek(fd, REISERFS_DISK_OFFSET_IN_BYTES, SEEK_SET) !=
-		REISERFS_DISK_OFFSET_IN_BYTES
-	    || read(fd, (char *) &reiserfssb, sizeof(reiserfssb)) !=
-		sizeof(reiserfssb))
-	    goto io_error;
-	if (reiserfs_magic_version(reiserfssb.s_magic))
-	    type = "reiserfs";
-    }
-
-    if (!type) {
-	    int blksize, blkoff;
-
-	    for (blksize = OCFS2_MIN_BLOCKSIZE;
-		 blksize <= OCFS2_MAX_BLOCKSIZE;
-		 blksize <<= 1) {
-		    blkoff = blksize * OCFS2_SUPER_BLOCK_BLKNO;
-		    if (lseek(fd, blkoff, SEEK_SET) != blkoff
-			|| read(fd, (char *) &osb, sizeof(osb)) != sizeof(osb))
-			    goto io_error;
-		    if (strncmp(osb.signature, OCFS2_SUPER_BLOCK_SIGNATURE,
-				sizeof(OCFS2_SUPER_BLOCK_SIGNATURE)) == 0)
-			    type = "ocfs2";
-	    }
-    }
-
-    if (!type) {
-	    /* perhaps the user tries to mount the swap space
-	       on a new disk; warn her before she does mke2fs on it */
-	    int pagesize = getpagesize();
-	    int rd;
-	    char buf[32768];
-
-	    rd = pagesize;
-	    if (rd < 8192)
-		    rd = 8192;
-	    if (rd > sizeof(buf))
-		    rd = sizeof(buf);
-	    if (lseek(fd, 0, SEEK_SET) != 0
-		|| read(fd, buf, rd) != rd)
-		    goto io_error;
-	    if (may_be_swap(buf+pagesize) ||
-		may_be_swap(buf+4096) || may_be_swap(buf+8192))
-		    type = "swap";
-    }
-
-    close (fd);
-    return(type);
-
-io_error:
-    if (errno)
-	 perror(device);
-    else
-	 fprintf(stderr, _("mount: error while guessing filesystem type\n"));
-    close(fd);
-    return 0;
+const static int
+known_fstype(const char *fstype)
+{
+	return blkid_known_fstype(fstype);
 }
 
 #endif
+#endif
 
 static struct tried {
 	struct tried *next;
@@ -534,9 +119,9 @@ free_tested(void) {
 	tried = NULL;
 }
 
-char *
+const char *
 guess_fstype(const char *spec) {
-	char *type = do_guess_fstype(spec);
+	const char *type = do_guess_fstype(spec);
 	if (verbose) {
 	    printf (_("mount: you didn't specify a filesystem type for %s\n"),
 		    spec);
Index: util-linux-devel/mount/mount_udev.c
===================================================================
--- /dev/null
+++ util-linux-devel/mount/mount_udev.c
@@ -0,0 +1,236 @@
+//#ifdef HAVE_LIBVOLUME_ID
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/mount.h>
+#include <sys/ioctl.h>
+#include <nls.h>
+#include <stddef.h>
+#include <libvolume_id.h>
+
+#include "mount_blkid.h"
+
+extern int verbose;
+
+struct volume_id_types_t {
+	int id;
+	char *token;
+	char *env;
+};
+
+enum {
+	VOLUME_ID_NONE=0,
+	VOLUME_ID_TYPE,
+	VOLUME_ID_LABEL,
+	VOLUME_ID_UUID
+};
+
+#define volume_id_offset(member) (unsigned long)offsetof(struct volume_id,member)
+
+struct volume_id_types_t volume_id_types[] = {
+	{ VOLUME_ID_TYPE, "TYPE", "ID_FS_TYPE" },
+	{ VOLUME_ID_LABEL, "LABEL", "ID_FS_LABEL" },
+	{ VOLUME_ID_UUID, "UUID",  "ID_FS_UUID" },
+	{ VOLUME_ID_NONE, NULL, NULL },
+};
+
+const char *
+volume_id_get_tag(const char *spec, const char *token)
+{
+	struct volume_id *vid;
+	uint64_t size;
+	struct volume_id_types_t *volume_id_ptr = volume_id_types;
+	char *var, *value;
+
+	value = calloc(1, VOLUME_ID_LABEL_SIZE);
+	if (!value)
+		return NULL;
+
+	if (!spec)
+		return NULL;
+
+	while (volume_id_ptr->token && strcmp(volume_id_ptr->token,token))
+		volume_id_ptr++;
+
+	if (!volume_id_ptr->token) {
+		free(value);
+		value = NULL;
+		goto out;
+	}
+
+	/* Quick exit if ID_FS_* variables are set */
+	if ((var = getenv(volume_id_ptr->env))) {
+		strncpy(value,var,VOLUME_ID_LABEL_SIZE - 1);
+		goto out;
+	}
+
+	vid = volume_id_open_node(spec);
+	if (!vid) {
+		free(value);
+		value = NULL;
+		goto out;
+	}
+
+	if (ioctl(vid->fd, BLKGETSIZE64, &size) != 0)
+		size = 0;
+
+	if (volume_id_probe_all(vid, 0, size) == 0) {
+		switch(volume_id_ptr->id) {
+		case VOLUME_ID_TYPE:
+			strcpy(value, vid->type);
+			break;
+		case VOLUME_ID_LABEL:
+			strcpy(value, vid->label);
+			break;
+		case VOLUME_ID_UUID:
+			strcpy(value, vid->uuid);
+			break;
+		default:
+			free(value);
+			value = NULL;
+			break;
+		}
+	} else
+		value = NULL;
+
+	volume_id_close(vid);
+
+ out:
+	return value;
+}
+
+void
+mount_blkid_get_cache(void) {}
+
+void
+mount_blkid_put_cache(void) {}
+
+const char *
+mount_get_volume_uuid_by_spec(const char *spec)
+{
+	return volume_id_get_tag(spec, "UUID");
+}
+
+const char *
+mount_get_volume_label_by_spec(const char *spec)
+{
+	return volume_id_get_tag(spec, "LABEL");
+}
+
+const char *
+mount_get_devname_by_uuid(const char *uuid) {
+	char *dev = NULL;
+
+	if (!uuid)
+		return NULL;
+
+	dev = malloc(19 + strlen(uuid));
+	if (dev) {
+		strcpy(dev,"/dev/disk/by-uuid/");
+		strcat(dev,uuid);
+	}
+
+	return dev;
+}
+
+const char *
+mount_get_devname_by_label(const char *label) {
+	char *dev = NULL;
+
+	if (!label)
+		return NULL;
+
+	dev = malloc(20 + strlen(label));
+	if (dev) {
+		strcpy(dev,"/dev/disk/by-label/");
+		strcat(dev,label);
+	}
+
+	return dev;
+}
+
+const char *
+mount_get_devname(const char *spec)
+{
+	char *token, *cp, *value;
+	const char *nspec = NULL;
+
+	if (!spec)
+		return NULL;
+
+	token = strdup(spec);
+	if (!token)
+		return NULL;
+
+	/* We have to return an allocated string */
+	if (!(cp = strchr(token, '=')))
+		return token;
+
+	value = token + (cp - token);
+	*value++ = '\0';
+
+	if (*value == '"' || *value == '\'') {
+		char c = *value++;
+		if (!(cp = strrchr(value, c)))
+			goto errout; /* missing closing quote */
+		*cp = '\0';
+	}
+
+	if (!strcmp(token,"LABEL")) {
+		nspec = mount_get_devname_by_label(value);
+	} else if (!strcmp(token,"UUID")) {
+		nspec = mount_get_devname_by_uuid(value);
+	}
+
+	free(token);
+
+ errout:
+	return nspec;
+}
+
+/* Also when no UUID= or LABEL= occur? No verbose? No warnings? */
+const char *
+mount_get_devname_for_mounting(const char *spec)
+{
+	char *token, *cp, *value;
+	const char *nspec = NULL;
+
+	if (!spec)
+		return NULL;
+
+	token = strdup(spec);
+	if (!token)
+		return NULL;
+
+	/* We have to return an allocated string */
+	if (!(cp = strchr(token, '=')))
+		return token;
+
+	value = token + (cp - token);
+	*value++ = '\0';
+
+	if (*value == '"' || *value == '\'') {
+		char c = *value++;
+		if (!(cp = strrchr(value, c)))
+			goto errout; /* missing closing quote */
+		*cp = '\0';
+	}
+
+	if (!strcmp(token,"LABEL")) {
+		nspec = mount_get_devname_by_label(value);
+		if (nspec && verbose > 1)
+			printf(_("mount: going to mount %s by LABEL\n"), spec);
+	} else if (!strcmp(token,"UUID")) {
+		nspec = mount_get_devname_by_uuid(value);
+		if (nspec && verbose > 1)
+			printf(_("mount: going to mount %s by UUID\n"), spec);
+	}
+
+	free(token);
+
+ errout:
+	return nspec;
+}
+
+//#endif
Index: util-linux-devel/mount/mount_guess_fstype.h
===================================================================
--- util-linux-devel.orig/mount/mount_guess_fstype.h
+++ util-linux-devel/mount/mount_guess_fstype.h
@@ -8,8 +8,8 @@ struct mountargs {
 
 extern int verbose;
 
-char *guess_fstype(const char *device);
-char *do_guess_fstype(const char *device);
+const char *guess_fstype(const char *device);
+const char *do_guess_fstype(const char *device);
 int procfsloop(int (*mount_fn)(struct mountargs *), struct mountargs *args,
 	       const char **type);
 int is_in_procfs(const char *fstype);
Index: util-linux-devel/configure.ac
===================================================================
--- util-linux-devel.orig/configure.ac
+++ util-linux-devel/configure.ac
@@ -56,10 +56,33 @@ AM_CONDITIONAL(HAVE_LIBUTIL, test x$ac_c
 AC_CHECK_LIB(termcap, tgetnum)
 AM_CONDITIONAL(HAVE_TERMCAP, test x$ac_cv_lib_termcap_tgetnum = xyes)
 
-AC_CHECK_LIB(blkid, blkid_known_fstype)
-AM_CONDITIONAL(HAVE_BLKID, test x$ac_cv_lib_blkid_blkid_known_fstype = xyes)
+AC_ARG_WITH(libvolume_id,
+	AS_HELP_STRING([--with-libvolume_id], [Use libvolume_id instead of blkid for filesystem detection]),
+	[with_volumeid=$withval],
+	[with_volumeid=no])
 
 
+if test "x$with_volumeid" != xno; then
+	AC_CHECK_LIB(volume_id, volume_id_open_node,
+		     have_volumeid=yes,
+	             [AC_MSG_FAILURE([--with-libvolume_id was given, but test for libvolume_id failed])])
+else
+	AC_CHECK_LIB(blkid, blkid_known_fstype,
+		     have_blkid=yes,
+		     AC_MSG_FAILURE([blkid is missing]))
+fi
+
+if test "x$have_volumeid" = xyes; then
+	AC_DEFINE([HAVE_LIBVOLUME_ID], [1],
+		  [Define if you have libvolume_id])
+else
+	AC_DEFINE([HAVE_LIBBLKID], [1],
+		  [Define if you have libblkid])
+fi
+
+AM_CONDITIONAL(HAVE_BLKID, test "x$have_blkid" = xyes)
+AM_CONDITIONAL(HAVE_VOLUME_ID, test "x$have_volumeid" = xyes)
+
 AM_GNU_GETTEXT_VERSION([0.14.1])
 AM_GNU_GETTEXT([external])
 if test -d po
Index: util-linux-devel/mount/Makefile.am
===================================================================
--- util-linux-devel.orig/mount/Makefile.am
+++ util-linux-devel/mount/Makefile.am
@@ -11,11 +11,11 @@ man_MANS = fstab.5 nfs.5 mount.8 swapoff
 MNTHDRS = fstab.h linux_fs.h mount_mntent.h mount_constants.h my_dev_t.h \
 	mount_paths.h get_label_uuid.h lomount.h mount_blkid.h \
 	mount_guess_fstype.h nfs_mount4.h realpath.h xmalloc.h \
-	getusername.h loop.h mount_by_label.h mount_guess_rootdev.h \
+	getusername.h loop.h mount_guess_rootdev.h \
 	nfsmount.h sundries.h
 
 mount_SOURCES = mount.c fstab.c sundries.c xmalloc.c realpath.c mount_mntent.c \
-	get_label_uuid.c mount_by_label.c mount_blkid.c mount_guess_fstype.c \
+	mount_guess_fstype.c \
 	getusername.c \
 	nfsmount.c nfsmount_xdr.c nfsmount_clnt.c \
 	lomount.c \
@@ -25,24 +25,34 @@ mount_LDADD = $(top_srcdir)/lib/libenv.a
 mount_CFLAGS = $(SUID_CFLAGS)
 
 umount_SOURCES = umount.c fstab.c sundries.c xmalloc.c realpath.c mount_mntent.c \
-	getusername.c get_label_uuid.c mount_by_label.c mount_blkid.c \
-	lomount.c \
+	getusername.c lomount.c \
 	$(MNTHDRS)
 	
 umount_LDADD = $(top_srcdir)/lib/libenv.a
 umount_CFLAGS = $(SUID_CFLAGS)
 
 swapon_SOURCES = swapon.c xmalloc.c \
-	get_label_uuid.c mount_by_label.c mount_blkid.c \
 	swap_constants.h realpath.c
 
 losetup_SOURCES = lomount.c loop.h lomount.h
 losetup_CFLAGS = -DMAIN
 
 if HAVE_BLKID
+mount_SOURCES += mount_blkid.c
+umount_SOURCES += mount_blkid.c
+swapon_SOURCES += mount_blkid.c
 mount_LDADD += -lblkid -luuid
 umount_LDADD += -lblkid -luuid
 swapon_LDADD = -lblkid -luuid
+else
+if HAVE_VOLUME_ID
+mount_SOURCES += mount_udev.c
+umount_SOURCES += mount_udev.c
+swapon_SOURCES += mount_udev.c
+mount_LDADD += -lvolume_id
+umount_LDADD += -lvolume_id
+swapon_LDADD = -lvolume_id
+endif
 endif
 
 if HAVE_PIVOT_ROOT
Index: util-linux-devel/mount/mount_by_label.h
===================================================================
--- util-linux-devel.orig/mount/mount_by_label.h
+++ /dev/null
@@ -1,4 +0,0 @@
-const char *get_spec_by_uuid(const char *uuid);
-const char *get_spec_by_volume_label(const char *volumelabel);
-const char *get_volume_label_by_spec(const char *spec);
-const char *second_occurrence_of_vol_label(const char *label);
Index: util-linux-devel/mount/swapon.c
===================================================================
--- util-linux-devel.orig/mount/swapon.c
+++ util-linux-devel/mount/swapon.c
@@ -16,7 +16,7 @@
 #include "swapargs.h"
 #include "nls.h"
 #include "mount_blkid.h"
-#include "mount_by_label.h"
+//#include "mount_by_label.h"
 #include "realpath.h"
 
 #define streq(s, t)	(strcmp ((s), (t)) == 0)
Index: util-linux-devel/mount/get_label_uuid.c
===================================================================
--- util-linux-devel.orig/mount/get_label_uuid.c
+++ /dev/null
@@ -1,221 +0,0 @@
-#ifndef HAVE_LIBBLKID
-/*
- * Get label. Used by mount, umount and swapon.
- */
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "xmalloc.h"
-#include "linux_fs.h"
-#include "get_label_uuid.h"
-#include "../disk-utils/swapheader.h"
-
-/*
- * See whether this device has (the magic of) a RAID superblock at the end.
- * If so, it probably is, or has been, part of a RAID array.
- *
- * For the moment this test is switched off - it causes problems.
- * "Checking for a disk label should only be done on the full raid,
- *  not on the disks that form the raid array. This test causes a lot of
- *  problems when run on my striped promise fasttrak 100 array."
- */
-static inline int
-is_raid_partition(int fd) {
-#if 0
-	struct mdp_super_block mdsb;
-	int n;
-
-	/* hardcode 4096 here in various places, because that's
-	   what it's defined to be.  Note that even if we used
-	   the actual kernel headers, sizeof(mdp_super_t) is
-	   slightly larger in the 2.2 kernel on 64-bit archs,
-	   so using that wouldn't work. */
-	lseek(fd, -4096, SEEK_END);	/* Ignore possible error
-					   about return value overflow */
-	n = 4096;
-	if (sizeof(mdsb) < n)
-		n = sizeof(mdsb);
-	if (read(fd, &mdsb, n) != n)
-		return 1;		/* error */
-	return (mdsbmagic(mdsb) == MD_SB_MAGIC);
-#else
-	return 0;
-#endif
-}
-
-int
-reiserfs_magic_version(const char *magic) {
-	int rc = 0;
-
-	if (!strncmp(magic, REISERFS_SUPER_MAGIC_STRING,
-		     strlen(REISERFS_SUPER_MAGIC_STRING)))
-		rc = 1;
-	if (!strncmp(magic, REISER2FS_SUPER_MAGIC_STRING, 
-		     strlen(REISER2FS_SUPER_MAGIC_STRING)))
-		rc = 2;
-	if (!strncmp(magic, REISER3FS_SUPER_MAGIC_STRING, 
-		     strlen(REISER3FS_SUPER_MAGIC_STRING)))
-		rc = 3;
-	return rc;
-}
-
-static void
-store_uuid(char *udest, char *usrc) {
-	if (usrc)
-		memcpy(udest, usrc, 16);
-	else
-		memset(udest, 0, 16);
-}
-
-static void
-store_label(char **ldest, char *lsrc, int len) {
-	*ldest = xmalloc(len+1);
-	memset(*ldest, 0, len+1);
-	memcpy(*ldest, lsrc, len);
-}
-
-static int
-is_v1_swap_partition(int fd, char **label, char *uuid) {
-	int n = getpagesize();
-	char *buf = xmalloc(n);
-	struct swap_header_v1_2 *p = (struct swap_header_v1_2 *) buf;
-
-	if (lseek(fd, 0, SEEK_SET) == 0
-	    && read(fd, buf, n) == n
-	    && !strncmp(buf+n-10, "SWAPSPACE2", 10)
-	    && p->version == 1) {
-		store_uuid(uuid, p->uuid);
-		store_label(label, p->volume_name, 16);
-		return 1;
-	}
-	return 0;
-}
-	    
-
-/*
- * Get both label and uuid.
- * For now, only ext2, ext3, xfs, ocfs, ocfs2, reiserfs, swap are supported
- *
- * Return 0 on success.
- */
-int
-get_label_uuid(const char *device, char **label, char *uuid) {
-	int fd;
-	struct ext2_super_block e2sb;
-	struct xfs_super_block xfsb;
-	struct jfs_super_block jfssb;
-	struct ocfs_volume_header ovh;	/* Oracle */
-	struct ocfs_volume_label olbl;
-	struct ocfs2_super_block osb;
-	struct reiserfs_super_block reiserfssb;
-	int blksize;
-	int rv = 0;
-
-	fd = open(device, O_RDONLY);
-	if (fd < 0)
-		return -1;
-
-	/* If there is a RAID partition, or an error, ignore this partition */
-	if (is_raid_partition(fd)) {
-		rv = 1;
-		goto done;
-	}
-
-	if (is_v1_swap_partition(fd, label, uuid))
-		goto done;
-
-	if (lseek(fd, 1024, SEEK_SET) == 1024
-	    && read(fd, (char *) &e2sb, sizeof(e2sb)) == sizeof(e2sb)
-	    && (ext2magic(e2sb) == EXT2_SUPER_MAGIC)) {
-		store_uuid(uuid, e2sb.s_uuid);
-		store_label(label, e2sb.s_volume_name,
-			    sizeof(e2sb.s_volume_name));
-		goto done;
-	}
-
-	if (lseek(fd, 0, SEEK_SET) == 0
-	    && read(fd, (char *) &xfsb, sizeof(xfsb)) == sizeof(xfsb)
-	    && (strncmp(xfsb.s_magic, XFS_SUPER_MAGIC, 4) == 0)) {
-		store_uuid(uuid, xfsb.s_uuid);
-		store_label(label, xfsb.s_fname, sizeof(xfsb.s_fname));
-		goto done;
-	}
-
-	if (lseek(fd, 0, SEEK_SET) == 0
-	    && read(fd, (char *) &ovh, sizeof(ovh)) == sizeof(ovh)
-	    && (strncmp(ovh.signature, OCFS_MAGIC, sizeof(OCFS_MAGIC)) == 0)
-	    && (lseek(fd, 512, SEEK_SET) == 512)
-	    && read(fd, (char *) &olbl, sizeof(olbl)) == sizeof(olbl)) {
-		store_uuid(uuid, NULL);
-		store_label(label, olbl.label, ocfslabellen(olbl));
-		goto done;
-	}
-
-	if (lseek(fd, JFS_SUPER1_OFF, SEEK_SET) == JFS_SUPER1_OFF
-	    && read(fd, (char *) &jfssb, sizeof(jfssb)) == sizeof(jfssb)
-	    && (strncmp(jfssb.s_magic, JFS_MAGIC, 4) == 0)) {
-
-/* The situation for jfs is rather messy. The structure of the
-   superblock changed a few times, but there seems to be no good way
-   to check what kind of sb we have.
-   Old (OS/2 compatible) jfs filesystems don't have UUIDs and have
-   an 11-byte label in s_fpack[].
-   Kernel 2.5.6 supports jfs v1; 2.5.8 supports v2; 2.5.18 has label/uuid.
-   Kernel 2.4.20 supports jfs v2 with label/uuid.
-   s_version will be 2 for new filesystems using an external log.
-   Other new filesystems will have version 1.
-   Label and UUID can be set by jfs_tune. */
-
-/* Let us believe label/uuid on v2, and on v1 only when label agrees
-   with s_fpack in the first 11 bytes. */
-
-		if (assemble4le(jfssb.s_version) == 1 &&
-		    strncmp(jfssb.s_label, jfssb.s_fpack, 11) != 0) {
-			store_uuid(uuid, NULL);
-			store_label(label, jfssb.s_fpack,
-				    sizeof(jfssb.s_fpack));
-		} else {
-			store_uuid(uuid, jfssb.s_uuid);
-			store_label(label, jfssb.s_label,
-				    sizeof(jfssb.s_label));
-		}
-		goto done;
-	}
-
-	if (lseek(fd, REISERFS_DISK_OFFSET_IN_BYTES, SEEK_SET)
-	    == REISERFS_DISK_OFFSET_IN_BYTES
-	    && read(fd, (char *) &reiserfssb, sizeof(reiserfssb))
-	    == sizeof(reiserfssb)
-	    /* Only 3.6.x format supers have labels or uuids.
-	       Label and UUID can be set by reiserfstune -l/-u. */
-	    && reiserfs_magic_version(reiserfssb.s_magic) > 1) {
-		store_uuid(uuid, reiserfssb.s_uuid);
-		store_label(label, reiserfssb.s_label,
-			    sizeof(reiserfssb.s_label));
-		goto done;
-	}
-
-	for (blksize = OCFS2_MIN_BLOCKSIZE;
-	     blksize <= OCFS2_MAX_BLOCKSIZE;
-	     blksize <<= 1) {
-		int blkoff = blksize * OCFS2_SUPER_BLOCK_BLKNO;
-
-		if (lseek(fd, blkoff, SEEK_SET) == blkoff
-		    && read(fd, (char *) &osb, sizeof(osb)) == sizeof(osb)
-		    && strncmp(osb.signature,
-			       OCFS2_SUPER_BLOCK_SIGNATURE,
-			       sizeof(OCFS2_SUPER_BLOCK_SIGNATURE)) == 0) {
-			store_uuid(uuid, osb.s_uuid);
-			store_label(label, osb.s_label, sizeof(osb.s_label));
-			goto done;
-		}
-	}
-	rv = 1;
- done:
-	close(fd);
-	return rv;
-}
-#endif
Index: util-linux-devel/mount/get_label_uuid.h
===================================================================
--- util-linux-devel.orig/mount/get_label_uuid.h
+++ /dev/null
@@ -1 +0,0 @@
-int get_label_uuid(const char *device, char **label, char *uuid);

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux