aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-06-13 16:09:16 +0000
committerRob Landley <rob@landley.net>2006-06-13 16:09:16 +0000
commitc4b673994e5e6f358b80fa3eef89e1cc26f60cee (patch)
tree7ac1ea3670c886924e49dae580c92cc9e21fb3d8
parentfd8409f8c5868d15a427f1e042352e7fc5372e35 (diff)
downloadbusybox-w32-c4b673994e5e6f358b80fa3eef89e1cc26f60cee.tar.gz
busybox-w32-c4b673994e5e6f358b80fa3eef89e1cc26f60cee.tar.bz2
busybox-w32-c4b673994e5e6f358b80fa3eef89e1cc26f60cee.zip
Use xstat() instead of if(stat()) die()
-rw-r--r--archival/bunzip2.c5
-rw-r--r--archival/uncompress.c8
-rw-r--r--archival/unlzma.c5
3 files changed, 5 insertions, 13 deletions
diff --git a/archival/bunzip2.c b/archival/bunzip2.c
index 09364b40e..abd7db3ab 100644
--- a/archival/bunzip2.c
+++ b/archival/bunzip2.c
@@ -50,10 +50,7 @@ int bunzip2_main(int argc, char **argv)
50 if (strcmp(extension, ".bz2") != 0) { 50 if (strcmp(extension, ".bz2") != 0) {
51 bb_error_msg_and_die("Invalid extension"); 51 bb_error_msg_and_die("Invalid extension");
52 } 52 }
53 /* TODO: xstat */ 53 xstat(filename, &stat_buf);
54 if (stat(filename, &stat_buf) < 0) {
55 bb_error_msg_and_die("Couldn't stat file %s", filename);
56 }
57 *extension=0; 54 *extension=0;
58 dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode); 55 dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
59 } else dst_fd = STDOUT_FILENO; 56 } else dst_fd = STDOUT_FILENO;
diff --git a/archival/uncompress.c b/archival/uncompress.c
index c47436ea3..b282fe811 100644
--- a/archival/uncompress.c
+++ b/archival/uncompress.c
@@ -61,11 +61,9 @@ int uncompress_main(int argc, char **argv)
61 *extension = '\0'; 61 *extension = '\0';
62 62
63 /* Open output file */ 63 /* Open output file */
64 dst_fd = bb_xopen(uncompressed_file, O_WRONLY | O_CREAT); 64 xstat(compressed_file, &stat_buf);
65 65 dst_fd = bb_xopen3(uncompressed_file, O_WRONLY | O_CREAT,
66 /* Set permissions on the file */ 66 stat_buf.st_mode);
67 stat(compressed_file, &stat_buf);
68 chmod(uncompressed_file, stat_buf.st_mode);
69 67
70 /* If unzip succeeds remove the old file */ 68 /* If unzip succeeds remove the old file */
71 delete_path = compressed_file; 69 delete_path = compressed_file;
diff --git a/archival/unlzma.c b/archival/unlzma.c
index 404da0acd..b4881af75 100644
--- a/archival/unlzma.c
+++ b/archival/unlzma.c
@@ -47,10 +47,7 @@ int unlzma_main(int argc, char **argv)
47 if (strcmp(extension, ".lzma") != 0) { 47 if (strcmp(extension, ".lzma") != 0) {
48 bb_error_msg_and_die("Invalid extension"); 48 bb_error_msg_and_die("Invalid extension");
49 } 49 }
50 /* TODO: xstat? */ 50 xstat(filename, &stat_buf);
51 if (stat(filename, &stat_buf) < 0) {
52 bb_error_msg_and_die("Couldn't stat file %s", filename);
53 }
54 *extension = 0; 51 *extension = 0;
55 dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode); 52 dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
56 } else 53 } else