diff options
author | Karel Zak <kzak@redhat.com> | 2010-03-15 13:46:43 +0100 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2010-03-15 13:46:43 +0100 |
commit | c6c98f93f5e4b3fb9a8b51ed2ef9967793df7b1c (patch) | |
tree | 2e7a565f33234947bf90343851f252142c61f4fa /lib | |
parent | f5b1bab190e86bd6a52942047d2c767ec82508d1 (diff) | |
download | util-linux-old-c6c98f93f5e4b3fb9a8b51ed2ef9967793df7b1c.tar.gz |
mount: report ambivalent FS detection, improve brute force detection
The ambivalent probing result should be properly reported and user
should be informed that the problem is possible to bypass by "-t
<type>" or resolved by wipefs(8).
The mount(8) command uses a brute force stage (calls mount(2) for all
/{proc,etc}/fylesystems) if there is not any other way how to detect
the filesystem type. The brute force stage should not be restricted by
libblkid. It's possible that libblkid is not able to detect slightly
corrupted filesystem, but kernel is able to mount such filesystem.
Note that the brute force stage should not be used if libblkid returns
ambivalent probing result. In this case user's intervention is required
(e.g. mount -t <type>).
Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fsprobe.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/lib/fsprobe.c b/lib/fsprobe.c index 77211806..8eb08fac 100644 --- a/lib/fsprobe.c +++ b/lib/fsprobe.c @@ -117,9 +117,9 @@ fsprobe_exit(void) * probing interface */ static char * -fsprobe_get_value(const char *name, const char *devname) +fsprobe_get_value(const char *name, const char *devname, int *ambi) { - int fd; + int fd, rc; const char *data = NULL; if (!devname || !name) @@ -139,10 +139,11 @@ fsprobe_get_value(const char *name, const char *devname) blkid_probe_set_superblocks_flags(blprobe, BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | BLKID_SUBLKS_TYPE); - if (blkid_do_safeprobe(blprobe)) - goto done; - if (blkid_probe_lookup_value(blprobe, name, &data, NULL)) - goto done; + rc = blkid_do_safeprobe(blprobe); + if (ambi) + *ambi = rc == -2 ? 1 : 0; /* ambivalent probing result */ + if (!rc) + blkid_probe_lookup_value(blprobe, name, &data, NULL); done: close(fd); return data ? strdup((char *) data) : NULL; @@ -151,19 +152,25 @@ done: char * fsprobe_get_label_by_devname(const char *devname) { - return fsprobe_get_value("LABEL", devname); + return fsprobe_get_value("LABEL", devname, NULL); } char * fsprobe_get_uuid_by_devname(const char *devname) { - return fsprobe_get_value("UUID", devname); + return fsprobe_get_value("UUID", devname, NULL); } char * fsprobe_get_fstype_by_devname(const char *devname) { - return fsprobe_get_value("TYPE", devname); + return fsprobe_get_value("TYPE", devname, NULL); +} + +char * +fsprobe_get_fstype_by_devname_ambi(const char *devname, int *ambi) +{ + return fsprobe_get_value("TYPE", devname, ambi); } char * @@ -232,6 +239,14 @@ fsprobe_get_fstype_by_devname(const char *devname) } char * +fsprobe_get_fstype_by_devname_ambi(const char *devname, int *ambi) +{ + if (ambi) + *ambi = 0; + return fsprobe_get_fstype_by_devname(devname); +} + +char * fsprobe_get_label_by_devname(const char *devname) { if (!blcache) |