summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-03-25 15:47:21 -0700
committerJosh Stone <jistone@redhat.com>2009-03-25 17:40:26 -0700
commit2a8c27f6bfdf2e7962def6fc8729ebb5fb54c701 (patch)
treefa368a2296bcc72ba5c5c2c375b5e293ae0c9c94
parent121e57ae36e2030093f72723b1fb74dc0507ddab (diff)
downloadsystemtap-steved-2a8c27f6bfdf2e7962def6fc8729ebb5fb54c701.tar.gz
systemtap-steved-2a8c27f6bfdf2e7962def6fc8729ebb5fb54c701.tar.xz
systemtap-steved-2a8c27f6bfdf2e7962def6fc8729ebb5fb54c701.zip
Add more file stats to the hash
For kernel developers, it may be common practice to reuse the same kernel build tree for several kernel variants. Our previous hashing only considered the release version, architecture, and build path, which may all remain constant for such a developer. This change adds the file size and mtime of several kernel version files to the hash, so it should be a bit more robust against collisions.
-rw-r--r--hash.cxx38
-rw-r--r--hash.h1
2 files changed, 25 insertions, 14 deletions
diff --git a/hash.cxx b/hash.cxx
index b8d5a0e4..c9121641 100644
--- a/hash.cxx
+++ b/hash.cxx
@@ -48,6 +48,20 @@ hash::add(const unsigned char *buffer, size_t size)
void
+hash::add_file(const std::string& filename)
+{
+ struct stat st;
+
+ if (stat(filename.c_str(), &st) == 0)
+ {
+ add(filename);
+ add(st.st_size);
+ add(st.st_mtime);
+ }
+}
+
+
+void
hash::result(string& r)
{
ostringstream rstream;
@@ -68,37 +82,33 @@ hash::result(string& r)
static void
get_base_hash (systemtap_session& s, hash& h)
{
- struct stat st;
-
// Hash kernel release and arch.
h.add(s.kernel_release);
h.add(s.kernel_build_tree);
h.add(s.architecture);
+ // Hash a few kernel version/build-id files too
+ // (useful for kernel developers reusing a single source tree)
+ h.add_file(s.kernel_build_tree + "/.config");
+ h.add_file(s.kernel_build_tree + "/.version");
+ h.add_file(s.kernel_build_tree + "/include/linux/compile.h");
+ h.add_file(s.kernel_build_tree + "/include/linux/version.h");
+ h.add_file(s.kernel_build_tree + "/include/linux/utsrelease.h");
+
// Hash runtime path (that gets added in as "-R path").
h.add(s.runtime_path);
// Hash compiler path, size, and mtime. We're just going to assume
// we'll be using gcc. XXX: getting kbuild to spit out out would be
// better.
- string gcc_path = find_executable ("gcc");
- if (stat(gcc_path.c_str(), &st) == 0)
- {
- h.add(gcc_path);
- h.add(st.st_size);
- h.add(st.st_mtime);
- }
+ h.add_file(find_executable("gcc"));
// Hash the systemtap size and mtime. We could use VERSION/DATE,
// but when developing systemtap that doesn't work well (since you
// can compile systemtap multiple times in 1 day). Since we don't
// know exactly where we're getting run from, we'll use
// /proc/self/exe.
- if (stat("/proc/self/exe", &st) == 0)
- {
- h.add(st.st_size);
- h.add(st.st_mtime);
- }
+ h.add_file("/proc/self/exe");
}
diff --git a/hash.h b/hash.h
index 0fe95e27..bb3d5ae1 100644
--- a/hash.h
+++ b/hash.h
@@ -30,6 +30,7 @@ public:
void add(const char *s) { add((const unsigned char *)s, strlen(s)); }
void add(const std::string& s) { add((const unsigned char *)s.c_str(),
s.length()); }
+ void add_file(const std::string& filename);
void result(std::string& r);
};