From 0d54337b70ee7ff1f78b3451a0aaf7a0bb9581e8 Mon Sep 17 00:00:00 2001 From: Thomas Fehr Date: Mon, 11 Mar 2013 17:49:25 +0100 Subject: [PATCH] prevent superfluous error log entries --- libstorage/src/AppUtil.cc | 7 ++++--- libstorage/src/AppUtil.h | 2 +- libstorage/src/Device.cc | 2 +- libstorage/src/Storage.cc | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libstorage/src/AppUtil.cc b/libstorage/src/AppUtil.cc index 7fd42e699..b6fca7f86 100644 --- a/libstorage/src/AppUtil.cc +++ b/libstorage/src/AppUtil.cc @@ -153,7 +153,7 @@ checkNormalFile(const string& Path_Cv) bool - getMajorMinor(const string& device, unsigned long& major, unsigned long& minor) + getMajorMinor(const string& device, unsigned long& major, unsigned long& minor, bool may_fail) { bool ret = false; string dev = normalizeDevice(device); @@ -167,9 +167,10 @@ checkNormalFile(const string& Path_Cv) minor = gnu_dev_minor(sbuf.st_rdev); } } - else + else { - y2err("stat for " << device << " failed errno:" << errno << " (" << strerror(errno) << ")"); + if( !may_fail ) + y2err("stat for " << device << " failed errno:" << errno << " (" << strerror(errno) << ")"); } return ret; } diff --git a/libstorage/src/AppUtil.h b/libstorage/src/AppUtil.h index 8fe98c2bf..a6293227e 100644 --- a/libstorage/src/AppUtil.h +++ b/libstorage/src/AppUtil.h @@ -56,7 +56,7 @@ bool setStatMode(const string& Path_Cv, mode_t val ); bool getStatVfs(const string& path, StatVfs&); - bool getMajorMinor(const string& device, unsigned long& major, unsigned long& minor); + bool getMajorMinor(const string& device, unsigned long& major, unsigned long& minor, bool may_fail=false); string extractNthWord(int Num_iv, const string& Line_Cv, bool GetRest_bi = false); diff --git a/libstorage/src/Device.cc b/libstorage/src/Device.cc index b6f520ed3..7eb1135f6 100644 --- a/libstorage/src/Device.cc +++ b/libstorage/src/Device.cc @@ -113,7 +113,7 @@ namespace storage bool Device::getMajorMinor() { - return storage::getMajorMinor(dev, mjr, mnr); + return storage::getMajorMinor(dev, mjr, mnr, create); } diff --git a/libstorage/src/Storage.cc b/libstorage/src/Storage.cc index 8e18ff011..6a3235bee 100644 --- a/libstorage/src/Storage.cc +++ b/libstorage/src/Storage.cc @@ -6257,7 +6257,7 @@ bool Storage::findVolume( const string& device, VolIterator& v, bool also_del, unsigned long mjr, mnr; mjr = mnr = 0; const Device* dev = NULL; - if( !testmode() && getMajorMinor( d, mjr, mnr ) && + if( !testmode() && getMajorMinor( d, mjr, mnr, true ) && (dev=deviceByNumber( mjr, mnr ))!=NULL ) { v = li->begin();