aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
Diffstat (limited to 'archival')
-rw-r--r--archival/ar.c12
-rw-r--r--archival/bunzip2.c16
-rw-r--r--archival/cpio.c4
-rw-r--r--archival/dpkg.c91
-rw-r--r--archival/dpkg_deb.c6
-rw-r--r--archival/gunzip.c30
-rw-r--r--archival/gzip.c32
-rw-r--r--archival/libunarchive/archive_copy_file.c2
-rw-r--r--archival/libunarchive/archive_xread.c2
-rw-r--r--archival/libunarchive/archive_xread_all.c2
-rw-r--r--archival/libunarchive/archive_xread_all_eof.c2
-rw-r--r--archival/libunarchive/check_header_gzip.c16
-rw-r--r--archival/libunarchive/data_extract_all.c16
-rw-r--r--archival/libunarchive/decompress_bunzip2.c8
-rw-r--r--archival/libunarchive/decompress_uncompress.c8
-rw-r--r--archival/libunarchive/decompress_unzip.c32
-rw-r--r--archival/libunarchive/get_header_ar.c16
-rw-r--r--archival/libunarchive/get_header_cpio.c16
-rw-r--r--archival/libunarchive/get_header_tar.c10
-rw-r--r--archival/libunarchive/get_header_tar_gz.c2
-rw-r--r--archival/libunarchive/header_verbose_list.c2
-rw-r--r--archival/libunarchive/seek_by_jump.c2
-rw-r--r--archival/libunarchive/uncompress.c8
-rw-r--r--archival/libunarchive/unpack_ar_archive.c2
-rw-r--r--archival/libunarchive/unzip.c32
-rw-r--r--archival/rpm.c14
-rw-r--r--archival/rpm2cpio.c18
-rw-r--r--archival/tar.c55
-rw-r--r--archival/uncompress.c20
-rw-r--r--archival/unzip.c18
30 files changed, 246 insertions, 248 deletions
diff --git a/archival/ar.c b/archival/ar.c
index 87968f7be..57ec92719 100644
--- a/archival/ar.c
+++ b/archival/ar.c
@@ -40,7 +40,7 @@
40 40
41static void header_verbose_list_ar(const file_header_t *file_header) 41static void header_verbose_list_ar(const file_header_t *file_header)
42{ 42{
43 const char *mode = mode_string(file_header->mode); 43 const char *mode = bb_mode_string(file_header->mode);
44 char *mtime; 44 char *mtime;
45 45
46 mtime = ctime(&file_header->mtime); 46 mtime = ctime(&file_header->mtime);
@@ -58,7 +58,7 @@ static void data_extract_regular_file(archive_handle_t *archive_handle)
58 int dst_fd; 58 int dst_fd;
59 59
60 file_header = archive_handle->file_header; 60 file_header = archive_handle->file_header;
61 dst_fd = xopen(file_header->name, O_WRONLY | O_CREAT); 61 dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT);
62 archive_copy_file(archive_handle, dst_fd); 62 archive_copy_file(archive_handle, dst_fd);
63 close(dst_fd); 63 close(dst_fd);
64 64
@@ -110,16 +110,16 @@ extern int ar_main(int argc, char **argv)
110 archive_handle->action_header = header_verbose_list_ar; 110 archive_handle->action_header = header_verbose_list_ar;
111 break; 111 break;
112 default: 112 default:
113 show_usage(); 113 bb_show_usage();
114 } 114 }
115 } 115 }
116 116
117 /* check the src filename was specified */ 117 /* check the src filename was specified */
118 if (optind == argc) { 118 if (optind == argc) {
119 show_usage(); 119 bb_show_usage();
120 } 120 }
121 121
122 archive_handle->src_fd = xopen(argv[optind++], O_RDONLY); 122 archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY);
123 123
124 /* TODO: This is the same as in tar, seperate function ? */ 124 /* TODO: This is the same as in tar, seperate function ? */
125 while (optind < argc) { 125 while (optind < argc) {
@@ -133,7 +133,7 @@ extern int ar_main(int argc, char **argv)
133#else 133#else
134 archive_xread_all(archive_handle, magic, 7); 134 archive_xread_all(archive_handle, magic, 7);
135 if (strncmp(magic, "!<arch>", 7) != 0) { 135 if (strncmp(magic, "!<arch>", 7) != 0) {
136 error_msg_and_die("Invalid ar magic"); 136 bb_error_msg_and_die("Invalid ar magic");
137 } 137 }
138 archive_handle->offset += 7; 138 archive_handle->offset += 7;
139 139
diff --git a/archival/bunzip2.c b/archival/bunzip2.c
index d5c06f4fd..eb5238cd4 100644
--- a/archival/bunzip2.c
+++ b/archival/bunzip2.c
@@ -41,7 +41,7 @@ int bunzip2_main(int argc, char **argv)
41 char *delete_name = NULL; 41 char *delete_name = NULL;
42 42
43 /* if called as bzcat */ 43 /* if called as bzcat */
44 if (strcmp(applet_name, "bzcat") == 0) 44 if (strcmp(bb_applet_name, "bzcat") == 0)
45 flags |= bunzip_to_stdout; 45 flags |= bunzip_to_stdout;
46 46
47 while ((opt = getopt(argc, argv, "cfh")) != -1) { 47 while ((opt = getopt(argc, argv, "cfh")) != -1) {
@@ -54,7 +54,7 @@ int bunzip2_main(int argc, char **argv)
54 break; 54 break;
55 case 'h': 55 case 'h':
56 default: 56 default:
57 show_usage(); /* exit's inside usage */ 57 bb_show_usage(); /* exit's inside usage */
58 } 58 }
59 } 59 }
60 60
@@ -64,23 +64,23 @@ int bunzip2_main(int argc, char **argv)
64 src_fd = fileno(stdin); 64 src_fd = fileno(stdin);
65 } else { 65 } else {
66 /* Open input file */ 66 /* Open input file */
67 src_fd = xopen(argv[optind], O_RDONLY); 67 src_fd = bb_xopen(argv[optind], O_RDONLY);
68 68
69 save_name = xstrdup(argv[optind]); 69 save_name = bb_xstrdup(argv[optind]);
70 if (strcmp(save_name + strlen(save_name) - 4, ".bz2") != 0) 70 if (strcmp(save_name + strlen(save_name) - 4, ".bz2") != 0)
71 error_msg_and_die("Invalid extension"); 71 bb_error_msg_and_die("Invalid extension");
72 save_name[strlen(save_name) - 4] = '\0'; 72 save_name[strlen(save_name) - 4] = '\0';
73 } 73 }
74 74
75 /* Check that the input is sane. */ 75 /* Check that the input is sane. */
76 if (isatty(src_fd) && (flags & bunzip_force) == 0) { 76 if (isatty(src_fd) && (flags & bunzip_force) == 0) {
77 error_msg_and_die("compressed data not read from terminal. Use -f to force it."); 77 bb_error_msg_and_die("compressed data not read from terminal. Use -f to force it.");
78 } 78 }
79 79
80 if (flags & bunzip_to_stdout) { 80 if (flags & bunzip_to_stdout) {
81 dst_fd = fileno(stdout); 81 dst_fd = fileno(stdout);
82 } else { 82 } else {
83 dst_fd = xopen(save_name, O_WRONLY | O_CREAT); 83 dst_fd = bb_xopen(save_name, O_WRONLY | O_CREAT);
84 } 84 }
85 85
86 if (uncompressStream(src_fd, dst_fd)) { 86 if (uncompressStream(src_fd, dst_fd)) {
@@ -96,7 +96,7 @@ int bunzip2_main(int argc, char **argv)
96 } 96 }
97 97
98 if ((delete_name) && (unlink(delete_name) < 0)) { 98 if ((delete_name) && (unlink(delete_name) < 0)) {
99 error_msg_and_die("Couldn't remove %s", delete_name); 99 bb_error_msg_and_die("Couldn't remove %s", delete_name);
100 } 100 }
101 101
102 return status; 102 return status;
diff --git a/archival/cpio.c b/archival/cpio.c
index 49f3f88e4..111807c43 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -63,11 +63,11 @@ extern int cpio_main(int argc, char **argv)
63 archive_handle->action_header = header_list; 63 archive_handle->action_header = header_list;
64 break; 64 break;
65 case 'F': 65 case 'F':
66 archive_handle->src_fd = xopen(optarg, O_RDONLY); 66 archive_handle->src_fd = bb_xopen(optarg, O_RDONLY);
67 archive_handle->seek = seek_by_jump; 67 archive_handle->seek = seek_by_jump;
68 break; 68 break;
69 default: 69 default:
70 show_usage(); 70 bb_show_usage();
71 } 71 }
72 } 72 }
73 73
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 692592268..3288f7e63 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -177,7 +177,7 @@ int search_name_hashtable(const char *key)
177 } 177 }
178 } 178 }
179 } 179 }
180 name_hashtable[probe_address] = xstrdup(key); 180 name_hashtable[probe_address] = bb_xstrdup(key);
181 return(probe_address); 181 return(probe_address);
182} 182}
183 183
@@ -218,10 +218,10 @@ int version_compare_part(const char *version1, const char *version2)
218 int ret; 218 int ret;
219 219
220 if (version1 == NULL) { 220 if (version1 == NULL) {
221 version1 = xstrdup(""); 221 version1 = bb_xstrdup("");
222 } 222 }
223 if (version2 == NULL) { 223 if (version2 == NULL) {
224 version2 = xstrdup(""); 224 version2 = bb_xstrdup("");
225 } 225 }
226 upstream_len1 = strlen(version1); 226 upstream_len1 = strlen(version1);
227 upstream_len2 = strlen(version2); 227 upstream_len2 = strlen(version2);
@@ -229,10 +229,10 @@ int version_compare_part(const char *version1, const char *version2)
229 while ((len1 < upstream_len1) || (len2 < upstream_len2)) { 229 while ((len1 < upstream_len1) || (len2 < upstream_len2)) {
230 /* Compare non-digit section */ 230 /* Compare non-digit section */
231 tmp_int = strcspn(&version1[len1], "0123456789"); 231 tmp_int = strcspn(&version1[len1], "0123456789");
232 name1_char = xstrndup(&version1[len1], tmp_int); 232 name1_char = bb_xstrndup(&version1[len1], tmp_int);
233 len1 += tmp_int; 233 len1 += tmp_int;
234 tmp_int = strcspn(&version2[len2], "0123456789"); 234 tmp_int = strcspn(&version2[len2], "0123456789");
235 name2_char = xstrndup(&version2[len2], tmp_int); 235 name2_char = bb_xstrndup(&version2[len2], tmp_int);
236 len2 += tmp_int; 236 len2 += tmp_int;
237 tmp_int = strcmp(name1_char, name2_char); 237 tmp_int = strcmp(name1_char, name2_char);
238 free(name1_char); 238 free(name1_char);
@@ -244,10 +244,10 @@ int version_compare_part(const char *version1, const char *version2)
244 244
245 /* Compare digits */ 245 /* Compare digits */
246 tmp_int = strspn(&version1[len1], "0123456789"); 246 tmp_int = strspn(&version1[len1], "0123456789");
247 name1_char = xstrndup(&version1[len1], tmp_int); 247 name1_char = bb_xstrndup(&version1[len1], tmp_int);
248 len1 += tmp_int; 248 len1 += tmp_int;
249 tmp_int = strspn(&version2[len2], "0123456789"); 249 tmp_int = strspn(&version2[len2], "0123456789");
250 name2_char = xstrndup(&version2[len2], tmp_int); 250 name2_char = bb_xstrndup(&version2[len2], tmp_int);
251 len2 += tmp_int; 251 len2 += tmp_int;
252 ver_num1 = atoi(name1_char); 252 ver_num1 = atoi(name1_char);
253 ver_num2 = atoi(name2_char); 253 ver_num2 = atoi(name2_char);
@@ -306,8 +306,8 @@ int version_compare(const unsigned int ver1, const unsigned int ver2)
306 } 306 }
307 307
308 /* Compare upstream version */ 308 /* Compare upstream version */
309 upstream_ver1 = xstrdup(ver1_ptr); 309 upstream_ver1 = bb_xstrdup(ver1_ptr);
310 upstream_ver2 = xstrdup(ver2_ptr); 310 upstream_ver2 = bb_xstrdup(ver2_ptr);
311 311
312 /* Chop off debian version, and store for later use */ 312 /* Chop off debian version, and store for later use */
313 deb_ver1 = strrchr(upstream_ver1, '-'); 313 deb_ver1 = strrchr(upstream_ver1, '-');
@@ -397,7 +397,7 @@ int search_package_hashtable(const unsigned int name, const unsigned int version
397 */ 397 */
398void add_split_dependencies(common_node_t *parent_node, const char *whole_line, unsigned int edge_type) 398void add_split_dependencies(common_node_t *parent_node, const char *whole_line, unsigned int edge_type)
399{ 399{
400 char *line = xstrdup(whole_line); 400 char *line = bb_xstrdup(whole_line);
401 char *line2; 401 char *line2;
402 char *line_ptr1 = NULL; 402 char *line_ptr1 = NULL;
403 char *line_ptr2 = NULL; 403 char *line_ptr2 = NULL;
@@ -410,7 +410,7 @@ void add_split_dependencies(common_node_t *parent_node, const char *whole_line,
410 410
411 field = strtok_r(line, ",", &line_ptr1); 411 field = strtok_r(line, ",", &line_ptr1);
412 do { 412 do {
413 line2 = xstrdup(field); 413 line2 = bb_xstrdup(field);
414 field2 = strtok_r(line2, "|", &line_ptr2); 414 field2 = strtok_r(line2, "|", &line_ptr2);
415 if ((edge_type == EDGE_DEPENDS) && (strcmp(field, field2) != 0)) { 415 if ((edge_type == EDGE_DEPENDS) && (strcmp(field, field2) != 0)) {
416 type = EDGE_OR_DEPENDS; 416 type = EDGE_OR_DEPENDS;
@@ -457,7 +457,7 @@ void add_split_dependencies(common_node_t *parent_node, const char *whole_line,
457 else if (strncmp(version, ">=", offset_ch) == 0) { 457 else if (strncmp(version, ">=", offset_ch) == 0) {
458 edge->operator = VER_MORE_EQUAL; 458 edge->operator = VER_MORE_EQUAL;
459 } else { 459 } else {
460 error_msg_and_die("Illegal operator\n"); 460 bb_error_msg_and_die("Illegal operator\n");
461 } 461 }
462 } 462 }
463 /* skip to start of version numbers */ 463 /* skip to start of version numbers */
@@ -588,7 +588,7 @@ unsigned int get_status(const unsigned int status_node, const int num)
588 status_string += strspn(status_string, " "); 588 status_string += strspn(status_string, " ");
589 } 589 }
590 len = strcspn(status_string, " \n\0"); 590 len = strcspn(status_string, " \n\0");
591 state_sub_string = xstrndup(status_string, len); 591 state_sub_string = bb_xstrndup(status_string, len);
592 state_sub_num = search_name_hashtable(state_sub_string); 592 state_sub_num = search_name_hashtable(state_sub_string);
593 free(state_sub_string); 593 free(state_sub_string);
594 return(state_sub_num); 594 return(state_sub_num);
@@ -620,7 +620,7 @@ void set_status(const unsigned int status_node_num, const char *new_value, const
620 status_len = new_value_len; 620 status_len = new_value_len;
621 break; 621 break;
622 default: 622 default:
623 error_msg_and_die("DEBUG ONLY: this shouldnt happen"); 623 bb_error_msg_and_die("DEBUG ONLY: this shouldnt happen");
624 } 624 }
625 625
626 new_status = (char *) xmalloc(want_len + flag_len + status_len + 3); 626 new_status = (char *) xmalloc(want_len + flag_len + status_len + 3);
@@ -638,7 +638,7 @@ void index_status_file(const char *filename)
638 status_node_t *status_node = NULL; 638 status_node_t *status_node = NULL;
639 unsigned int status_num; 639 unsigned int status_num;
640 640
641 status_file = xfopen(filename, "r"); 641 status_file = bb_xfopen(filename, "r");
642 while ((control_buffer = fgets_str(status_file, "\n\n")) != NULL) { 642 while ((control_buffer = fgets_str(status_file, "\n\n")) != NULL) {
643 const unsigned int package_num = fill_package_struct(control_buffer); 643 const unsigned int package_num = fill_package_struct(control_buffer);
644 if (package_num != -1) { 644 if (package_num != -1) {
@@ -648,7 +648,7 @@ void index_status_file(const char *filename)
648 if (status_line != NULL) { 648 if (status_line != NULL) {
649 status_line += 7; 649 status_line += 7;
650 status_line += strspn(status_line, " \n\t"); 650 status_line += strspn(status_line, " \n\t");
651 status_line = xstrndup(status_line, strcspn(status_line, "\n\0")); 651 status_line = bb_xstrndup(status_line, strcspn(status_line, "\n\0"));
652 status_node->status = search_name_hashtable(status_line); 652 status_node->status = search_name_hashtable(status_line);
653 free(status_line); 653 free(status_line);
654 } 654 }
@@ -754,8 +754,8 @@ void write_buffer_no_status(FILE *new_status_file, const char *control_buffer)
754/* This could do with a cleanup */ 754/* This could do with a cleanup */
755void write_status_file(deb_file_t **deb_file) 755void write_status_file(deb_file_t **deb_file)
756{ 756{
757 FILE *old_status_file = xfopen("/var/lib/dpkg/status", "r"); 757 FILE *old_status_file = bb_xfopen("/var/lib/dpkg/status", "r");
758 FILE *new_status_file = xfopen("/var/lib/dpkg/status.udeb", "w"); 758 FILE *new_status_file = bb_xfopen("/var/lib/dpkg/status.udeb", "w");
759 char *package_name; 759 char *package_name;
760 char *status_from_file; 760 char *status_from_file;
761 char *control_buffer = NULL; 761 char *control_buffer = NULL;
@@ -773,14 +773,14 @@ void write_status_file(deb_file_t **deb_file)
773 773
774 tmp_string += 8; 774 tmp_string += 8;
775 tmp_string += strspn(tmp_string, " \n\t"); 775 tmp_string += strspn(tmp_string, " \n\t");
776 package_name = xstrndup(tmp_string, strcspn(tmp_string, "\n\0")); 776 package_name = bb_xstrndup(tmp_string, strcspn(tmp_string, "\n\0"));
777 write_flag = FALSE; 777 write_flag = FALSE;
778 tmp_string = strstr(control_buffer, "Status:"); 778 tmp_string = strstr(control_buffer, "Status:");
779 if (tmp_string != NULL) { 779 if (tmp_string != NULL) {
780 /* Seperate the status value from the control buffer */ 780 /* Seperate the status value from the control buffer */
781 tmp_string += 7; 781 tmp_string += 7;
782 tmp_string += strspn(tmp_string, " \n\t"); 782 tmp_string += strspn(tmp_string, " \n\t");
783 status_from_file = xstrndup(tmp_string, strcspn(tmp_string, "\n")); 783 status_from_file = bb_xstrndup(tmp_string, strcspn(tmp_string, "\n"));
784 } else { 784 } else {
785 status_from_file = NULL; 785 status_from_file = NULL;
786 } 786 }
@@ -810,7 +810,7 @@ void write_status_file(deb_file_t **deb_file)
810 } 810 }
811 /* This is temperary, debugging only */ 811 /* This is temperary, debugging only */
812 if (deb_file[i] == NULL) { 812 if (deb_file[i] == NULL) {
813 error_msg_and_die("ALERT: Couldnt find a control file, your status file may be broken, status may be incorrect for %s", package_name); 813 bb_error_msg_and_die("ALERT: Couldnt find a control file, your status file may be broken, status may be incorrect for %s", package_name);
814 } 814 }
815 } 815 }
816 else if (strcmp("not-installed", name_hashtable[state_status]) == 0) { 816 else if (strcmp("not-installed", name_hashtable[state_status]) == 0) {
@@ -881,15 +881,15 @@ void write_status_file(deb_file_t **deb_file)
881 if (rename("/var/lib/dpkg/status", "/var/lib/dpkg/status.udeb.bak") == -1) { 881 if (rename("/var/lib/dpkg/status", "/var/lib/dpkg/status.udeb.bak") == -1) {
882 struct stat stat_buf; 882 struct stat stat_buf;
883 if (stat("/var/lib/dpkg/status", &stat_buf) == 0) { 883 if (stat("/var/lib/dpkg/status", &stat_buf) == 0) {
884 error_msg_and_die("Couldnt create backup status file"); 884 bb_error_msg_and_die("Couldnt create backup status file");
885 } 885 }
886 /* Its ok if renaming the status file fails becasue status 886 /* Its ok if renaming the status file fails becasue status
887 * file doesnt exist, maybe we are starting from scratch */ 887 * file doesnt exist, maybe we are starting from scratch */
888 error_msg("No status file found, creating new one"); 888 bb_error_msg("No status file found, creating new one");
889 } 889 }
890 890
891 if (rename("/var/lib/dpkg/status.udeb", "/var/lib/dpkg/status") == -1) { 891 if (rename("/var/lib/dpkg/status.udeb", "/var/lib/dpkg/status") == -1) {
892 error_msg_and_die("DANGER: Couldnt create status file, you need to manually repair your status file"); 892 bb_error_msg_and_die("DANGER: Couldnt create status file, you need to manually repair your status file");
893 } 893 }
894} 894}
895 895
@@ -976,7 +976,7 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
976 } 976 }
977 977
978 if (result) { 978 if (result) {
979 error_msg_and_die("Package %s conflicts with %s", 979 bb_error_msg_and_die("Package %s conflicts with %s",
980 name_hashtable[package_node->name], 980 name_hashtable[package_node->name],
981 name_hashtable[package_edge->name]); 981 name_hashtable[package_edge->name]);
982 } 982 }
@@ -1021,7 +1021,7 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
1021 } 1021 }
1022 1022
1023 if (result) { 1023 if (result) {
1024 error_msg_and_die("Package %s pre-depends on %s, but it is not installed", 1024 bb_error_msg_and_die("Package %s pre-depends on %s, but it is not installed",
1025 name_hashtable[package_node->name], 1025 name_hashtable[package_node->name],
1026 name_hashtable[package_edge->name]); 1026 name_hashtable[package_edge->name]);
1027 } 1027 }
@@ -1038,7 +1038,7 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
1038 } 1038 }
1039 /* It must be already installed, or to be installed */ 1039 /* It must be already installed, or to be installed */
1040 if (result) { 1040 if (result) {
1041 error_msg_and_die("Package %s depends on %s, but it is not installed, or flaged to be installed", 1041 bb_error_msg_and_die("Package %s depends on %s, but it is not installed, or flaged to be installed",
1042 name_hashtable[package_node->name], 1042 name_hashtable[package_node->name],
1043 name_hashtable[package_edge->name]); 1043 name_hashtable[package_edge->name]);
1044 } 1044 }
@@ -1065,9 +1065,8 @@ char **create_list(const char *filename)
1065 return(NULL); 1065 return(NULL);
1066 } 1066 }
1067 1067
1068 while ((line = get_line_from_file(list_stream)) != NULL) { 1068 while ((line = bb_get_chomped_line_from_file(list_stream)) != NULL) {
1069 file_list = xrealloc(file_list, sizeof(char *) * (count + 2)); 1069 file_list = xrealloc(file_list, sizeof(char *) * (count + 2));
1070 chomp(line);
1071 file_list[count] = line; 1070 file_list[count] = line;
1072 count++; 1071 count++;
1073 } 1072 }
@@ -1228,7 +1227,7 @@ void remove_package(const unsigned int package_num)
1228 /* run prerm script */ 1227 /* run prerm script */
1229 return_value = run_package_script(package_name, "prerm"); 1228 return_value = run_package_script(package_name, "prerm");
1230 if (return_value == -1) { 1229 if (return_value == -1) {
1231 error_msg_and_die("script failed, prerm failure"); 1230 bb_error_msg_and_die("script failed, prerm failure");
1232 } 1231 }
1233 1232
1234 /* Create a list of files to remove, and a seperate list of those to keep */ 1233 /* Create a list of files to remove, and a seperate list of those to keep */
@@ -1245,7 +1244,7 @@ void remove_package(const unsigned int package_num)
1245 1244
1246 /* Create a list of files in /var/lib/dpkg/info/<package>.* to keep */ 1245 /* Create a list of files in /var/lib/dpkg/info/<package>.* to keep */
1247 exclude_files = xmalloc(sizeof(char*) * 3); 1246 exclude_files = xmalloc(sizeof(char*) * 3);
1248 exclude_files[0] = xstrdup(conffile_name); 1247 exclude_files[0] = bb_xstrdup(conffile_name);
1249 exclude_files[1] = xmalloc(package_name_length + 27); 1248 exclude_files[1] = xmalloc(package_name_length + 27);
1250 sprintf(exclude_files[1], "/var/lib/dpkg/info/%s.postrm", package_name); 1249 sprintf(exclude_files[1], "/var/lib/dpkg/info/%s.postrm", package_name);
1251 exclude_files[2] = NULL; 1250 exclude_files[2] = NULL;
@@ -1275,7 +1274,7 @@ void purge_package(const unsigned int package_num)
1275 1274
1276 /* run prerm script */ 1275 /* run prerm script */
1277 if (run_package_script(package_name, "prerm") != 0) { 1276 if (run_package_script(package_name, "prerm") != 0) {
1278 error_msg_and_die("script failed, prerm failure"); 1277 bb_error_msg_and_die("script failed, prerm failure");
1279 } 1278 }
1280 1279
1281 /* Create a list of files to remove */ 1280 /* Create a list of files to remove */
@@ -1297,7 +1296,7 @@ void purge_package(const unsigned int package_num)
1297 1296
1298 /* run postrm script */ 1297 /* run postrm script */
1299 if (run_package_script(package_name, "postrm") == -1) { 1298 if (run_package_script(package_name, "postrm") == -1) {
1300 error_msg_and_die("postrm fialure.. set status to what?"); 1299 bb_error_msg_and_die("postrm fialure.. set status to what?");
1301 } 1300 }
1302 1301
1303 /* Change package status */ 1302 /* Change package status */
@@ -1312,7 +1311,7 @@ static archive_handle_t *init_archive_deb_ar(const char *filename)
1312 /* Setup an ar archive handle that refers to the gzip sub archive */ 1311 /* Setup an ar archive handle that refers to the gzip sub archive */
1313 ar_handle = init_handle(); 1312 ar_handle = init_handle();
1314 ar_handle->filter = filter_accept_list_reassign; 1313 ar_handle->filter = filter_accept_list_reassign;
1315 ar_handle->src_fd = xopen(filename, O_RDONLY); 1314 ar_handle->src_fd = bb_xopen(filename, O_RDONLY);
1316 1315
1317 return(ar_handle); 1316 return(ar_handle);
1318} 1317}
@@ -1420,7 +1419,7 @@ static void unpack_package(deb_file_t *deb_file)
1420 /* Run the preinst prior to extracting */ 1419 /* Run the preinst prior to extracting */
1421 if (run_package_script(package_name, "preinst") != 0) { 1420 if (run_package_script(package_name, "preinst") != 0) {
1422 /* when preinst returns exit code != 0 then quit installation process */ 1421 /* when preinst returns exit code != 0 then quit installation process */
1423 error_msg_and_die("subprocess pre-installation script returned error."); 1422 bb_error_msg_and_die("subprocess pre-installation script returned error.");
1424 } 1423 }
1425 1424
1426 /* Extract data.tar.gz to the root directory */ 1425 /* Extract data.tar.gz to the root directory */
@@ -1430,7 +1429,7 @@ static void unpack_package(deb_file_t *deb_file)
1430 1429
1431 /* Create the list file */ 1430 /* Create the list file */
1432 strcat(info_prefix, "list"); 1431 strcat(info_prefix, "list");
1433 out_stream = xfopen(info_prefix, "w"); 1432 out_stream = bb_xfopen(info_prefix, "w");
1434 while (archive_handle->passed) { 1433 while (archive_handle->passed) {
1435 /* blindly skip over the leading '.' */ 1434 /* blindly skip over the leading '.' */
1436 fputs(archive_handle->passed->data + 1, out_stream); 1435 fputs(archive_handle->passed->data + 1, out_stream);
@@ -1457,7 +1456,7 @@ void configure_package(deb_file_t *deb_file)
1457 /* Run the postinst script */ 1456 /* Run the postinst script */
1458 if (run_package_script(package_name, "postinst") != 0) { 1457 if (run_package_script(package_name, "postinst") != 0) {
1459 /* TODO: handle failure gracefully */ 1458 /* TODO: handle failure gracefully */
1460 error_msg_and_die("postrm failure.. set status to what?"); 1459 bb_error_msg_and_die("postrm failure.. set status to what?");
1461 } 1460 }
1462 /* Change status to reflect success */ 1461 /* Change status to reflect success */
1463 set_status(status_num, "install", 1); 1462 set_status(status_num, "install", 1);
@@ -1506,12 +1505,12 @@ int dpkg_main(int argc, char **argv)
1506 dpkg_opt |= dpkg_opt_filename; 1505 dpkg_opt |= dpkg_opt_filename;
1507 break; 1506 break;
1508 default: 1507 default:
1509 show_usage(); 1508 bb_show_usage();
1510 } 1509 }
1511 } 1510 }
1512 /* check for non-otion argument if expected */ 1511 /* check for non-otion argument if expected */
1513 if ((dpkg_opt == 0) || ((argc == optind) && !(dpkg_opt && dpkg_opt_list_installed))) { 1512 if ((dpkg_opt == 0) || ((argc == optind) && !(dpkg_opt && dpkg_opt_list_installed))) {
1514 show_usage(); 1513 bb_show_usage();
1515 } 1514 }
1516 1515
1517/* puts("(Reading database ... xxxxx files and directories installed.)"); */ 1516/* puts("(Reading database ... xxxxx files and directories installed.)"); */
@@ -1538,13 +1537,13 @@ int dpkg_main(int argc, char **argv)
1538 init_archive_deb_control(archive_handle); 1537 init_archive_deb_control(archive_handle);
1539 deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list); 1538 deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list);
1540 if (deb_file[deb_count]->control_file == NULL) { 1539 if (deb_file[deb_count]->control_file == NULL) {
1541 error_msg_and_die("Couldnt extract control file"); 1540 bb_error_msg_and_die("Couldnt extract control file");
1542 } 1541 }
1543 deb_file[deb_count]->filename = xstrdup(argv[optind]); 1542 deb_file[deb_count]->filename = bb_xstrdup(argv[optind]);
1544 package_num = fill_package_struct(deb_file[deb_count]->control_file); 1543 package_num = fill_package_struct(deb_file[deb_count]->control_file);
1545 1544
1546 if (package_num == -1) { 1545 if (package_num == -1) {
1547 error_msg("Invalid control file in %s", argv[optind]); 1546 bb_error_msg("Invalid control file in %s", argv[optind]);
1548 continue; 1547 continue;
1549 } 1548 }
1550 deb_file[deb_count]->package = (unsigned int) package_num; 1549 deb_file[deb_count]->package = (unsigned int) package_num;
@@ -1574,7 +1573,7 @@ int dpkg_main(int argc, char **argv)
1574 search_name_hashtable(argv[optind]), 1573 search_name_hashtable(argv[optind]),
1575 search_name_hashtable("ANY"), VER_ANY); 1574 search_name_hashtable("ANY"), VER_ANY);
1576 if (package_hashtable[deb_file[deb_count]->package] == NULL) { 1575 if (package_hashtable[deb_file[deb_count]->package] == NULL) {
1577 error_msg_and_die("Package %s is uninstalled or unknown\n", argv[optind]); 1576 bb_error_msg_and_die("Package %s is uninstalled or unknown\n", argv[optind]);
1578 } 1577 }
1579 state_status = get_status(search_status_hashtable(name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]), 3); 1578 state_status = get_status(search_status_hashtable(name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]), 3);
1580 1579
@@ -1582,13 +1581,13 @@ int dpkg_main(int argc, char **argv)
1582 if (dpkg_opt & dpkg_opt_remove) { 1581 if (dpkg_opt & dpkg_opt_remove) {
1583 if ((strcmp(name_hashtable[state_status], "not-installed") == 0) || 1582 if ((strcmp(name_hashtable[state_status], "not-installed") == 0) ||
1584 (strcmp(name_hashtable[state_status], "config-files") == 0)) { 1583 (strcmp(name_hashtable[state_status], "config-files") == 0)) {
1585 error_msg_and_die("%s is already removed.", name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]); 1584 bb_error_msg_and_die("%s is already removed.", name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]);
1586 } 1585 }
1587 } 1586 }
1588 else if (dpkg_opt & dpkg_opt_purge) { 1587 else if (dpkg_opt & dpkg_opt_purge) {
1589 /* if package status is "conf-files" then its ok */ 1588 /* if package status is "conf-files" then its ok */
1590 if (strcmp(name_hashtable[state_status], "not-installed") == 0) { 1589 if (strcmp(name_hashtable[state_status], "not-installed") == 0) {
1591 error_msg_and_die("%s is already purged.", name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]); 1590 bb_error_msg_and_die("%s is already purged.", name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]);
1592 } 1591 }
1593 } 1592 }
1594 } 1593 }
@@ -1601,7 +1600,7 @@ int dpkg_main(int argc, char **argv)
1601 /* TODO: check dependencies before removing */ 1600 /* TODO: check dependencies before removing */
1602 if ((dpkg_opt & dpkg_opt_force_ignore_depends) != dpkg_opt_force_ignore_depends) { 1601 if ((dpkg_opt & dpkg_opt_force_ignore_depends) != dpkg_opt_force_ignore_depends) {
1603 if (!check_deps(deb_file, 0, deb_count)) { 1602 if (!check_deps(deb_file, 0, deb_count)) {
1604 error_msg_and_die("Dependency check failed"); 1603 bb_error_msg_and_die("Dependency check failed");
1605 } 1604 }
1606 } 1605 }
1607 1606
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index 2c338227c..2d7383fd7 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -82,15 +82,15 @@ extern int dpkg_deb_main(int argc, char **argv)
82 tar_archive->action_data = data_extract_all; 82 tar_archive->action_data = data_extract_all;
83 break; 83 break;
84 default: 84 default:
85 show_usage(); 85 bb_show_usage();
86 } 86 }
87 } 87 }
88 88
89 if (optind + 2 < argc) { 89 if (optind + 2 < argc) {
90 show_usage(); 90 bb_show_usage();
91 } 91 }
92 92
93 tar_archive->src_fd = ar_archive->src_fd = xopen(argv[optind++], O_RDONLY); 93 tar_archive->src_fd = ar_archive->src_fd = bb_xopen(argv[optind++], O_RDONLY);
94 94
95 /* Workout where to extract the files */ 95 /* Workout where to extract the files */
96 /* 2nd argument is a dir name */ 96 /* 2nd argument is a dir name */
diff --git a/archival/gunzip.c b/archival/gunzip.c
index e9963a8d2..3350da052 100644
--- a/archival/gunzip.c
+++ b/archival/gunzip.c
@@ -82,7 +82,7 @@ extern int gunzip_main(int argc, char **argv)
82 int opt; 82 int opt;
83 83
84 /* if called as zcat */ 84 /* if called as zcat */
85 if (strcmp(applet_name, "zcat") == 0) { 85 if (strcmp(bb_applet_name, "zcat") == 0) {
86 flags |= gunzip_to_stdout; 86 flags |= gunzip_to_stdout;
87 } 87 }
88 88
@@ -100,7 +100,7 @@ extern int gunzip_main(int argc, char **argv)
100 case 'd': /* Used to convert gzip to gunzip. */ 100 case 'd': /* Used to convert gzip to gunzip. */
101 break; 101 break;
102 default: 102 default:
103 show_usage(); /* exit's inside usage */ 103 bb_show_usage(); /* exit's inside usage */
104 } 104 }
105 } 105 }
106 106
@@ -118,29 +118,29 @@ extern int gunzip_main(int argc, char **argv)
118 src_fd = fileno(stdin); 118 src_fd = fileno(stdin);
119 flags |= gunzip_to_stdout; 119 flags |= gunzip_to_stdout;
120 } else { 120 } else {
121 src_fd = xopen(old_path, O_RDONLY); 121 src_fd = bb_xopen(old_path, O_RDONLY);
122 122
123 /* Get the time stamp on the input file. */ 123 /* Get the time stamp on the input file. */
124 if (stat(old_path, &stat_buf) < 0) { 124 if (stat(old_path, &stat_buf) < 0) {
125 error_msg_and_die("Couldn't stat file %s", old_path); 125 bb_error_msg_and_die("Couldn't stat file %s", old_path);
126 } 126 }
127 } 127 }
128 128
129 /* Check that the input is sane. */ 129 /* Check that the input is sane. */
130 if (isatty(src_fd) && ((flags & gunzip_force) == 0)) { 130 if (isatty(src_fd) && ((flags & gunzip_force) == 0)) {
131 error_msg_and_die 131 bb_error_msg_and_die
132 ("compressed data not read from terminal. Use -f to force it."); 132 ("compressed data not read from terminal. Use -f to force it.");
133 } 133 }
134 134
135 /* Set output filename and number */ 135 /* Set output filename and number */
136 if (flags & gunzip_test) { 136 if (flags & gunzip_test) {
137 dst_fd = xopen("/dev/null", O_WRONLY); /* why does test use filenum 2 ? */ 137 dst_fd = bb_xopen("/dev/null", O_WRONLY); /* why does test use filenum 2 ? */
138 } else if (flags & gunzip_to_stdout) { 138 } else if (flags & gunzip_to_stdout) {
139 dst_fd = fileno(stdout); 139 dst_fd = fileno(stdout);
140 } else { 140 } else {
141 char *extension; 141 char *extension;
142 142
143 new_path = xstrdup(old_path); 143 new_path = bb_xstrdup(old_path);
144 144
145 extension = strrchr(new_path, '.'); 145 extension = strrchr(new_path, '.');
146#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS 146#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
@@ -154,11 +154,11 @@ extern int gunzip_main(int argc, char **argv)
154 extension[2] = 'a'; 154 extension[2] = 'a';
155 extension[3] = 'r'; 155 extension[3] = 'r';
156 } else { 156 } else {
157 error_msg_and_die("Invalid extension"); 157 bb_error_msg_and_die("Invalid extension");
158 } 158 }
159 159
160 /* Open output file */ 160 /* Open output file */
161 dst_fd = xopen(new_path, O_WRONLY | O_CREAT); 161 dst_fd = bb_xopen(new_path, O_WRONLY | O_CREAT);
162 162
163 /* Set permissions on the file */ 163 /* Set permissions on the file */
164 chmod(new_path, stat_buf.st_mode); 164 chmod(new_path, stat_buf.st_mode);
@@ -168,10 +168,10 @@ extern int gunzip_main(int argc, char **argv)
168 } 168 }
169 169
170 /* do the decompression, and cleanup */ 170 /* do the decompression, and cleanup */
171 if (xread_char(src_fd) == 0x1f) { 171 if (bb_xread_char(src_fd) == 0x1f) {
172 unsigned char magic2; 172 unsigned char magic2;
173 173
174 magic2 = xread_char(src_fd); 174 magic2 = bb_xread_char(src_fd);
175#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS 175#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
176 if (magic2 == 0x9d) { 176 if (magic2 == 0x9d) {
177 status = uncompress(src_fd, dst_fd); 177 status = uncompress(src_fd, dst_fd);
@@ -181,14 +181,14 @@ extern int gunzip_main(int argc, char **argv)
181 check_header_gzip(src_fd); 181 check_header_gzip(src_fd);
182 status = inflate(src_fd, dst_fd); 182 status = inflate(src_fd, dst_fd);
183 if (status != 0) { 183 if (status != 0) {
184 error_msg_and_die("Error inflating"); 184 bb_error_msg_and_die("Error inflating");
185 } 185 }
186 check_trailer_gzip(src_fd); 186 check_trailer_gzip(src_fd);
187 } else { 187 } else {
188 error_msg_and_die("Invalid magic"); 188 bb_error_msg_and_die("Invalid magic");
189 } 189 }
190 } else { 190 } else {
191 error_msg_and_die("Invalid magic"); 191 bb_error_msg_and_die("Invalid magic");
192 } 192 }
193 193
194 if ((status != EXIT_SUCCESS) && (new_path)) { 194 if ((status != EXIT_SUCCESS) && (new_path)) {
@@ -205,7 +205,7 @@ extern int gunzip_main(int argc, char **argv)
205 205
206 /* delete_path will be NULL if in test mode or from stdin */ 206 /* delete_path will be NULL if in test mode or from stdin */
207 if (delete_path && (unlink(delete_path) == -1)) { 207 if (delete_path && (unlink(delete_path) == -1)) {
208 error_msg_and_die("Couldn't remove %s", delete_path); 208 bb_error_msg_and_die("Couldn't remove %s", delete_path);
209 } 209 }
210 210
211 free(new_path); 211 free(new_path);
diff --git a/archival/gzip.c b/archival/gzip.c
index 971724d74..cabc4aa2f 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -187,7 +187,7 @@ typedef int file_t; /* Do not use stdio */
187 187
188/* Diagnostic functions */ 188/* Diagnostic functions */
189#ifdef DEBUG 189#ifdef DEBUG
190# define Assert(cond,msg) {if(!(cond)) error_msg(msg);} 190# define Assert(cond,msg) {if(!(cond)) bb_error_msg(msg);}
191# define Trace(x) fprintf x 191# define Trace(x) fprintf x
192# define Tracev(x) {if (verbose) fprintf x ;} 192# define Tracev(x) {if (verbose) fprintf x ;}
193# define Tracevv(x) {if (verbose>1) fprintf x ;} 193# define Tracevv(x) {if (verbose>1) fprintf x ;}
@@ -352,10 +352,10 @@ static void clear_bufs(void)
352 bytes_in = 0L; 352 bytes_in = 0L;
353} 353}
354 354
355static void write_error_msg(void) 355static void write_bb_error_msg(void)
356{ 356{
357 fputc('\n', stderr); 357 fputc('\n', stderr);
358 perror_msg(""); 358 bb_perror_nomsg();
359 abort_gzip(); 359 abort_gzip();
360} 360}
361 361
@@ -369,7 +369,7 @@ static void write_buf(int fd, void *buf, unsigned cnt)
369 369
370 while ((n = write(fd, buf, cnt)) != cnt) { 370 while ((n = write(fd, buf, cnt)) != cnt) {
371 if (n == (unsigned) (-1)) { 371 if (n == (unsigned) (-1)) {
372 write_error_msg(); 372 write_bb_error_msg();
373 } 373 }
374 cnt -= n; 374 cnt -= n;
375 buf = (void *) ((char *) buf + n); 375 buf = (void *) ((char *) buf + n);
@@ -977,11 +977,11 @@ static void check_match(IPos start, IPos match, int length)
977 /* check that the match is indeed a match */ 977 /* check that the match is indeed a match */
978 if (memcmp((char *) window + match, 978 if (memcmp((char *) window + match,
979 (char *) window + start, length) != EQUAL) { 979 (char *) window + start, length) != EQUAL) {
980 error_msg(" start %d, match %d, length %d", start, match, length); 980 bb_error_msg(" start %d, match %d, length %d", start, match, length);
981 error_msg("invalid match"); 981 bb_error_msg("invalid match");
982 } 982 }
983 if (verbose > 1) { 983 if (verbose > 1) {
984 error_msg("\\[%d,%d]", start - match, length); 984 bb_error_msg("\\[%d,%d]", start - match, length);
985 do { 985 do {
986 putc(window[start++], stderr); 986 putc(window[start++], stderr);
987 } while (--length != 0); 987 } while (--length != 0);
@@ -1232,7 +1232,7 @@ int gzip_main(int argc, char **argv)
1232 return gunzip_main(argc, argv); 1232 return gunzip_main(argc, argv);
1233#endif 1233#endif
1234 default: 1234 default:
1235 show_usage(); 1235 bb_show_usage();
1236 } 1236 }
1237 } 1237 }
1238 1238
@@ -1282,7 +1282,7 @@ int gzip_main(int argc, char **argv)
1282 } else { 1282 } else {
1283 inFileNum = open(argv[i], O_RDONLY); 1283 inFileNum = open(argv[i], O_RDONLY);
1284 if (inFileNum < 0 || fstat(inFileNum, &statBuf) < 0) 1284 if (inFileNum < 0 || fstat(inFileNum, &statBuf) < 0)
1285 perror_msg_and_die("%s", argv[i]); 1285 bb_perror_msg_and_die("%s", argv[i]);
1286 time_stamp = statBuf.st_ctime; 1286 time_stamp = statBuf.st_ctime;
1287 ifile_size = statBuf.st_size; 1287 ifile_size = statBuf.st_size;
1288 1288
@@ -1299,7 +1299,7 @@ int gzip_main(int argc, char **argv)
1299 outFileNum = open(path, O_RDWR | O_CREAT | O_EXCL); 1299 outFileNum = open(path, O_RDWR | O_CREAT | O_EXCL);
1300#endif 1300#endif
1301 if (outFileNum < 0) { 1301 if (outFileNum < 0) {
1302 perror_msg("%s", path); 1302 bb_perror_msg("%s", path);
1303 free(path); 1303 free(path);
1304 continue; 1304 continue;
1305 } 1305 }
@@ -1311,7 +1311,7 @@ int gzip_main(int argc, char **argv)
1311 } 1311 }
1312 1312
1313 if (path == NULL && isatty(outFileNum) && force == 0) { 1313 if (path == NULL && isatty(outFileNum) && force == 0) {
1314 error_msg 1314 bb_error_msg
1315 ("compressed data not written to a terminal. Use -f to force compression."); 1315 ("compressed data not written to a terminal. Use -f to force compression.");
1316 free(path); 1316 free(path);
1317 continue; 1317 continue;
@@ -1330,7 +1330,7 @@ int gzip_main(int argc, char **argv)
1330 delFileName = path; 1330 delFileName = path;
1331 1331
1332 if (unlink(delFileName) < 0) 1332 if (unlink(delFileName) < 0)
1333 perror_msg("%s", delFileName); 1333 bb_perror_msg("%s", delFileName);
1334 } 1334 }
1335 1335
1336 free(path); 1336 free(path);
@@ -1655,7 +1655,7 @@ static void set_file_type(void);
1655 1655
1656#else /* DEBUG */ 1656#else /* DEBUG */
1657# define send_code(c, tree) \ 1657# define send_code(c, tree) \
1658 { if (verbose>1) error_msg("\ncd %3d ",(c)); \ 1658 { if (verbose>1) bb_error_msg("\ncd %3d ",(c)); \
1659 send_bits(tree[c].Code, tree[c].Len); } 1659 send_bits(tree[c].Code, tree[c].Len); }
1660#endif 1660#endif
1661 1661
@@ -2035,7 +2035,7 @@ static void build_tree(tree_desc * desc)
2035 tree[n].Dad = tree[m].Dad = (ush) node; 2035 tree[n].Dad = tree[m].Dad = (ush) node;
2036#ifdef DUMP_BL_TREE 2036#ifdef DUMP_BL_TREE
2037 if (tree == bl_tree) { 2037 if (tree == bl_tree) {
2038 error_msg("\nnode %d(%d), sons %d(%d) %d(%d)", 2038 bb_error_msg("\nnode %d(%d), sons %d(%d) %d(%d)",
2039 node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); 2039 node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
2040 } 2040 }
2041#endif 2041#endif
@@ -2273,7 +2273,7 @@ static ulg flush_block(char *buf, ulg stored_len, int eof)
2273 if (stored_len <= opt_lenb && eof && compressed_len == 0L && seekable()) { 2273 if (stored_len <= opt_lenb && eof && compressed_len == 0L && seekable()) {
2274 /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ 2274 /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
2275 if (buf == (char *) 0) 2275 if (buf == (char *) 0)
2276 error_msg("block vanished"); 2276 bb_error_msg("block vanished");
2277 2277
2278 copy_block(buf, (unsigned) stored_len, 0); /* without header */ 2278 copy_block(buf, (unsigned) stored_len, 0); /* without header */
2279 compressed_len = stored_len << 3; 2279 compressed_len = stored_len << 3;
@@ -2442,7 +2442,7 @@ static void set_file_type()
2442 bin_freq += dyn_ltree[n++].Freq; 2442 bin_freq += dyn_ltree[n++].Freq;
2443 *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII; 2443 *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
2444 if (*file_type == BINARY && translate_eol) { 2444 if (*file_type == BINARY && translate_eol) {
2445 error_msg("-l used on binary file"); 2445 bb_error_msg("-l used on binary file");
2446 } 2446 }
2447} 2447}
2448 2448
diff --git a/archival/libunarchive/archive_copy_file.c b/archival/libunarchive/archive_copy_file.c
index faa8059ef..675bc6ffe 100644
--- a/archival/libunarchive/archive_copy_file.c
+++ b/archival/libunarchive/archive_copy_file.c
@@ -35,7 +35,7 @@ extern void archive_copy_file(const archive_handle_t *archive_handle, const int
35 size = archive_xread(archive_handle, buffer, size); 35 size = archive_xread(archive_handle, buffer, size);
36 36
37 if (write(dst_fd, buffer, size) != size) { 37 if (write(dst_fd, buffer, size) != size) {
38 error_msg_and_die ("Short write"); 38 bb_error_msg_and_die ("Short write");
39 } 39 }
40 chunksize -= size; 40 chunksize -= size;
41 } 41 }
diff --git a/archival/libunarchive/archive_xread.c b/archival/libunarchive/archive_xread.c
index 7fde4c0b1..0b29dbfb9 100644
--- a/archival/libunarchive/archive_xread.c
+++ b/archival/libunarchive/archive_xread.c
@@ -26,7 +26,7 @@ extern ssize_t archive_xread(const archive_handle_t *archive_handle, unsigned ch
26 26
27 size = archive_handle->read(archive_handle->src_fd, buf, count); 27 size = archive_handle->read(archive_handle->src_fd, buf, count);
28 if (size == -1) { 28 if (size == -1) {
29 perror_msg_and_die("Read error"); 29 bb_perror_msg_and_die("Read error");
30 } 30 }
31 31
32 return(size); 32 return(size);
diff --git a/archival/libunarchive/archive_xread_all.c b/archival/libunarchive/archive_xread_all.c
index ef8cc0141..cfe046b27 100644
--- a/archival/libunarchive/archive_xread_all.c
+++ b/archival/libunarchive/archive_xread_all.c
@@ -26,7 +26,7 @@ extern void archive_xread_all(const archive_handle_t *archive_handle, void *buf,
26 26
27 size = archive_xread(archive_handle, buf, count); 27 size = archive_xread(archive_handle, buf, count);
28 if (size != count) { 28 if (size != count) {
29 error_msg_and_die("Short read"); 29 bb_error_msg_and_die("Short read");
30 } 30 }
31 return; 31 return;
32} 32}
diff --git a/archival/libunarchive/archive_xread_all_eof.c b/archival/libunarchive/archive_xread_all_eof.c
index 3cfbbd8d1..23719cd7b 100644
--- a/archival/libunarchive/archive_xread_all_eof.c
+++ b/archival/libunarchive/archive_xread_all_eof.c
@@ -26,7 +26,7 @@ extern ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned
26 26
27 size = archive_xread(archive_handle, buf, count); 27 size = archive_xread(archive_handle, buf, count);
28 if ((size != 0) && (size != count)) { 28 if ((size != 0) && (size != count)) {
29 perror_msg_and_die("Short read, read %d of %d", size, count); 29 bb_perror_msg_and_die("Short read, read %d of %d", size, count);
30 } 30 }
31 return(size); 31 return(size);
32} 32}
diff --git a/archival/libunarchive/check_header_gzip.c b/archival/libunarchive/check_header_gzip.c
index d661df7cc..13832c240 100644
--- a/archival/libunarchive/check_header_gzip.c
+++ b/archival/libunarchive/check_header_gzip.c
@@ -15,11 +15,11 @@ extern void check_header_gzip(int src_fd)
15 } formated; 15 } formated;
16 } header; 16 } header;
17 17
18 xread_all(src_fd, header.raw, 8); 18 bb_xread_all(src_fd, header.raw, 8);
19 19
20 /* Check the compression method */ 20 /* Check the compression method */
21 if (header.formated.method != 8) { 21 if (header.formated.method != 8) {
22 error_msg_and_die("Unknown compression method %d", 22 bb_error_msg_and_die("Unknown compression method %d",
23 header.formated.method); 23 header.formated.method);
24 } 24 }
25 25
@@ -27,10 +27,10 @@ extern void check_header_gzip(int src_fd)
27 /* bit 2 set: extra field present */ 27 /* bit 2 set: extra field present */
28 unsigned char extra_short; 28 unsigned char extra_short;
29 29
30 extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8); 30 extra_short = bb_xread_char(src_fd) + (bb_xread_char(src_fd) << 8);
31 while (extra_short > 0) { 31 while (extra_short > 0) {
32 /* Ignore extra field */ 32 /* Ignore extra field */
33 xread_char(src_fd); 33 bb_xread_char(src_fd);
34 extra_short--; 34 extra_short--;
35 } 35 }
36 } 36 }
@@ -38,19 +38,19 @@ extern void check_header_gzip(int src_fd)
38 /* Discard original name if any */ 38 /* Discard original name if any */
39 if (header.formated.flags & 0x08) { 39 if (header.formated.flags & 0x08) {
40 /* bit 3 set: original file name present */ 40 /* bit 3 set: original file name present */
41 while(xread_char(src_fd) != 0); 41 while(bb_xread_char(src_fd) != 0);
42 } 42 }
43 43
44 /* Discard file comment if any */ 44 /* Discard file comment if any */
45 if (header.formated.flags & 0x10) { 45 if (header.formated.flags & 0x10) {
46 /* bit 4 set: file comment present */ 46 /* bit 4 set: file comment present */
47 while(xread_char(src_fd) != 0); 47 while(bb_xread_char(src_fd) != 0);
48 } 48 }
49 49
50 /* Read the header checksum */ 50 /* Read the header checksum */
51 if (header.formated.flags & 0x02) { 51 if (header.formated.flags & 0x02) {
52 xread_char(src_fd); 52 bb_xread_char(src_fd);
53 xread_char(src_fd); 53 bb_xread_char(src_fd);
54 } 54 }
55 55
56 return; 56 return;
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c
index 1eb8bb388..77b4de593 100644
--- a/archival/libunarchive/data_extract_all.c
+++ b/archival/libunarchive/data_extract_all.c
@@ -34,8 +34,8 @@ extern void data_extract_all(archive_handle_t *archive_handle)
34 int res; 34 int res;
35 35
36 if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) { 36 if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
37 char *name = xstrdup(file_header->name); 37 char *name = bb_xstrdup(file_header->name);
38 make_directory (dirname(name), 0777, FILEUTILS_RECUR); 38 bb_make_directory (dirname(name), 0777, FILEUTILS_RECUR);
39 free(name); 39 free(name);
40 } 40 }
41 41
@@ -47,13 +47,13 @@ extern void data_extract_all(archive_handle_t *archive_handle)
47 /* hard link */ 47 /* hard link */
48 res = link(file_header->link_name, file_header->name); 48 res = link(file_header->link_name, file_header->name);
49 if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { 49 if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
50 perror_msg("Couldnt create hard link"); 50 bb_perror_msg("Couldnt create hard link");
51 } 51 }
52 } else 52 } else
53#endif 53#endif
54 { 54 {
55 /* Regular file */ 55 /* Regular file */
56 dst_fd = xopen(file_header->name, O_WRONLY | O_CREAT); 56 dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT);
57 archive_copy_file(archive_handle, dst_fd); 57 archive_copy_file(archive_handle, dst_fd);
58 close(dst_fd); 58 close(dst_fd);
59 } 59 }
@@ -63,7 +63,7 @@ extern void data_extract_all(archive_handle_t *archive_handle)
63 unlink(file_header->name); 63 unlink(file_header->name);
64 res = mkdir(file_header->name, file_header->mode); 64 res = mkdir(file_header->name, file_header->mode);
65 if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { 65 if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
66 perror_msg("extract_archive: %s", file_header->name); 66 bb_perror_msg("extract_archive: %s", file_header->name);
67 } 67 }
68 break; 68 break;
69 case S_IFLNK: 69 case S_IFLNK:
@@ -71,7 +71,7 @@ extern void data_extract_all(archive_handle_t *archive_handle)
71 unlink(file_header->name); 71 unlink(file_header->name);
72 res = symlink(file_header->link_name, file_header->name); 72 res = symlink(file_header->link_name, file_header->name);
73 if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { 73 if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
74 perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name); 74 bb_perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name);
75 } 75 }
76 break; 76 break;
77 case S_IFSOCK: 77 case S_IFSOCK:
@@ -81,11 +81,11 @@ extern void data_extract_all(archive_handle_t *archive_handle)
81 unlink(file_header->name); 81 unlink(file_header->name);
82 res = mknod(file_header->name, file_header->mode, file_header->device); 82 res = mknod(file_header->name, file_header->mode, file_header->device);
83 if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { 83 if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
84 perror_msg("Cannot create node %s", file_header->name); 84 bb_perror_msg("Cannot create node %s", file_header->name);
85 } 85 }
86 break; 86 break;
87 default: 87 default:
88 error_msg_and_die("Unrecognised file type"); 88 bb_error_msg_and_die("Unrecognised file type");
89 } 89 }
90 90
91 chmod(file_header->name, file_header->mode); 91 chmod(file_header->name, file_header->mode);
diff --git a/archival/libunarchive/decompress_bunzip2.c b/archival/libunarchive/decompress_bunzip2.c
index 4b611b833..0164b77e0 100644
--- a/archival/libunarchive/decompress_bunzip2.c
+++ b/archival/libunarchive/decompress_bunzip2.c
@@ -1548,7 +1548,7 @@ extern ssize_t read_bz2(int fd, void *buf, size_t count)
1548 1548
1549 while (1) { 1549 while (1) {
1550 if (bzf->strm.avail_in == 0) { 1550 if (bzf->strm.avail_in == 0) {
1551 n = xread(bzf->fd, bzf->buf, BZ_MAX_UNUSED); 1551 n = bb_xread(bzf->fd, bzf->buf, BZ_MAX_UNUSED);
1552 if (n == 0) { 1552 if (n == 0) {
1553 break; 1553 break;
1554 } 1554 }
@@ -1560,7 +1560,7 @@ extern ssize_t read_bz2(int fd, void *buf, size_t count)
1560 ret = BZ2_bzDecompress(&(bzf->strm)); 1560 ret = BZ2_bzDecompress(&(bzf->strm));
1561 1561
1562 if ((ret != BZ_OK) && (ret != BZ_STREAM_END)) { 1562 if ((ret != BZ_OK) && (ret != BZ_STREAM_END)) {
1563 error_msg_and_die("Error decompressing"); 1563 bb_error_msg_and_die("Error decompressing");
1564 } 1564 }
1565 1565
1566 if (ret == BZ_STREAM_END) { 1566 if (ret == BZ_STREAM_END) {
@@ -1628,12 +1628,12 @@ extern unsigned char uncompressStream(int src_fd, int dst_fd)
1628 while (bzerr == BZ_OK) { 1628 while (bzerr == BZ_OK) {
1629 nread = read_bz2(src_fd, obuf, 5000); 1629 nread = read_bz2(src_fd, obuf, 5000);
1630 if (bzerr == BZ_DATA_ERROR_MAGIC) { 1630 if (bzerr == BZ_DATA_ERROR_MAGIC) {
1631 error_msg_and_die("invalid magic"); 1631 bb_error_msg_and_die("invalid magic");
1632 } 1632 }
1633 if (((bzerr == BZ_OK) || (bzerr == BZ_STREAM_END)) && (nread > 0)) { 1633 if (((bzerr == BZ_OK) || (bzerr == BZ_STREAM_END)) && (nread > 0)) {
1634 if (write(dst_fd, obuf, nread) != nread) { 1634 if (write(dst_fd, obuf, nread) != nread) {
1635 BZ2_bzReadClose(); 1635 BZ2_bzReadClose();
1636 perror_msg_and_die("Couldnt write to file"); 1636 bb_perror_msg_and_die("Couldnt write to file");
1637 } 1637 }
1638 } 1638 }
1639 } 1639 }
diff --git a/archival/libunarchive/decompress_uncompress.c b/archival/libunarchive/decompress_uncompress.c
index 192e98126..9851ca39d 100644
--- a/archival/libunarchive/decompress_uncompress.c
+++ b/archival/libunarchive/decompress_uncompress.c
@@ -121,14 +121,14 @@ extern int uncompress(int fd_in, int fd_out)
121 121
122 insize = 0; 122 insize = 0;
123 123
124 inbuf[0] = xread_char(fd_in); 124 inbuf[0] = bb_xread_char(fd_in);
125 125
126 maxbits = inbuf[0] & BIT_MASK; 126 maxbits = inbuf[0] & BIT_MASK;
127 block_mode = inbuf[0] & BLOCK_MODE; 127 block_mode = inbuf[0] & BLOCK_MODE;
128 maxmaxcode = MAXCODE(maxbits); 128 maxmaxcode = MAXCODE(maxbits);
129 129
130 if (maxbits > BITS) { 130 if (maxbits > BITS) {
131 error_msg("compressed with %d bits, can only handle %d bits", maxbits, 131 bb_error_msg("compressed with %d bits, can only handle %d bits", maxbits,
132 BITS); 132 BITS);
133 return -1; 133 return -1;
134 } 134 }
@@ -227,11 +227,11 @@ extern int uncompress(int fd_in, int fd_out)
227 posbits -= n_bits; 227 posbits -= n_bits;
228 p = &inbuf[posbits >> 3]; 228 p = &inbuf[posbits >> 3];
229 229
230 error_msg 230 bb_error_msg
231 ("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)", 231 ("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)",
232 insize, posbits, p[-1], p[0], p[1], p[2], p[3], 232 insize, posbits, p[-1], p[0], p[1], p[2], p[3],
233 (posbits & 07)); 233 (posbits & 07));
234 error_msg("uncompress: corrupt input"); 234 bb_error_msg("uncompress: corrupt input");
235 return -1; 235 return -1;
236 } 236 }
237 237
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c
index 3a7334ce9..2401cf831 100644
--- a/archival/libunarchive/decompress_unzip.c
+++ b/archival/libunarchive/decompress_unzip.c
@@ -150,7 +150,7 @@ static void fill_bytebuffer(void)
150 /* Leave the first 4 bytes empty so we can always unwind the bitbuffer 150 /* Leave the first 4 bytes empty so we can always unwind the bitbuffer
151 * to the front of the bytebuffer, leave 4 bytes free at end of tail 151 * to the front of the bytebuffer, leave 4 bytes free at end of tail
152 * so we can easily top up buffer in check_trailer_gzip() */ 152 * so we can easily top up buffer in check_trailer_gzip() */
153 bytebuffer_size = 4 + xread(gunzip_src_fd, &bytebuffer[4], BYTEBUFFER_MAX - 8); 153 bytebuffer_size = 4 + bb_xread(gunzip_src_fd, &bytebuffer[4], BYTEBUFFER_MAX - 8);
154 bytebuffer_offset = 4; 154 bytebuffer_offset = 4;
155 } 155 }
156} 156}
@@ -448,7 +448,7 @@ static int inflate_codes(huft_t * my_tl, huft_t * my_td, const unsigned int my_b
448 if ((e = (t = tl + ((unsigned) b & ml))->e) > 16) 448 if ((e = (t = tl + ((unsigned) b & ml))->e) > 16)
449 do { 449 do {
450 if (e == 99) { 450 if (e == 99) {
451 error_msg_and_die("inflate_codes error 1");; 451 bb_error_msg_and_die("inflate_codes error 1");;
452 } 452 }
453 b >>= t->b; 453 b >>= t->b;
454 k -= t->b; 454 k -= t->b;
@@ -484,7 +484,7 @@ static int inflate_codes(huft_t * my_tl, huft_t * my_td, const unsigned int my_b
484 if ((e = (t = td + ((unsigned) b & md))->e) > 16) 484 if ((e = (t = td + ((unsigned) b & md))->e) > 16)
485 do { 485 do {
486 if (e == 99) 486 if (e == 99)
487 error_msg_and_die("inflate_codes error 2");; 487 bb_error_msg_and_die("inflate_codes error 2");;
488 b >>= t->b; 488 b >>= t->b;
489 k -= t->b; 489 k -= t->b;
490 e -= 16; 490 e -= 16;
@@ -821,7 +821,7 @@ static int inflate_block(int *e)
821 821
822 if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0) { 822 if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0) {
823 if (i == 1) { 823 if (i == 1) {
824 error_msg_and_die("Incomplete literal tree"); 824 bb_error_msg_and_die("Incomplete literal tree");
825 huft_free(tl); 825 huft_free(tl);
826 } 826 }
827 return i; /* incomplete code set */ 827 return i; /* incomplete code set */
@@ -830,7 +830,7 @@ static int inflate_block(int *e)
830 bd = dbits; 830 bd = dbits;
831 if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0) { 831 if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0) {
832 if (i == 1) { 832 if (i == 1) {
833 error_msg_and_die("incomplete distance tree"); 833 bb_error_msg_and_die("incomplete distance tree");
834 huft_free(td); 834 huft_free(td);
835 } 835 }
836 huft_free(tl); 836 huft_free(tl);
@@ -846,7 +846,7 @@ static int inflate_block(int *e)
846 } 846 }
847 default: 847 default:
848 /* bad block type */ 848 /* bad block type */
849 error_msg_and_die("bad block type %d\n", t); 849 bb_error_msg_and_die("bad block type %d\n", t);
850 } 850 }
851} 851}
852 852
@@ -884,7 +884,7 @@ static int inflate_get_next_window(void)
884 break; 884 break;
885 case -2: ret = inflate_codes(0,0,0,0,0); 885 case -2: ret = inflate_codes(0,0,0,0,0);
886 break; 886 break;
887 default: error_msg_and_die("inflate error %d", method); 887 default: bb_error_msg_and_die("inflate error %d", method);
888 } 888 }
889 889
890 if (ret == 1) { 890 if (ret == 1) {
@@ -975,16 +975,16 @@ extern void GZ_gzReadClose(void)
975 ssize_t nread, nwrote; 975 ssize_t nread, nwrote;
976 976
977 GZ_gzReadOpen(in, 0, 0); 977 GZ_gzReadOpen(in, 0, 0);
978 while(1) { // Robbed from copyfd.c 978 while(1) { // Robbed from bb_copyfd.c
979 nread = read_gz(in, buf, sizeof(buf)); 979 nread = read_gz(in, buf, sizeof(buf));
980 if (nread == 0) break; // no data to write 980 if (nread == 0) break; // no data to write
981 else if (nread == -1) { 981 else if (nread == -1) {
982 perror_msg("read"); 982 bb_perror_msg("read");
983 return -1; 983 return -1;
984 } 984 }
985 nwrote = full_write(out, buf, nread); 985 nwrote = bb_full_write(out, buf, nread);
986 if (nwrote == -1) { 986 if (nwrote == -1) {
987 perror_msg("write"); 987 bb_perror_msg("write");
988 return -1; 988 return -1;
989 } 989 }
990 } 990 }
@@ -998,9 +998,9 @@ extern int inflate(int in, int out)
998 GZ_gzReadOpen(in, 0, 0); 998 GZ_gzReadOpen(in, 0, 0);
999 while(1) { 999 while(1) {
1000 int ret = inflate_get_next_window(); 1000 int ret = inflate_get_next_window();
1001 nwrote = full_write(out, gunzip_window, gunzip_outbuf_count); 1001 nwrote = bb_full_write(out, gunzip_window, gunzip_outbuf_count);
1002 if (nwrote == -1) { 1002 if (nwrote == -1) {
1003 perror_msg("write"); 1003 bb_perror_msg("write");
1004 return -1; 1004 return -1;
1005 } 1005 }
1006 if (ret == 0) break; 1006 if (ret == 0) break;
@@ -1017,7 +1017,7 @@ extern void check_trailer_gzip(int src_fd)
1017 /* top up the input buffer with the rest of the trailer */ 1017 /* top up the input buffer with the rest of the trailer */
1018 count = bytebuffer_size - bytebuffer_offset; 1018 count = bytebuffer_size - bytebuffer_offset;
1019 if (count < 8) { 1019 if (count < 8) {
1020 xread_all(src_fd, &bytebuffer[bytebuffer_size], 8 - count); 1020 bb_xread_all(src_fd, &bytebuffer[bytebuffer_size], 8 - count);
1021 bytebuffer_size += 8 - count; 1021 bytebuffer_size += 8 - count;
1022 } 1022 }
1023 for (count = 0; count != 4; count++) { 1023 for (count = 0; count != 4; count++) {
@@ -1027,14 +1027,14 @@ extern void check_trailer_gzip(int src_fd)
1027 1027
1028 /* Validate decompression - crc */ 1028 /* Validate decompression - crc */
1029 if (stored_crc != (gunzip_crc ^ 0xffffffffL)) { 1029 if (stored_crc != (gunzip_crc ^ 0xffffffffL)) {
1030 error_msg_and_die("crc error"); 1030 bb_error_msg_and_die("crc error");
1031 } 1031 }
1032 1032
1033 /* Validate decompression - size */ 1033 /* Validate decompression - size */
1034 if (gunzip_bytes_out != 1034 if (gunzip_bytes_out !=
1035 (bytebuffer[bytebuffer_offset] | (bytebuffer[bytebuffer_offset+1] << 8) | 1035 (bytebuffer[bytebuffer_offset] | (bytebuffer[bytebuffer_offset+1] << 8) |
1036 (bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24))) { 1036 (bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24))) {
1037 error_msg_and_die("Incorrect length, but crc is correct"); 1037 bb_error_msg_and_die("Incorrect length, but crc is correct");
1038 } 1038 }
1039 1039
1040} 1040}
diff --git a/archival/libunarchive/get_header_ar.c b/archival/libunarchive/get_header_ar.c
index 1e0e6c12d..6c576a8da 100644
--- a/archival/libunarchive/get_header_ar.c
+++ b/archival/libunarchive/get_header_ar.c
@@ -41,7 +41,7 @@ extern char get_header_ar(archive_handle_t *archive_handle)
41 static unsigned int ar_long_name_size; 41 static unsigned int ar_long_name_size;
42#endif 42#endif
43 43
44 /* dont use xread as we want to handle the error ourself */ 44 /* dont use bb_xread as we want to handle the error ourself */
45 if (read(archive_handle->src_fd, ar.raw, 60) != 60) { 45 if (read(archive_handle->src_fd, ar.raw, 60) != 60) {
46 /* End Of File */ 46 /* End Of File */
47 return(EXIT_FAILURE); 47 return(EXIT_FAILURE);
@@ -51,14 +51,14 @@ extern char get_header_ar(archive_handle_t *archive_handle)
51 if (ar.raw[0] == '\n') { 51 if (ar.raw[0] == '\n') {
52 /* fix up the header, we started reading 1 byte too early */ 52 /* fix up the header, we started reading 1 byte too early */
53 memmove(ar.raw, &ar.raw[1], 59); 53 memmove(ar.raw, &ar.raw[1], 59);
54 ar.raw[59] = xread_char(archive_handle->src_fd); 54 ar.raw[59] = bb_xread_char(archive_handle->src_fd);
55 archive_handle->offset++; 55 archive_handle->offset++;
56 } 56 }
57 archive_handle->offset += 60; 57 archive_handle->offset += 60;
58 58
59 /* align the headers based on the header magic */ 59 /* align the headers based on the header magic */
60 if ((ar.formated.magic[0] != '`') || (ar.formated.magic[1] != '\n')) { 60 if ((ar.formated.magic[0] != '`') || (ar.formated.magic[1] != '\n')) {
61 error_msg_and_die("Invalid ar header"); 61 bb_error_msg_and_die("Invalid ar header");
62 } 62 }
63 63
64 typed->mode = strtol(ar.formated.mode, NULL, 8); 64 typed->mode = strtol(ar.formated.mode, NULL, 8);
@@ -76,7 +76,7 @@ extern char get_header_ar(archive_handle_t *archive_handle)
76 * in static variable long_names for use in future entries */ 76 * in static variable long_names for use in future entries */
77 ar_long_name_size = typed->size; 77 ar_long_name_size = typed->size;
78 ar_long_names = xmalloc(ar_long_name_size); 78 ar_long_names = xmalloc(ar_long_name_size);
79 xread_all(archive_handle->src_fd, ar_long_names, ar_long_name_size); 79 bb_xread_all(archive_handle->src_fd, ar_long_names, ar_long_name_size);
80 archive_handle->offset += ar_long_name_size; 80 archive_handle->offset += ar_long_name_size;
81 /* This ar entries data section only contained filenames for other records 81 /* This ar entries data section only contained filenames for other records
82 * they are stored in the static ar_long_names for future reference */ 82 * they are stored in the static ar_long_names for future reference */
@@ -90,16 +90,16 @@ extern char get_header_ar(archive_handle_t *archive_handle)
90 (saved in variable long_name) that conatains the real filename */ 90 (saved in variable long_name) that conatains the real filename */
91 const unsigned int long_offset = atoi(&ar.formated.name[1]); 91 const unsigned int long_offset = atoi(&ar.formated.name[1]);
92 if (long_offset >= ar_long_name_size) { 92 if (long_offset >= ar_long_name_size) {
93 error_msg_and_die("Cant resolve long filename"); 93 bb_error_msg_and_die("Cant resolve long filename");
94 } 94 }
95 typed->name = xstrdup(ar_long_names + long_offset); 95 typed->name = bb_xstrdup(ar_long_names + long_offset);
96 } 96 }
97#else 97#else
98 error_msg_and_die("long filenames not supported"); 98 bb_error_msg_and_die("long filenames not supported");
99#endif 99#endif
100 } else { 100 } else {
101 /* short filenames */ 101 /* short filenames */
102 typed->name = xstrndup(ar.formated.name, 16); 102 typed->name = bb_xstrndup(ar.formated.name, 16);
103 } 103 }
104 104
105 typed->name[strcspn(typed->name, " /")] = '\0'; 105 typed->name[strcspn(typed->name, " /")] = '\0';
diff --git a/archival/libunarchive/get_header_cpio.c b/archival/libunarchive/get_header_cpio.c
index ea0857840..975e2a4bd 100644
--- a/archival/libunarchive/get_header_cpio.c
+++ b/archival/libunarchive/get_header_cpio.c
@@ -46,7 +46,7 @@ extern char get_header_cpio(archive_handle_t *archive_handle)
46 oldtmp = NULL; 46 oldtmp = NULL;
47 47
48 while (tmp) { 48 while (tmp) {
49 error_msg_and_die("need to fix this\n"); 49 bb_error_msg_and_die("need to fix this\n");
50 if (tmp->entry->link_name) { /* Found a hardlink ready to be extracted */ 50 if (tmp->entry->link_name) { /* Found a hardlink ready to be extracted */
51 file_header = tmp->entry; 51 file_header = tmp->entry;
52 if (oldtmp) { 52 if (oldtmp) {
@@ -78,11 +78,11 @@ extern char get_header_cpio(archive_handle_t *archive_handle)
78 cpio_header[2], 78 cpio_header[2],
79 cpio_header[3], 79 cpio_header[3],
80 cpio_header[4]); 80 cpio_header[4]);
81 error_msg_and_die("Unsupported cpio format"); 81 bb_error_msg_and_die("Unsupported cpio format");
82 } 82 }
83 83
84 if ((cpio_header[5] != '1') && (cpio_header[5] != '2')) { 84 if ((cpio_header[5] != '1') && (cpio_header[5] != '2')) {
85 error_msg_and_die("Unsupported cpio format, use newc or crc"); 85 bb_error_msg_and_die("Unsupported cpio format, use newc or crc");
86 } 86 }
87 87
88 { 88 {
@@ -109,7 +109,7 @@ extern char get_header_cpio(archive_handle_t *archive_handle)
109 hardlinks_t *tmp = saved_hardlinks; 109 hardlinks_t *tmp = saved_hardlinks;
110 hardlinks_t *oldtmp = NULL; 110 hardlinks_t *oldtmp = NULL;
111 while (tmp) { 111 while (tmp) {
112 error_msg("%s not created: cannot resolve hardlink", tmp->entry->name); 112 bb_error_msg("%s not created: cannot resolve hardlink", tmp->entry->name);
113 oldtmp = tmp; 113 oldtmp = tmp;
114 tmp = tmp->next; 114 tmp = tmp->next;
115 free (oldtmp->entry->name); 115 free (oldtmp->entry->name);
@@ -142,13 +142,13 @@ extern char get_header_cpio(archive_handle_t *archive_handle)
142 pending_hardlinks = 1; 142 pending_hardlinks = 1;
143 while (tmp) { 143 while (tmp) {
144 if (tmp->inode == inode) { 144 if (tmp->inode == inode) {
145 tmp->entry->link_name = xstrdup(file_header->name); 145 tmp->entry->link_name = bb_xstrdup(file_header->name);
146 nlink--; 146 nlink--;
147 } 147 }
148 tmp = tmp->next; 148 tmp = tmp->next;
149 } 149 }
150 if (nlink > 1) { 150 if (nlink > 1) {
151 error_msg("error resolving hardlink: did you create the archive with GNU cpio 2.0-2.2?"); 151 bb_error_msg("error resolving hardlink: did you create the archive with GNU cpio 2.0-2.2?");
152 } 152 }
153 } 153 }
154 } 154 }
@@ -165,11 +165,11 @@ extern char get_header_cpio(archive_handle_t *archive_handle)
165 if ((archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) || (statbuf.st_mtime < file_header->mtime)) { 165 if ((archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) || (statbuf.st_mtime < file_header->mtime)) {
166 /* Remove file if flag set or its older than the file to be extracted */ 166 /* Remove file if flag set or its older than the file to be extracted */
167 if (unlink(file_header->name) == -1) { 167 if (unlink(file_header->name) == -1) {
168 perror_msg_and_die("Couldnt remove old file"); 168 bb_perror_msg_and_die("Couldnt remove old file");
169 } 169 }
170 } else { 170 } else {
171 if (! archive_handle->flags & ARCHIVE_EXTRACT_QUIET) { 171 if (! archive_handle->flags & ARCHIVE_EXTRACT_QUIET) {
172 error_msg("%s not created: newer or same age file exists", file_header->name); 172 bb_error_msg("%s not created: newer or same age file exists", file_header->name);
173 } 173 }
174 extract_flag = FALSE; 174 extract_flag = FALSE;
175 } 175 }
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index 2cb141ede..365f464dd 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -75,7 +75,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
75#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY 75#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
76 if (strncmp(tar.formated.magic, "\0\0\0\0\0", 5) != 0) 76 if (strncmp(tar.formated.magic, "\0\0\0\0\0", 5) != 0)
77#endif 77#endif
78 error_msg_and_die("Invalid tar magic"); 78 bb_error_msg_and_die("Invalid tar magic");
79 } 79 }
80 /* Do checksum on headers */ 80 /* Do checksum on headers */
81 for (i = 0; i < 148 ; i++) { 81 for (i = 0; i < 148 ; i++) {
@@ -86,7 +86,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
86 sum += tar.raw[i]; 86 sum += tar.raw[i];
87 } 87 }
88 if (sum != strtol(tar.formated.chksum, NULL, 8)) { 88 if (sum != strtol(tar.formated.chksum, NULL, 8)) {
89 error_msg("Invalid tar header checksum"); 89 bb_error_msg("Invalid tar header checksum");
90 return(EXIT_FAILURE); 90 return(EXIT_FAILURE);
91 } 91 }
92 92
@@ -116,7 +116,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
116 file_header->size = strtol(tar.formated.size, NULL, 8); 116 file_header->size = strtol(tar.formated.size, NULL, 8);
117 file_header->mtime = strtol(tar.formated.mtime, NULL, 8); 117 file_header->mtime = strtol(tar.formated.mtime, NULL, 8);
118 file_header->link_name = (tar.formated.linkname[0] != '\0') ? 118 file_header->link_name = (tar.formated.linkname[0] != '\0') ?
119 xstrdup(tar.formated.linkname) : NULL; 119 bb_xstrdup(tar.formated.linkname) : NULL;
120 file_header->device = (dev_t) ((strtol(tar.formated.devmajor, NULL, 8) << 8) + 120 file_header->device = (dev_t) ((strtol(tar.formated.devmajor, NULL, 8) << 8) +
121 strtol(tar.formated.devminor, NULL, 8)); 121 strtol(tar.formated.devminor, NULL, 8));
122 122
@@ -129,7 +129,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
129 file_header->mode |= S_IFREG; 129 file_header->mode |= S_IFREG;
130 break; 130 break;
131 case '1': 131 case '1':
132 error_msg("Internal hard link not supported"); 132 bb_error_msg("Internal hard link not supported");
133 break; 133 break;
134 case '2': 134 case '2':
135 file_header->mode |= S_IFLNK; 135 file_header->mode |= S_IFLNK;
@@ -170,7 +170,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
170 case 'N': 170 case 'N':
171 case 'S': 171 case 'S':
172 case 'V': 172 case 'V':
173 error_msg("Ignoring GNU extension type %c", tar.formated.typeflag); 173 bb_error_msg("Ignoring GNU extension type %c", tar.formated.typeflag);
174# endif 174# endif
175 } 175 }
176#endif 176#endif
diff --git a/archival/libunarchive/get_header_tar_gz.c b/archival/libunarchive/get_header_tar_gz.c
index a4355d24c..7792432ae 100644
--- a/archival/libunarchive/get_header_tar_gz.c
+++ b/archival/libunarchive/get_header_tar_gz.c
@@ -25,7 +25,7 @@ extern char get_header_tar_gz(archive_handle_t *archive_handle)
25 25
26 archive_xread_all(archive_handle, &magic, 2); 26 archive_xread_all(archive_handle, &magic, 2);
27 if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { 27 if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
28 error_msg_and_die("Invalid gzip magic"); 28 bb_error_msg_and_die("Invalid gzip magic");
29 } 29 }
30 30
31 check_header_gzip(archive_handle->src_fd); 31 check_header_gzip(archive_handle->src_fd);
diff --git a/archival/libunarchive/header_verbose_list.c b/archival/libunarchive/header_verbose_list.c
index ff7b3bca2..6739dd393 100644
--- a/archival/libunarchive/header_verbose_list.c
+++ b/archival/libunarchive/header_verbose_list.c
@@ -9,7 +9,7 @@ extern void header_verbose_list(const file_header_t *file_header)
9 struct tm *mtime = localtime(&file_header->mtime); 9 struct tm *mtime = localtime(&file_header->mtime);
10 10
11 printf("%s %d/%d%10u %4u-%02u-%02u %02u:%02u:%02u %s", 11 printf("%s %d/%d%10u %4u-%02u-%02u %02u:%02u:%02u %s",
12 mode_string(file_header->mode), 12 bb_mode_string(file_header->mode),
13 file_header->uid, 13 file_header->uid,
14 file_header->gid, 14 file_header->gid,
15 (unsigned int) file_header->size, 15 (unsigned int) file_header->size,
diff --git a/archival/libunarchive/seek_by_jump.c b/archival/libunarchive/seek_by_jump.c
index 282397616..578870d9b 100644
--- a/archival/libunarchive/seek_by_jump.c
+++ b/archival/libunarchive/seek_by_jump.c
@@ -30,6 +30,6 @@ extern void seek_by_jump(const archive_handle_t *archive_handle, const unsigned
30 seek_by_char(archive_handle, amount); 30 seek_by_char(archive_handle, amount);
31 } else 31 } else
32#endif 32#endif
33 perror_msg_and_die("Seek failure"); 33 bb_perror_msg_and_die("Seek failure");
34 } 34 }
35} 35}
diff --git a/archival/libunarchive/uncompress.c b/archival/libunarchive/uncompress.c
index 192e98126..9851ca39d 100644
--- a/archival/libunarchive/uncompress.c
+++ b/archival/libunarchive/uncompress.c
@@ -121,14 +121,14 @@ extern int uncompress(int fd_in, int fd_out)
121 121
122 insize = 0; 122 insize = 0;
123 123
124 inbuf[0] = xread_char(fd_in); 124 inbuf[0] = bb_xread_char(fd_in);
125 125
126 maxbits = inbuf[0] & BIT_MASK; 126 maxbits = inbuf[0] & BIT_MASK;
127 block_mode = inbuf[0] & BLOCK_MODE; 127 block_mode = inbuf[0] & BLOCK_MODE;
128 maxmaxcode = MAXCODE(maxbits); 128 maxmaxcode = MAXCODE(maxbits);
129 129
130 if (maxbits > BITS) { 130 if (maxbits > BITS) {
131 error_msg("compressed with %d bits, can only handle %d bits", maxbits, 131 bb_error_msg("compressed with %d bits, can only handle %d bits", maxbits,
132 BITS); 132 BITS);
133 return -1; 133 return -1;
134 } 134 }
@@ -227,11 +227,11 @@ extern int uncompress(int fd_in, int fd_out)
227 posbits -= n_bits; 227 posbits -= n_bits;
228 p = &inbuf[posbits >> 3]; 228 p = &inbuf[posbits >> 3];
229 229
230 error_msg 230 bb_error_msg
231 ("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)", 231 ("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)",
232 insize, posbits, p[-1], p[0], p[1], p[2], p[3], 232 insize, posbits, p[-1], p[0], p[1], p[2], p[3],
233 (posbits & 07)); 233 (posbits & 07));
234 error_msg("uncompress: corrupt input"); 234 bb_error_msg("uncompress: corrupt input");
235 return -1; 235 return -1;
236 } 236 }
237 237
diff --git a/archival/libunarchive/unpack_ar_archive.c b/archival/libunarchive/unpack_ar_archive.c
index afa3672ad..e8f113bcf 100644
--- a/archival/libunarchive/unpack_ar_archive.c
+++ b/archival/libunarchive/unpack_ar_archive.c
@@ -26,7 +26,7 @@ extern void unpack_ar_archive(archive_handle_t *ar_archive)
26 26
27 archive_xread_all(ar_archive, magic, 7); 27 archive_xread_all(ar_archive, magic, 7);
28 if (strncmp(magic, "!<arch>", 7) != 0) { 28 if (strncmp(magic, "!<arch>", 7) != 0) {
29 error_msg_and_die("Invalid ar magic"); 29 bb_error_msg_and_die("Invalid ar magic");
30 } 30 }
31 ar_archive->offset += 7; 31 ar_archive->offset += 7;
32 32
diff --git a/archival/libunarchive/unzip.c b/archival/libunarchive/unzip.c
index 3a7334ce9..2401cf831 100644
--- a/archival/libunarchive/unzip.c
+++ b/archival/libunarchive/unzip.c
@@ -150,7 +150,7 @@ static void fill_bytebuffer(void)
150 /* Leave the first 4 bytes empty so we can always unwind the bitbuffer 150 /* Leave the first 4 bytes empty so we can always unwind the bitbuffer
151 * to the front of the bytebuffer, leave 4 bytes free at end of tail 151 * to the front of the bytebuffer, leave 4 bytes free at end of tail
152 * so we can easily top up buffer in check_trailer_gzip() */ 152 * so we can easily top up buffer in check_trailer_gzip() */
153 bytebuffer_size = 4 + xread(gunzip_src_fd, &bytebuffer[4], BYTEBUFFER_MAX - 8); 153 bytebuffer_size = 4 + bb_xread(gunzip_src_fd, &bytebuffer[4], BYTEBUFFER_MAX - 8);
154 bytebuffer_offset = 4; 154 bytebuffer_offset = 4;
155 } 155 }
156} 156}
@@ -448,7 +448,7 @@ static int inflate_codes(huft_t * my_tl, huft_t * my_td, const unsigned int my_b
448 if ((e = (t = tl + ((unsigned) b & ml))->e) > 16) 448 if ((e = (t = tl + ((unsigned) b & ml))->e) > 16)
449 do { 449 do {
450 if (e == 99) { 450 if (e == 99) {
451 error_msg_and_die("inflate_codes error 1");; 451 bb_error_msg_and_die("inflate_codes error 1");;
452 } 452 }
453 b >>= t->b; 453 b >>= t->b;
454 k -= t->b; 454 k -= t->b;
@@ -484,7 +484,7 @@ static int inflate_codes(huft_t * my_tl, huft_t * my_td, const unsigned int my_b
484 if ((e = (t = td + ((unsigned) b & md))->e) > 16) 484 if ((e = (t = td + ((unsigned) b & md))->e) > 16)
485 do { 485 do {
486 if (e == 99) 486 if (e == 99)
487 error_msg_and_die("inflate_codes error 2");; 487 bb_error_msg_and_die("inflate_codes error 2");;
488 b >>= t->b; 488 b >>= t->b;
489 k -= t->b; 489 k -= t->b;
490 e -= 16; 490 e -= 16;
@@ -821,7 +821,7 @@ static int inflate_block(int *e)
821 821
822 if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0) { 822 if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0) {
823 if (i == 1) { 823 if (i == 1) {
824 error_msg_and_die("Incomplete literal tree"); 824 bb_error_msg_and_die("Incomplete literal tree");
825 huft_free(tl); 825 huft_free(tl);
826 } 826 }
827 return i; /* incomplete code set */ 827 return i; /* incomplete code set */
@@ -830,7 +830,7 @@ static int inflate_block(int *e)
830 bd = dbits; 830 bd = dbits;
831 if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0) { 831 if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0) {
832 if (i == 1) { 832 if (i == 1) {
833 error_msg_and_die("incomplete distance tree"); 833 bb_error_msg_and_die("incomplete distance tree");
834 huft_free(td); 834 huft_free(td);
835 } 835 }
836 huft_free(tl); 836 huft_free(tl);
@@ -846,7 +846,7 @@ static int inflate_block(int *e)
846 } 846 }
847 default: 847 default:
848 /* bad block type */ 848 /* bad block type */
849 error_msg_and_die("bad block type %d\n", t); 849 bb_error_msg_and_die("bad block type %d\n", t);
850 } 850 }
851} 851}
852 852
@@ -884,7 +884,7 @@ static int inflate_get_next_window(void)
884 break; 884 break;
885 case -2: ret = inflate_codes(0,0,0,0,0); 885 case -2: ret = inflate_codes(0,0,0,0,0);
886 break; 886 break;
887 default: error_msg_and_die("inflate error %d", method); 887 default: bb_error_msg_and_die("inflate error %d", method);
888 } 888 }
889 889
890 if (ret == 1) { 890 if (ret == 1) {
@@ -975,16 +975,16 @@ extern void GZ_gzReadClose(void)
975 ssize_t nread, nwrote; 975 ssize_t nread, nwrote;
976 976
977 GZ_gzReadOpen(in, 0, 0); 977 GZ_gzReadOpen(in, 0, 0);
978 while(1) { // Robbed from copyfd.c 978 while(1) { // Robbed from bb_copyfd.c
979 nread = read_gz(in, buf, sizeof(buf)); 979 nread = read_gz(in, buf, sizeof(buf));
980 if (nread == 0) break; // no data to write 980 if (nread == 0) break; // no data to write
981 else if (nread == -1) { 981 else if (nread == -1) {
982 perror_msg("read"); 982 bb_perror_msg("read");
983 return -1; 983 return -1;
984 } 984 }
985 nwrote = full_write(out, buf, nread); 985 nwrote = bb_full_write(out, buf, nread);
986 if (nwrote == -1) { 986 if (nwrote == -1) {
987 perror_msg("write"); 987 bb_perror_msg("write");
988 return -1; 988 return -1;
989 } 989 }
990 } 990 }
@@ -998,9 +998,9 @@ extern int inflate(int in, int out)
998 GZ_gzReadOpen(in, 0, 0); 998 GZ_gzReadOpen(in, 0, 0);
999 while(1) { 999 while(1) {
1000 int ret = inflate_get_next_window(); 1000 int ret = inflate_get_next_window();
1001 nwrote = full_write(out, gunzip_window, gunzip_outbuf_count); 1001 nwrote = bb_full_write(out, gunzip_window, gunzip_outbuf_count);
1002 if (nwrote == -1) { 1002 if (nwrote == -1) {
1003 perror_msg("write"); 1003 bb_perror_msg("write");
1004 return -1; 1004 return -1;
1005 } 1005 }
1006 if (ret == 0) break; 1006 if (ret == 0) break;
@@ -1017,7 +1017,7 @@ extern void check_trailer_gzip(int src_fd)
1017 /* top up the input buffer with the rest of the trailer */ 1017 /* top up the input buffer with the rest of the trailer */
1018 count = bytebuffer_size - bytebuffer_offset; 1018 count = bytebuffer_size - bytebuffer_offset;
1019 if (count < 8) { 1019 if (count < 8) {
1020 xread_all(src_fd, &bytebuffer[bytebuffer_size], 8 - count); 1020 bb_xread_all(src_fd, &bytebuffer[bytebuffer_size], 8 - count);
1021 bytebuffer_size += 8 - count; 1021 bytebuffer_size += 8 - count;
1022 } 1022 }
1023 for (count = 0; count != 4; count++) { 1023 for (count = 0; count != 4; count++) {
@@ -1027,14 +1027,14 @@ extern void check_trailer_gzip(int src_fd)
1027 1027
1028 /* Validate decompression - crc */ 1028 /* Validate decompression - crc */
1029 if (stored_crc != (gunzip_crc ^ 0xffffffffL)) { 1029 if (stored_crc != (gunzip_crc ^ 0xffffffffL)) {
1030 error_msg_and_die("crc error"); 1030 bb_error_msg_and_die("crc error");
1031 } 1031 }
1032 1032
1033 /* Validate decompression - size */ 1033 /* Validate decompression - size */
1034 if (gunzip_bytes_out != 1034 if (gunzip_bytes_out !=
1035 (bytebuffer[bytebuffer_offset] | (bytebuffer[bytebuffer_offset+1] << 8) | 1035 (bytebuffer[bytebuffer_offset] | (bytebuffer[bytebuffer_offset+1] << 8) |
1036 (bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24))) { 1036 (bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24))) {
1037 error_msg_and_die("Incorrect length, but crc is correct"); 1037 bb_error_msg_and_die("Incorrect length, but crc is correct");
1038 } 1038 }
1039 1039
1040} 1040}
diff --git a/archival/rpm.c b/archival/rpm.c
index 61486cb03..5bde53285 100644
--- a/archival/rpm.c
+++ b/archival/rpm.c
@@ -116,7 +116,7 @@ int rpm_main(int argc, char **argv)
116 break; 116 break;
117 case 'q': // First arg: Query mode 117 case 'q': // First arg: Query mode
118 if (!func) func |= rpm_query; 118 if (!func) func |= rpm_query;
119 else show_usage(); 119 else bb_show_usage();
120 break; 120 break;
121 case 'p': // Query a package 121 case 'p': // Query a package
122 func |= rpm_query_package; 122 func |= rpm_query_package;
@@ -133,13 +133,13 @@ int rpm_main(int argc, char **argv)
133 func |= rpm_query_list_config; 133 func |= rpm_query_list_config;
134 break; 134 break;
135 default: 135 default:
136 show_usage(); 136 bb_show_usage();
137 } 137 }
138 } 138 }
139 139
140 if (optind == argc) show_usage(); 140 if (optind == argc) bb_show_usage();
141 while (optind < argc) { 141 while (optind < argc) {
142 rpm_fd = xopen(argv[optind], O_RDONLY); 142 rpm_fd = bb_xopen(argv[optind], O_RDONLY);
143 mytags = rpm_gettags(rpm_fd, (int *) &tagcount); 143 mytags = rpm_gettags(rpm_fd, (int *) &tagcount);
144 offset = lseek(rpm_fd, 0, SEEK_CUR); 144 offset = lseek(rpm_fd, 0, SEEK_CUR);
145 if (!mytags) { printf("Error reading rpm header\n"); exit(-1); } 145 if (!mytags) { printf("Error reading rpm header\n"); exit(-1); }
@@ -206,9 +206,9 @@ void extract_cpio_gz(int fd) {
206 archive_handle->src_fd = fd; 206 archive_handle->src_fd = fd;
207 archive_handle->offset = 0; 207 archive_handle->offset = 0;
208 208
209 xread_all(archive_handle->src_fd, &magic, 2); 209 bb_xread_all(archive_handle->src_fd, &magic, 2);
210 if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { 210 if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
211 error_msg_and_die("Invalid gzip magic"); 211 bb_error_msg_and_die("Invalid gzip magic");
212 } 212 }
213 check_header_gzip(archive_handle->src_fd); 213 check_header_gzip(archive_handle->src_fd);
214 chdir("/"); // Install RPM's to root 214 chdir("/"); // Install RPM's to root
@@ -314,7 +314,7 @@ void fileaction_dobackup(char *filename, int fileref)
314 if (rpm_getint(RPMTAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { /* Only need to backup config files */ 314 if (rpm_getint(RPMTAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { /* Only need to backup config files */
315 stat_res = lstat (filename, &oldfile); 315 stat_res = lstat (filename, &oldfile);
316 if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { /* File already exists - really should check MD5's etc to see if different */ 316 if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { /* File already exists - really should check MD5's etc to see if different */
317 newname = xstrdup(filename); 317 newname = bb_xstrdup(filename);
318 newname = strcat(newname, ".rpmorig"); 318 newname = strcat(newname, ".rpmorig");
319 copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS); 319 copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS);
320 remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE); 320 remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE);
diff --git a/archival/rpm2cpio.c b/archival/rpm2cpio.c
index 66f680869..bb9f69573 100644
--- a/archival/rpm2cpio.c
+++ b/archival/rpm2cpio.c
@@ -52,12 +52,12 @@ void skip_header(int rpm_fd)
52{ 52{
53 struct rpm_header header; 53 struct rpm_header header;
54 54
55 xread_all(rpm_fd, &header, sizeof(struct rpm_header)); 55 bb_xread_all(rpm_fd, &header, sizeof(struct rpm_header));
56 if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) { 56 if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) {
57 error_msg_and_die("Invalid RPM header magic"); /* Invalid magic */ 57 bb_error_msg_and_die("Invalid RPM header magic"); /* Invalid magic */
58 } 58 }
59 if (header.version != 1) { 59 if (header.version != 1) {
60 error_msg_and_die("Unsupported RPM header version"); /* This program only supports v1 headers */ 60 bb_error_msg_and_die("Unsupported RPM header version"); /* This program only supports v1 headers */
61 } 61 }
62 header.entries = ntohl(header.entries); 62 header.entries = ntohl(header.entries);
63 header.size = ntohl(header.size); 63 header.size = ntohl(header.size);
@@ -75,12 +75,12 @@ extern int rpm2cpio_main(int argc, char **argv)
75 if (argc == 1) { 75 if (argc == 1) {
76 rpm_fd = fileno(stdin); 76 rpm_fd = fileno(stdin);
77 } else { 77 } else {
78 rpm_fd = xopen(argv[1], O_RDONLY); 78 rpm_fd = bb_xopen(argv[1], O_RDONLY);
79 } 79 }
80 80
81 xread_all(rpm_fd, &lead, sizeof(struct rpm_lead)); 81 bb_xread_all(rpm_fd, &lead, sizeof(struct rpm_lead));
82 if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) { 82 if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) {
83 error_msg_and_die("Invalid RPM magic"); /* Just check the magic, the rest is irrelevant */ 83 bb_error_msg_and_die("Invalid RPM magic"); /* Just check the magic, the rest is irrelevant */
84 } 84 }
85 85
86 /* Skip the signature header */ 86 /* Skip the signature header */
@@ -90,14 +90,14 @@ extern int rpm2cpio_main(int argc, char **argv)
90 /* Skip the main header */ 90 /* Skip the main header */
91 skip_header(rpm_fd); 91 skip_header(rpm_fd);
92 92
93 xread_all(rpm_fd, &magic, 2); 93 bb_xread_all(rpm_fd, &magic, 2);
94 if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) { 94 if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
95 error_msg_and_die("Invalid gzip magic"); 95 bb_error_msg_and_die("Invalid gzip magic");
96 } 96 }
97 97
98 check_header_gzip(rpm_fd); 98 check_header_gzip(rpm_fd);
99 if (inflate(rpm_fd, fileno(stdout)) != 0) { 99 if (inflate(rpm_fd, fileno(stdout)) != 0) {
100 error_msg("Error inflating"); 100 bb_error_msg("Error inflating");
101 } 101 }
102 check_trailer_gzip(rpm_fd); 102 check_trailer_gzip(rpm_fd);
103 103
diff --git a/archival/tar.c b/archival/tar.c
index fa1c57512..c39d5787f 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -278,7 +278,7 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo,
278 header.typeflag = REGTYPE; 278 header.typeflag = REGTYPE;
279 putOctal(header.size, sizeof(header.size), statbuf->st_size); 279 putOctal(header.size, sizeof(header.size), statbuf->st_size);
280 } else { 280 } else {
281 error_msg("%s: Unknown file type", real_name); 281 bb_error_msg("%s: Unknown file type", real_name);
282 return (FALSE); 282 return (FALSE);
283 } 283 }
284 284
@@ -295,9 +295,9 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo,
295 295
296 /* Now write the header out to disk */ 296 /* Now write the header out to disk */
297 if ((size = 297 if ((size =
298 full_write(tbInfo->tarFd, (char *) &header, 298 bb_full_write(tbInfo->tarFd, (char *) &header,
299 sizeof(struct TarHeader))) < 0) { 299 sizeof(struct TarHeader))) < 0) {
300 error_msg(io_error, real_name); 300 bb_error_msg(bb_msg_io_error, real_name);
301 return (FALSE); 301 return (FALSE);
302 } 302 }
303 /* Pad the header up to the tar block size */ 303 /* Pad the header up to the tar block size */
@@ -368,7 +368,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
368 368
369 /* It is against the rules to archive a socket */ 369 /* It is against the rules to archive a socket */
370 if (S_ISSOCK(statbuf->st_mode)) { 370 if (S_ISSOCK(statbuf->st_mode)) {
371 error_msg("%s: socket ignored", fileName); 371 bb_error_msg("%s: socket ignored", fileName);
372 return (TRUE); 372 return (TRUE);
373 } 373 }
374 374
@@ -377,7 +377,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
377 * the new tarball */ 377 * the new tarball */
378 if (tbInfo->statBuf.st_dev == statbuf->st_dev && 378 if (tbInfo->statBuf.st_dev == statbuf->st_dev &&
379 tbInfo->statBuf.st_ino == statbuf->st_ino) { 379 tbInfo->statBuf.st_ino == statbuf->st_ino) {
380 error_msg("%s: file is the archive; skipping", fileName); 380 bb_error_msg("%s: file is the archive; skipping", fileName);
381 return (TRUE); 381 return (TRUE);
382 } 382 }
383 383
@@ -386,14 +386,14 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
386 static int alreadyWarned = FALSE; 386 static int alreadyWarned = FALSE;
387 387
388 if (alreadyWarned == FALSE) { 388 if (alreadyWarned == FALSE) {
389 error_msg("Removing leading '/' from member names"); 389 bb_error_msg("Removing leading '/' from member names");
390 alreadyWarned = TRUE; 390 alreadyWarned = TRUE;
391 } 391 }
392 header_name++; 392 header_name++;
393 } 393 }
394 394
395 if (strlen(fileName) >= NAME_SIZE) { 395 if (strlen(fileName) >= NAME_SIZE) {
396 error_msg(name_longer_than_foo, NAME_SIZE); 396 bb_error_msg(bb_msg_name_longer_than_foo, NAME_SIZE);
397 return (TRUE); 397 return (TRUE);
398 } 398 }
399 399
@@ -419,21 +419,21 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
419 419
420 /* open the file we want to archive, and make sure all is well */ 420 /* open the file we want to archive, and make sure all is well */
421 if ((inputFileFd = open(fileName, O_RDONLY)) < 0) { 421 if ((inputFileFd = open(fileName, O_RDONLY)) < 0) {
422 perror_msg("%s: Cannot open", fileName); 422 bb_perror_msg("%s: Cannot open", fileName);
423 return (FALSE); 423 return (FALSE);
424 } 424 }
425 425
426 /* write the file to the archive */ 426 /* write the file to the archive */
427 while ((size = full_read(inputFileFd, buffer, sizeof(buffer))) > 0) { 427 while ((size = bb_full_read(inputFileFd, buffer, sizeof(buffer))) > 0) {
428 if (full_write(tbInfo->tarFd, buffer, size) != size) { 428 if (bb_full_write(tbInfo->tarFd, buffer, size) != size) {
429 /* Output file seems to have a problem */ 429 /* Output file seems to have a problem */
430 error_msg(io_error, fileName); 430 bb_error_msg(bb_msg_io_error, fileName);
431 return (FALSE); 431 return (FALSE);
432 } 432 }
433 readSize += size; 433 readSize += size;
434 } 434 }
435 if (size == -1) { 435 if (size == -1) {
436 error_msg(io_error, fileName); 436 bb_error_msg(bb_msg_io_error, fileName);
437 return (FALSE); 437 return (FALSE);
438 } 438 }
439 /* Pad the file up to the tar block size */ 439 /* Pad the file up to the tar block size */
@@ -464,7 +464,7 @@ static inline int writeTarFile(const char *tarName, const int verboseFlag,
464 464
465 /* Make sure there is at least one file to tar up. */ 465 /* Make sure there is at least one file to tar up. */
466 if (include == NULL) { 466 if (include == NULL) {
467 error_msg_and_die("Cowardly refusing to create an empty archive"); 467 bb_error_msg_and_die("Cowardly refusing to create an empty archive");
468 } 468 }
469 469
470 /* Open the tar file for writing. */ 470 /* Open the tar file for writing. */
@@ -477,7 +477,7 @@ static inline int writeTarFile(const char *tarName, const int verboseFlag,
477 } 477 }
478 478
479 if (tbInfo.tarFd < 0) { 479 if (tbInfo.tarFd < 0) {
480 perror_msg("%s: Cannot open", tarName); 480 bb_perror_msg("%s: Cannot open", tarName);
481 freeHardLinkInfo(&tbInfo.hlInfoHead); 481 freeHardLinkInfo(&tbInfo.hlInfoHead);
482 return (FALSE); 482 return (FALSE);
483 } 483 }
@@ -485,12 +485,12 @@ static inline int writeTarFile(const char *tarName, const int verboseFlag,
485 /* Store the stat info for the tarball's file, so 485 /* Store the stat info for the tarball's file, so
486 * can avoid including the tarball into itself.... */ 486 * can avoid including the tarball into itself.... */
487 if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0) 487 if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0)
488 error_msg_and_die(io_error, tarName); 488 bb_error_msg_and_die(bb_msg_io_error, tarName);
489 489
490#ifdef CONFIG_FEATURE_TAR_GZIP 490#ifdef CONFIG_FEATURE_TAR_GZIP
491 if (gzip) { 491 if (gzip) {
492 if (pipe(gzipDataPipe) < 0 || pipe(gzipStatusPipe) < 0) { 492 if (pipe(gzipDataPipe) < 0 || pipe(gzipStatusPipe) < 0) {
493 perror_msg_and_die("Failed to create gzip pipe"); 493 bb_perror_msg_and_die("Failed to create gzip pipe");
494 } 494 }
495 495
496 signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */ 496 signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
@@ -529,7 +529,7 @@ static inline int writeTarFile(const char *tarName, const int verboseFlag,
529 529
530 if (n == 0 && vfork_exec_errno != 0) { 530 if (n == 0 && vfork_exec_errno != 0) {
531 errno = vfork_exec_errno; 531 errno = vfork_exec_errno;
532 perror_msg_and_die("Could not exec gzip process"); 532 bb_perror_msg_and_die("Could not exec gzip process");
533 } else if ((n < 0) && (errno == EAGAIN || errno == EINTR)) 533 } else if ((n < 0) && (errno == EAGAIN || errno == EINTR))
534 continue; /* try it again */ 534 continue; /* try it again */
535 break; 535 break;
@@ -538,7 +538,7 @@ static inline int writeTarFile(const char *tarName, const int verboseFlag,
538 538
539 tbInfo.tarFd = gzipDataPipe[1]; 539 tbInfo.tarFd = gzipDataPipe[1];
540 } else { 540 } else {
541 perror_msg_and_die("Failed to vfork gzip process"); 541 bb_perror_msg_and_die("Failed to vfork gzip process");
542 } 542 }
543 } 543 }
544#endif 544#endif
@@ -567,7 +567,7 @@ static inline int writeTarFile(const char *tarName, const int verboseFlag,
567 /* Hang up the tools, close up shop, head home */ 567 /* Hang up the tools, close up shop, head home */
568 close(tbInfo.tarFd); 568 close(tbInfo.tarFd);
569 if (errorFlag) 569 if (errorFlag)
570 error_msg("Error exit delayed from previous errors"); 570 bb_error_msg("Error exit delayed from previous errors");
571 571
572 freeHardLinkInfo(&tbInfo.hlInfoHead); 572 freeHardLinkInfo(&tbInfo.hlInfoHead);
573 573
@@ -585,10 +585,9 @@ static inline int writeTarFile(const char *tarName, const int verboseFlag,
585#ifdef CONFIG_FEATURE_TAR_EXCLUDE 585#ifdef CONFIG_FEATURE_TAR_EXCLUDE
586static llist_t *append_file_list_to_list(const char *filename, llist_t *list) 586static llist_t *append_file_list_to_list(const char *filename, llist_t *list)
587{ 587{
588 FILE *src_stream = xfopen(filename, "r"); 588 FILE *src_stream = bb_xfopen(filename, "r");
589 char *line; 589 char *line;
590 while((line = get_line_from_file(src_stream)) != NULL) { 590 while((line = bb_get_chomped_line_from_file(src_stream)) != NULL) {
591 chomp(line);
592 list = llist_add_to(list, line); 591 list = llist_add_to(list, line);
593 } 592 }
594 fclose(src_stream); 593 fclose(src_stream);
@@ -611,7 +610,7 @@ int tar_main(int argc, char **argv)
611 unsigned char ctx_flag = 0; 610 unsigned char ctx_flag = 0;
612 611
613 if (argc < 2) { 612 if (argc < 2) {
614 show_usage(); 613 bb_show_usage();
615 } 614 }
616 615
617 /* Prepend '-' to the first argument if required */ 616 /* Prepend '-' to the first argument if required */
@@ -690,13 +689,13 @@ int tar_main(int argc, char **argv)
690 break; 689 break;
691#endif 690#endif
692 default: 691 default:
693 show_usage(); 692 bb_show_usage();
694 } 693 }
695 } 694 }
696 695
697 /* Check one and only one context option was given */ 696 /* Check one and only one context option was given */
698 if ((ctx_flag != CTX_CREATE) && (ctx_flag != CTX_TEST) && (ctx_flag != CTX_EXTRACT)) { 697 if ((ctx_flag != CTX_CREATE) && (ctx_flag != CTX_TEST) && (ctx_flag != CTX_EXTRACT)) {
699 show_usage(); 698 bb_show_usage();
700 } 699 }
701 700
702 /* Check if we are reading from stdin */ 701 /* Check if we are reading from stdin */
@@ -740,11 +739,11 @@ int tar_main(int argc, char **argv)
740 tar_handle->src_fd = fileno(stdin); 739 tar_handle->src_fd = fileno(stdin);
741 tar_handle->seek = seek_by_char; 740 tar_handle->seek = seek_by_char;
742 } else { 741 } else {
743 tar_handle->src_fd = xopen(tar_filename, O_RDONLY); 742 tar_handle->src_fd = bb_xopen(tar_filename, O_RDONLY);
744 } 743 }
745 744
746 if ((base_dir) && (chdir(base_dir))) { 745 if ((base_dir) && (chdir(base_dir))) {
747 perror_msg_and_die("Couldnt chdir"); 746 bb_perror_msg_and_die("Couldnt chdir");
748 } 747 }
749 748
750 while (get_header_ptr(tar_handle) == EXIT_SUCCESS); 749 while (get_header_ptr(tar_handle) == EXIT_SUCCESS);
@@ -753,7 +752,7 @@ int tar_main(int argc, char **argv)
753 while (tar_handle->accept) { 752 while (tar_handle->accept) {
754 if (find_list_entry(tar_handle->reject, tar_handle->accept->data) == NULL) { 753 if (find_list_entry(tar_handle->reject, tar_handle->accept->data) == NULL) {
755 if (find_list_entry(tar_handle->passed, tar_handle->accept->data) == NULL) { 754 if (find_list_entry(tar_handle->passed, tar_handle->accept->data) == NULL) {
756 error_msg_and_die("%s: Not found in archive\n", tar_handle->accept->data); 755 bb_error_msg_and_die("%s: Not found in archive\n", tar_handle->accept->data);
757 } 756 }
758 } 757 }
759 tar_handle->accept = tar_handle->accept->link; 758 tar_handle->accept = tar_handle->accept->link;
diff --git a/archival/uncompress.c b/archival/uncompress.c
index 877bcc784..2d2145d18 100644
--- a/archival/uncompress.c
+++ b/archival/uncompress.c
@@ -45,7 +45,7 @@ int uncompress_main(int argc, char **argv)
45 flags |= gunzip_force; 45 flags |= gunzip_force;
46 break; 46 break;
47 default: 47 default:
48 show_usage(); /* exit's inside usage */ 48 bb_show_usage(); /* exit's inside usage */
49 } 49 }
50 } 50 }
51 51
@@ -63,17 +63,17 @@ int uncompress_main(int argc, char **argv)
63 src_fd = fileno(stdin); 63 src_fd = fileno(stdin);
64 flags |= gunzip_to_stdout; 64 flags |= gunzip_to_stdout;
65 } else { 65 } else {
66 src_fd = xopen(old_path, O_RDONLY); 66 src_fd = bb_xopen(old_path, O_RDONLY);
67 67
68 /* Get the time stamp on the input file. */ 68 /* Get the time stamp on the input file. */
69 if (stat(old_path, &stat_buf) < 0) { 69 if (stat(old_path, &stat_buf) < 0) {
70 error_msg_and_die("Couldn't stat file %s", old_path); 70 bb_error_msg_and_die("Couldn't stat file %s", old_path);
71 } 71 }
72 } 72 }
73 73
74 /* Check that the input is sane. */ 74 /* Check that the input is sane. */
75 if (isatty(src_fd) && ((flags & gunzip_force) == 0)) { 75 if (isatty(src_fd) && ((flags & gunzip_force) == 0)) {
76 error_msg_and_die 76 bb_error_msg_and_die
77 ("compressed data not read from terminal. Use -f to force it."); 77 ("compressed data not read from terminal. Use -f to force it.");
78 } 78 }
79 79
@@ -83,16 +83,16 @@ int uncompress_main(int argc, char **argv)
83 } else { 83 } else {
84 char *extension; 84 char *extension;
85 85
86 new_path = xstrdup(old_path); 86 new_path = bb_xstrdup(old_path);
87 87
88 extension = strrchr(new_path, '.'); 88 extension = strrchr(new_path, '.');
89 if (!extension || (strcmp(extension, ".Z") != 0)) { 89 if (!extension || (strcmp(extension, ".Z") != 0)) {
90 error_msg_and_die("Invalid extension"); 90 bb_error_msg_and_die("Invalid extension");
91 } 91 }
92 *extension = '\0'; 92 *extension = '\0';
93 93
94 /* Open output file */ 94 /* Open output file */
95 dst_fd = xopen(new_path, O_WRONLY | O_CREAT); 95 dst_fd = bb_xopen(new_path, O_WRONLY | O_CREAT);
96 96
97 /* Set permissions on the file */ 97 /* Set permissions on the file */
98 chmod(new_path, stat_buf.st_mode); 98 chmod(new_path, stat_buf.st_mode);
@@ -102,10 +102,10 @@ int uncompress_main(int argc, char **argv)
102 } 102 }
103 103
104 /* do the decompression, and cleanup */ 104 /* do the decompression, and cleanup */
105 if ((xread_char(src_fd) == 0x1f) && (xread_char(src_fd) == 0x9d)) { 105 if ((bb_xread_char(src_fd) == 0x1f) && (bb_xread_char(src_fd) == 0x9d)) {
106 status = uncompress(src_fd, dst_fd); 106 status = uncompress(src_fd, dst_fd);
107 } else { 107 } else {
108 error_msg_and_die("Invalid magic"); 108 bb_error_msg_and_die("Invalid magic");
109 } 109 }
110 110
111 if ((status != EXIT_SUCCESS) && (new_path)) { 111 if ((status != EXIT_SUCCESS) && (new_path)) {
@@ -122,7 +122,7 @@ int uncompress_main(int argc, char **argv)
122 122
123 /* delete_path will be NULL if in test mode or from stdin */ 123 /* delete_path will be NULL if in test mode or from stdin */
124 if (delete_path && (unlink(delete_path) == -1)) { 124 if (delete_path && (unlink(delete_path) == -1)) {
125 error_msg_and_die("Couldn't remove %s", delete_path); 125 bb_error_msg_and_die("Couldn't remove %s", delete_path);
126 } 126 }
127 127
128 free(new_path); 128 free(new_path);
diff --git a/archival/unzip.c b/archival/unzip.c
index 86416d327..f2d7f4918 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -120,12 +120,12 @@ extern int unzip_main(int argc, char **argv)
120 break; 120 break;
121#endif 121#endif
122 default: 122 default:
123 show_usage(); 123 bb_show_usage();
124 } 124 }
125 } 125 }
126 126
127 if (argc == optind) { 127 if (argc == optind) {
128 show_usage(); 128 bb_show_usage();
129 } 129 }
130 130
131 printf("Archive: %s\n", argv[optind]); 131 printf("Archive: %s\n", argv[optind]);
@@ -138,11 +138,11 @@ extern int unzip_main(int argc, char **argv)
138 archive_handle->src_fd = fileno(stdin); 138 archive_handle->src_fd = fileno(stdin);
139 archive_handle->seek = seek_by_char; 139 archive_handle->seek = seek_by_char;
140 } else { 140 } else {
141 archive_handle->src_fd = xopen(argv[optind++], O_RDONLY); 141 archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY);
142 } 142 }
143 143
144 if ((base_dir) && (chdir(base_dir))) { 144 if ((base_dir) && (chdir(base_dir))) {
145 perror_msg_and_die("Couldnt chdir"); 145 bb_perror_msg_and_die("Couldnt chdir");
146 } 146 }
147 147
148 while (optind < argc) { 148 while (optind < argc) {
@@ -163,7 +163,7 @@ extern int unzip_main(int argc, char **argv)
163 break; 163 break;
164 } 164 }
165 else if (magic != ZIP_FILEHEADER_MAGIC) { 165 else if (magic != ZIP_FILEHEADER_MAGIC) {
166 error_msg_and_die("Invlaide zip magic"); 166 bb_error_msg_and_die("Invlaide zip magic");
167 } 167 }
168 168
169 /* Read the file header */ 169 /* Read the file header */
@@ -172,7 +172,7 @@ extern int unzip_main(int argc, char **argv)
172 archive_handle->file_header->mode = S_IFREG | 0777; 172 archive_handle->file_header->mode = S_IFREG | 0777;
173 173
174 if (zip_header.formated.method != 8) { 174 if (zip_header.formated.method != 8) {
175 error_msg_and_die("Unsupported compression method %d\n", zip_header.formated.method); 175 bb_error_msg_and_die("Unsupported compression method %d\n", zip_header.formated.method);
176 } 176 }
177 177
178 /* Read filename */ 178 /* Read filename */
@@ -198,19 +198,19 @@ extern int unzip_main(int argc, char **argv)
198 if (archive_handle->action_data) { 198 if (archive_handle->action_data) {
199 archive_handle->action_data(archive_handle); 199 archive_handle->action_data(archive_handle);
200 } else { 200 } else {
201 dst_fd = xopen(archive_handle->file_header->name, O_WRONLY | O_CREAT); 201 dst_fd = bb_xopen(archive_handle->file_header->name, O_WRONLY | O_CREAT);
202 inflate(archive_handle->src_fd, dst_fd); 202 inflate(archive_handle->src_fd, dst_fd);
203 close(dst_fd); 203 close(dst_fd);
204 chmod(archive_handle->file_header->name, archive_handle->file_header->mode); 204 chmod(archive_handle->file_header->name, archive_handle->file_header->mode);
205 205
206 /* Validate decompression - crc */ 206 /* Validate decompression - crc */
207 if (zip_header.formated.crc32 != (gunzip_crc ^ 0xffffffffL)) { 207 if (zip_header.formated.crc32 != (gunzip_crc ^ 0xffffffffL)) {
208 error_msg("Invalid compressed data--crc error"); 208 bb_error_msg("Invalid compressed data--crc error");
209 } 209 }
210 210
211 /* Validate decompression - size */ 211 /* Validate decompression - size */
212 if (gunzip_bytes_out != zip_header.formated.ucmpsize) { 212 if (gunzip_bytes_out != zip_header.formated.ucmpsize) {
213 error_msg("Invalid compressed data--length error"); 213 bb_error_msg("Invalid compressed data--length error");
214 } 214 }
215 } 215 }
216 216