Mailinglist Archive: zypp-commit (38 mails)

< Previous Next >
[zypp-commit] <libzypp> master : Tune CheckAccessDeleted to focus on libraries and executables.
  • From: Michael Andres <ma@xxxxxxx>
  • Date: Wed, 26 Aug 2009 15:57:07 +0200
  • Message-id: <E1MgJ08-0006RZ-E1@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit 3906ad222caaabd2cf45193252a22ecd700134a4
Author: Michael Andres <ma@xxxxxxx>
Date: Wed Aug 26 15:57:07 2009 +0200

Tune CheckAccessDeleted to focus on libraries and executables.
---
VERSION.cmake | 4 +-
package/libzypp.changes | 6 +++
tools/zypp-CheckAccessDeleted.cc | 4 +-
zypp/misc/CheckAccessDeleted.cc | 67 +++++++++++++++++++++++++++++--------
zypp/misc/CheckAccessDeleted.h | 7 ++--
5 files changed, 66 insertions(+), 22 deletions(-)

diff --git a/VERSION.cmake b/VERSION.cmake
index 933719f..3a304f4 100644
--- a/VERSION.cmake
+++ b/VERSION.cmake
@@ -61,8 +61,8 @@
SET(LIBZYPP_MAJOR "6")
SET(LIBZYPP_COMPATMINOR "11")
SET(LIBZYPP_MINOR "13")
-SET(LIBZYPP_PATCH "1")
+SET(LIBZYPP_PATCH "2")
#
-# LAST RELEASED: 6.13.1 (11)
+# LAST RELEASED: 6.13.2 (11)
# (The number in parenthesis is LIBZYPP_COMPATMINOR)
#=======
diff --git a/package/libzypp.changes b/package/libzypp.changes
index 3247faf..5c13823 100644
--- a/package/libzypp.changes
+++ b/package/libzypp.changes
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Wed Aug 26 15:55:22 CEST 2009 - ma@xxxxxxx
+
+- Tune CheckAccessDeleted to focus on libraries and executables.
+- version 6.13.2 (11)
+
+-------------------------------------------------------------------
Thu Aug 6 18:18:21 CEST 2009 - ma@xxxxxxx

- Provide class CheckAccessDeleted and command zypp-CheckAccessDeleted
diff --git a/tools/zypp-CheckAccessDeleted.cc b/tools/zypp-CheckAccessDeleted.cc
index 09811ff..9517c49 100644
--- a/tools/zypp-CheckAccessDeleted.cc
+++ b/tools/zypp-CheckAccessDeleted.cc
@@ -103,14 +103,14 @@ int main( int argc, char * argv[] )
{
std::cout << "Usage: " << progname << " [--help]" << std::endl;
std::cout << "List information about all running processe" << std::endl;
- std::cout << "which access deleted files or libraries." << std::endl;
+ std::cout << "which access deleted executables or libraries." <<
std::endl;
std::cout << " PID " << "process ID" << std::endl;
std::cout << " PPID " << "parent process ID" << std::endl;
std::cout << " UID " << "process user ID" << std::endl;
std::cout << " LOGIN " << "process login name" << std::endl;
std::cout << " COMMAND " << "process command name" << std::endl;
std::cout << " SERVICE " << "/etc/init.d/ script that might be used to
restart the command (guessed)" << std::endl;
- std::cout << " FILES " << "list of deleted files or libraries
accessed" << std::endl;
+ std::cout << " FILES " << "list of deleted executables or libraries
accessed" << std::endl;
return 0;
}
std::cerr << progname << ": unexpected argument '" << argv[1] << "'" <<
std::endl;
diff --git a/zypp/misc/CheckAccessDeleted.cc b/zypp/misc/CheckAccessDeleted.cc
index ce0b7e7..9aa9d55 100644
--- a/zypp/misc/CheckAccessDeleted.cc
+++ b/zypp/misc/CheckAccessDeleted.cc
@@ -91,37 +91,74 @@ namespace zypp
MIL << " Take " << pinfo << endl;
}

