From aa86ddaa8041b15458707773b703b53552934e81 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Mon, 25 Jul 2011 16:22:25 +0200 Subject: [PATCH] Always read /proc/mounts when looking for mounted media (bnc#705893) --- zypp/media/MediaManager.cc | 4 +--- zypp/media/Mount.cc | 11 ++++++++++- zypp/media/Mount.h | 5 +++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/zypp/media/MediaManager.cc b/zypp/media/MediaManager.cc index 2097f96..0144ca1 100644 --- a/zypp/media/MediaManager.cc +++ b/zypp/media/MediaManager.cc @@ -231,9 +231,7 @@ namespace zypp static inline MountEntries getMountEntries() { - // use "/etc/mtab" by default, - // fallback to "/proc/mounts" - return Mount::getEntries(/* "/etc/mtab" */); + return Mount::getEntries(); } }; diff --git a/zypp/media/Mount.cc b/zypp/media/Mount.cc index 66da0df..3758420 100644 --- a/zypp/media/Mount.cc +++ b/zypp/media/Mount.cc @@ -25,6 +25,8 @@ #include "zypp/media/Mount.h" #include "zypp/media/MediaException.h" +#include "zypp/PathInfo.h" + #ifndef N_ #define N_(STR) STR #endif @@ -278,8 +280,15 @@ Mount::getEntries(const std::string &mtab) if( mtab.empty()) { - mtabs.push_back("/etc/mtab"); mtabs.push_back("/proc/mounts"); + // Also read /etc/mtab if it is a file (on newer sytems + // mtab is a symlink to /proc/mounts). + // Reason for this is the different representation of + // mounted loop devices: + // /etc/mtab: /tmp/SLES-11-SP2-MINI-ISO-x86_64-Beta2-DVD.iso on /mnt type iso9660 (ro,loop=/dev/loop0) + // /proc/mounts: /dev/loop0 /mnt iso9660 ro,relatime 0 0 + if ( PathInfo( "/etc/mtab", PathInfo::LSTAT ).isFile() ) + mtabs.push_back("/etc/mtab"); } else { diff --git a/zypp/media/Mount.h b/zypp/media/Mount.h index 1c95dda..04ea0d4 100644 --- a/zypp/media/Mount.h +++ b/zypp/media/Mount.h @@ -128,8 +128,9 @@ namespace zypp { * * @param mtab The name of the (mounted) file system description * file to read from. This file should be one /etc/mtab, - * /etc/fstab or /proc/mounts. Default is to try the - * /etc/mtab and fail back to /proc/mounts. + * /etc/fstab or /proc/mounts. Default is to read + * /proc/mounts and /etc/mtab in case is not a symlink + * to /proc/mounts. * @returns A vector with mount entries or empty vector if reading * or parsing of the mtab file(s) failed. */ -- 2.7.4