aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2010-06-14 16:52:48 -0500
committerMark Hatle <mark.hatle@windriver.com>2010-07-22 17:56:34 -0500
commit5cc484386e1a6d8da5b0ce3016501ca436f9d7ab (patch)
tree7862034445127241ecec8d0aae922bc13a1bd404
parentb8f600e48a7d105021e2e11ebc86b0665932a717 (diff)
downloadprelink-cross-5cc484386e1a6d8da5b0ce3016501ca436f9d7ab.tar.gz
prelink-cross-5cc484386e1a6d8da5b0ce3016501ca436f9d7ab.tar.bz2
prelink-cross-5cc484386e1a6d8da5b0ce3016501ca436f9d7ab.zip
Cleanup wrap_stat
2006-11-30 Mark Shinwell <shinwell@codesourcery.com> * wrap-file.c (wrap_stat_body): New. (wrap_lstat64, wrap_stat64): Use wrap_stat_body. * gather.c (add_to_blacklist): Add missing wrap_stat64
-rw-r--r--trunk/ChangeLog.cross5
-rw-r--r--trunk/src/gather.c2
-rw-r--r--trunk/src/wrap-file.c38
3 files changed, 23 insertions, 22 deletions
diff --git a/trunk/ChangeLog.cross b/trunk/ChangeLog.cross
index 183f962..d57b3d3 100644
--- a/trunk/ChangeLog.cross
+++ b/trunk/ChangeLog.cross
@@ -2,6 +2,11 @@
* Integrate prelinker/cross-prelinking patches
+ 006-11-30 Mark Shinwell <shinwell@codesourcery.com>
+
+ * wrap-file.c (wrap_stat_body): New.
+ (wrap_lstat64, wrap_stat64): Use wrap_stat_body.
+
2006-11-28 Mark Shinwell <shinwell@codesourcery.com>
* src/layout.c (layout_libs): Add assertion to check for buffer
diff --git a/trunk/src/gather.c b/trunk/src/gather.c
index 8163fe2..d31f472 100644
--- a/trunk/src/gather.c
+++ b/trunk/src/gather.c
@@ -1273,7 +1273,7 @@ add_to_blacklist (const char *name, int deref, int onefs)
size_t len;
struct stat64 st;
- if (stat64 (name, &st) < 0)
+ if (wrap_stat64 (name, &st) < 0)
{
if (implicit)
return 0;
diff --git a/trunk/src/wrap-file.c b/trunk/src/wrap-file.c
index 0f7120c..6b0c3f1 100644
--- a/trunk/src/wrap-file.c
+++ b/trunk/src/wrap-file.c
@@ -312,31 +312,15 @@ wrap_prelink_canonicalize (const char *name, struct stat64 *stp)
return prelink_canonicalize(name, stp);
}
-int
-wrap_lstat64 (const char *file, struct stat64 *buf)
-{
- char *tmpname = sysroot_file_name (file, 1, NULL);
- int ret;
-
- if (tmpname == NULL)
- return -1;
-
- ret = lstat64 (tmpname, buf);
-
- if (tmpname != file)
- free (tmpname);
- return ret;
-}
-
-int
-wrap_stat64 (const char *file, struct stat64 *buf)
+static int
+wrap_stat_body (const char *file, struct stat64 *buf, int lstat)
{
char* file_copy;
char *tmpname;
int ret;
int len;
- tmpname = sysroot_file_name (file, 0, NULL);
+ tmpname = sysroot_file_name (file, lstat, NULL);
if (tmpname == NULL)
return -1;
@@ -350,10 +334,10 @@ wrap_stat64 (const char *file, struct stat64 *buf)
return -1;
len = strlen (file_copy);
- if (file_copy[len - 1] == '/')
+ if (len && file_copy[len - 1] == '/' || file_copy[len - 1] == '\\'))
file_copy[len - 1] = '\0';
- ret = stat64 (file_copy, buf);
+ ret = lstat ? lstat64 (file_copy, buf) : stat64 (file_copy, buf);
free (file_copy);
@@ -361,6 +345,18 @@ wrap_stat64 (const char *file, struct stat64 *buf)
}
int
+wrap_lstat64 (const char *file, struct stat64 *buf)
+{
+ return wrap_stat_body (file, buf, 1);
+}
+
+int
+wrap_stat64 (const char *file, struct stat64 *buf)
+{
+ return wrap_stat_body (file, buf, 0);
+}
+
+int
wrap_rename (const char *old, const char *new)
{
char *tmpold = sysroot_file_name (old, 1, NULL);