- /** Add line to cache if it refers to a deleted file.
- * Either the link count \c(k) os \c 0, or if no link cout is present,
- * the filedescriptor/type \c (ft) is set to \c DEL.
+ /** Add line to cache if it refers to a deleted executable or library file:
+ * - Either the link count \c(k) os \c 0, or no link cout is present.
+ * - The type \c (t) is set to \c REG or \c DEL
+ * - The filedescriptor \c (f) is set to \c txt, \c mem or \c DEL
*/
inline void addCacheIf( CheckAccessDeleted::ProcInfo & cache_r, const
std::string & line_r )
{
- bool takeLine = false;
- const char * name = "";
+ const char * k = ".";
+ const char * f = ".";
+ const char * t = ".";
+ const char * n = ".";

- for_( ch, line_r.begin(), line_r.end() )
+ for_( ch, line_r.c_str(), ch+line_r.size() )
{
switch ( *ch )
{
case 'k':
- if ( ! takeLine && *(ch+1) == '0' && *(ch+2) == '\0' )
- takeLine = true;
- break;
+ if ( *(ch+1) != '0' ) // skip non-zero link counts
+ return;
+ k = ch+1;
+ break;
case 'f':
+ f = ch+1;
+ break;
case 't':
- if ( ! takeLine && *(ch+1) == 'D' && *(ch+2) == 'E' && *(ch+3) ==
'L' && *(ch+4) == '\0' )
- takeLine = true;
+ t = ch+1;
break;
case 'n':
- name = &*(ch+1);
- break;
+ n = ch+1;
+ break;
}
if ( *ch == '\n' ) break; // end of data
do { ++ch; } while ( *ch != '\0' ); // skip to next field
}
- if ( takeLine )
- cache_r.files.push_back( name );
+
+ if ( !t || !f || !n )
+ return; // wrong filedescriptor/type/name
+
+ if ( !( ( *t == 'R' && *(t+1) == 'E' && *(t+2) == 'G' && *(t+3) ==
'\0' )
+ || ( *t == 'D' && *(t+1) == 'E' && *(t+2) == 'L' && *(t+3) ==
'\0' ) ) )
+ return; // wrong type
+
+ if ( !( ( *f == 'm' && *(f+1) == 'e' && *(f+2) == 'm' && *(f+3) ==
'\0' )
+ || ( *f == 't' && *(f+1) == 'x' && *(f+2) == 't' && *(f+3) ==
'\0' )
+ || ( *f == 'D' && *(f+1) == 'E' && *(f+2) == 'L' && *(f+3) ==
'\0' )
+ || ( *f == 'l' && *(f+1) == 't' && *(f+2) == 'x' && *(f+3) ==
'\0' ) ) )
+ return; // wrong filedescriptor type
+
+ std::string name( n );
+
+ if ( *f == 'm' || *f == 'D' ) // skip some wellknown nonlibrary
memorymapped files
+ {
+ static const char * black[] = {
+ "/SYSV",
+ "/var/run/"
+ };
+ for_( it, arrayBegin( black ), arrayEnd( black ) )
+ {
+ if ( str::hasPrefix( n, *it ) )
+ return;
+ }
+ }
+
+ if ( std::find( cache_r.files.begin(), cache_r.files.end(), name ) ==
cache_r.files.end() )
+ {
+ // Add if no duplicate
+ cache_r.files.push_back( n );
+ }
}
/////////////////////////////////////////////////////////////////
} // namespace
diff --git a/zypp/misc/CheckAccessDeleted.h b/zypp/misc/CheckAccessDeleted.h
index 10c1455..cb8b545 100644
--- a/zypp/misc/CheckAccessDeleted.h
+++ b/zypp/misc/CheckAccessDeleted.h
@@ -21,7 +21,7 @@ namespace zypp
{ /////////////////////////////////////////////////////////////////

/**
- * Check for running processes which access deleted files or libraries.
+ * Check for running processes which access deleted executables or libraries.
*
* Executed after commit, this gives a hint which processes/services
* need to be restarted.
@@ -33,6 +33,7 @@ namespace zypp
*/
class CheckAccessDeleted
{
+
public:
/**
* Data about one running process accessing deleted files.
@@ -44,7 +45,7 @@ namespace zypp
std::string puid; //!< process user ID
std::string login; //!< process login name
std::string command; //!< process command name
- std::vector<std::string> files; //!< list of deleted files or
libraries accessed
+ std::vector<std::string> files; //!< list of deleted
executables or libraries accessed

/** Guess if command was started by an \c /etc/init.d/ script.
* The name of an \c /etc/init.d/ script that might be used to restart
the
@@ -68,7 +69,7 @@ namespace zypp
{ if ( doCheck_r ) check(); }

public:
- /** Check for running processes which access deleted files or libraries.
+ /** Check for running processes which access deleted executables or
libraries.
* \return the number of processes found.
* \throws Exception On error collecting the data (e.g. no lsof
installed)
*/
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages