Add option to return an error if all binaries cannot be prelinked
PATCH 1/1 Add option to return an error if all binaries cannot be prelinked
Otherwise, there's no way to validate whether or not the operation was actually successful without rescanning.
Signed-off-by Kyle Russell <[email protected]>
--- src/doit.c | 16 +++++++++++----- src/main.c | 8 +++++++- src/prelink.h | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-)
src/doit.c +11 -5
@@ -237,11 +237,11 @@ error_out:return ; } -void +int prelink_all (void ) {struct collect_ents l; -int i; +int i, fails =0 ; l.ents = (struct prelink_entry **) alloca (prelink_entry_count
@@ -250,7 +250,13 @@ prelink_all (void)htab_traverse (prelink_filename_htab, find_ents, &l);for (i =0 ; i < l.nents; ++i) -if (l.ents[i]->done ==1 - || (l.ents[i]->done ==0 && l.ents[i]->type ==ET_EXEC )) -prelink_ent (l.ents[i]); + { +if (l.ents[i]->done ==1 + || (l.ents[i]->done ==0 && l.ents[i]->type ==ET_EXEC )) +prelink_ent (l.ents[i]); +if (l.ents[i]->type ==ET_UNPRELINKABLE ) + fails++; + } + +return fails; }
src/main.c +7 -1
@@ -47,6 +47,7 @@ int one_file_system;int enable_cxx_optimizations =1 ;int exec_shield;int undo, verify; +int errors;enum verify_method_t verify_method;int quick;int compute_checksum;
@@ -90,6 +91,7 @@ static struct argp_option options[] = { {"black-list", 'b', "PATH", 0, "Blacklist path" }, {"cache-file", 'C', "CACHE", 0, "Use CACHE as cache file" }, {"config-file", 'c', "CONF", 0, "Use CONF as configuration file" }, + {"errors", 'e', 0, 0, "Returns an error if all binaries are not prelinkable" }, {"force", 'f', 0, 0, "Force prelinking" }, {"dereference", 'h', 0, 0, "Follow symlinks when processing directory trees from command line" }, {"one-file-system", 'l', 0, 0, "Stay in local file system when processing directories from command line" },
@@ -139,6 +141,9 @@ parse_opt (int key, char *arg, struct argp_state *state)if (add_to_blacklist (arg, dereference, one_file_system))exit (EXIT_FAILURE );break ; +case 'e' : + errors =1 ; +break ;case 'f' : force =1 ;break ;
@@ -524,7 +529,8 @@ main (int argc, char *argv[])prelink_load_cache ();layout_libs (); -prelink_all (); +if (prelink_all () && errors) +return EXIT_FAILURE ;if (! no_update && ! dry_run)prelink_save_cache (all);
src/prelink.h +1 -1
@@ -574,7 +574,7 @@ int get_relocated_mem (struct prelink_info *info, DSO *dso, GElf_Addr addr,int layout_libs (void ); -void prelink_all (void ); +int prelink_all (void );int undo_all (void );
Signature · 1 line
2.17.1