aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2010-06-11 12:55:35 -0500
committerMark Hatle <mark.hatle@windriver.com>2010-07-22 15:50:13 -0500
commit48d8280a61d3edb62ffcf8c18c5e71fad80b3307 (patch)
treee75e86d929af7270de1e8222112d21e1328c8f13
parentcfe26a3ed3e9e4e9783baef8463234e4ca23c686 (diff)
downloadprelink-cross-48d8280a61d3edb62ffcf8c18c5e71fad80b3307.tar.gz
prelink-cross-48d8280a61d3edb62ffcf8c18c5e71fad80b3307.tar.bz2
prelink-cross-48d8280a61d3edb62ffcf8c18c5e71fad80b3307.zip
Import from: prelink-noreexecinit.patch
Source: CodeSourcery, LLC. When prelinking a system, check to see if we modified /sbin/init, if we did re-run it. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
-rw-r--r--ChangeLog.cross4
-rw-r--r--src/main.c25
2 files changed, 29 insertions, 0 deletions
diff --git a/ChangeLog.cross b/ChangeLog.cross
index 0eac7ae..bacc9d7 100644
--- a/ChangeLog.cross
+++ b/ChangeLog.cross
@@ -1,3 +1,7 @@
+2006-08-09 CodeSourcery, LLC.
+
+ * main.c: if we modified /sbin/init, re-run init
+
2006-08-08 CodeSourcery, LLC.
* arch-arm.c: add ARM EABI support, dynamic_linker_alt
diff --git a/src/main.c b/src/main.c
index 0392d5b..844c52f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -58,6 +58,8 @@ const char *ld_library_path;
const char *prelink_conf = PRELINK_CONF;
const char *prelink_cache = PRELINK_CACHE;
const char *undo_output;
+int noreexecinit;
+time_t initctime;
const char *argp_program_version = "prelink 1.0";
@@ -113,6 +115,7 @@ static struct argp_option options[] = {
{"mmap-region-end", OPT_MMAP_REG_END, "BASE_ADDRESS", OPTION_HIDDEN, "" },
{"seed", OPT_SEED, "SEED", OPTION_HIDDEN, "" },
{"compute-checksum", OPT_COMPUTE_CHECKSUM, 0, OPTION_HIDDEN, "" },
+ {"init", 'i', 0, 0, "Do not re-execute init" },
{ 0 }
};
@@ -227,12 +230,29 @@ parse_opt (int key, char *arg, struct argp_state *state)
case OPT_SYSROOT:
sysroot = arg;
break;
+ case 'i':
+ noreexecinit=1;
+ break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
+time_t get_ctime(const char *file) {
+ struct stat st;
+ if(stat(file,&st) == 0)
+ return st.st_ctime;
+ return 0;
+}
+
+void checkinit() {
+ if(initctime != get_ctime("/sbin/init")) {
+ printf("Executing /sbin/init U\n");
+ system("/sbin/init U");
+ }
+}
+
static struct argp argp = { options, parse_opt, "[FILES]", argp_doc };
int
@@ -250,6 +270,11 @@ main (int argc, char *argv[])
argp_parse (&argp, argc, argv, 0, &remaining, 0);
+ if(!noreexecinit) {
+ initctime = get_ctime("/sbin/init");
+ atexit(checkinit);
+ }
+
if (ld_library_path == NULL)
ld_library_path = getenv ("LD_LIBRARY_PATH");