This afternoon I updated a small system to git HEAD, rebooted,
and discovered that modprobe no longer worked.
Specifically, it spat out an error like this:
modprobe: no gzip/bzip2/xz magic
grep helped me track this down to archival/libarchive/open_transformer.c.
I'm using uncompressed modules, so I need modprobe to simply proceed on
when an uncompressed file is encountered.
This was the most obvious way to do that; in the process, I happened to find
and fix similar issues in man and tar.
I'm not sure how far back this is an issue; it looks like it may be from
this commit:
commit 7c47b560a8fc97956dd8132bd7f1863d83c19866
Author: Denys Vlasenko <[email protected]>
Date: Fri Jan 10 14:06:57 2014 +0100
libarchive: open_zipped() does not need to check extensions for e.g. gzip
Thanks,
Isaac Dunham>From daba7a86bede551c5ab14a4c99426c3711b530c9 Mon Sep 17 00:00:00 2001
From: Isaac Dunham <[email protected]>
Date: Thu, 16 Jan 2014 19:28:09 -0800
Subject: [PATCH] Unbreak modutils, tar, man for uncompressed files.
Several tools broke because open_zipped() exited on uncompressed
files.
To reproduce, use a defconfig busybox and run these commands:
$ ./busybox tar cf new.tar LICENSE
$ ./busybox tar tf new.tar
tar: no gzip/bzip2/xz magic
This fixes the issue.
fbsplash and bunzip/gunzip/un* still have the old behavior.
function old new delta
fbsplash_main 1009 1014 +5
bbunpack 739 744 +5
open_zipped 88 89 +1
xmalloc_open_zipped_read_close 67 63 -4
cut_main 918 887 -31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 11/-35) Total: -24 bytes
---
archival/bbunzip.c | 2 +-
archival/libarchive/open_transformer.c | 6 +++---
archival/tar.c | 2 +-
include/libbb.h | 4 ++--
miscutils/fbsplash.c | 2 +-
miscutils/man.c | 2 +-
6 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index b3fb90f..0a10c3e 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -72,7 +72,7 @@ int FAST_FUNC bbunpack(char **argv,
goto err;
} else {
/* "clever zcat" with FILE */
- int fd = open_zipped(filename);
+ int fd = open_zipped(filename, /*fail_if_not_detected*/ 1);
if (fd < 0)
goto err_name;
xmove_fd(fd, STDIN_FILENO);
diff --git a/archival/libarchive/open_transformer.c b/archival/libarchive/open_transformer.c
index 1aeba13..ad34072 100644
--- a/archival/libarchive/open_transformer.c
+++ b/archival/libarchive/open_transformer.c
@@ -180,7 +180,7 @@ int FAST_FUNC setup_unzip_on_fd(int fd, int fail_if_not_detected)
return 0;
}
-int FAST_FUNC open_zipped(const char *fname)
+int FAST_FUNC open_zipped(const char *fname, int fail_if_not_detected)
{
int fd;
@@ -200,7 +200,7 @@ int FAST_FUNC open_zipped(const char *fname)
|| (ENABLE_FEATURE_SEAMLESS_BZ2)
|| (ENABLE_FEATURE_SEAMLESS_XZ)
) {
- setup_unzip_on_fd(fd, /*fail_if_not_detected:*/ 1);
+ setup_unzip_on_fd(fd, fail_if_not_detected);
}
return fd;
@@ -213,7 +213,7 @@ void* FAST_FUNC xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_
int fd;
char *image;
- fd = open_zipped(fname);
+ fd = open_zipped(fname, 0); //all users need to open uncompressed files
if (fd < 0)
return NULL;
diff --git a/archival/tar.c b/archival/tar.c
index bd61abd..ec06b38 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -1137,7 +1137,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
&& flags == O_RDONLY
&& !(opt & OPT_ANY_COMPRESS)
) {
- tar_handle->src_fd = open_zipped(tar_filename);
+ tar_handle->src_fd = open_zipped(tar_filename, /*fail_if_not_opened*/ 0);
if (tar_handle->src_fd < 0)
bb_perror_msg_and_die("can't open '%s'", tar_filename);
} else {
diff --git a/include/libbb.h b/include/libbb.h
index 64167bb..d2cb7d8 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -738,10 +738,10 @@ extern void *xmalloc_xopen_read_close(const char *filename, size_t *maxsz_p) FAS
/* Autodetects gzip/bzip2 formats. fd may be in the middle of the file! */
extern int setup_unzip_on_fd(int fd, int fail_if_not_detected) FAST_FUNC;
/* Autodetects .gz etc */
-extern int open_zipped(const char *fname) FAST_FUNC;
+extern int open_zipped(const char *fname, int fail_if_not_detected) FAST_FUNC;
#else
# define setup_unzip_on_fd(...) (0)
-# define open_zipped(fname) open((fname), O_RDONLY);
+# define open_zipped(fname, ignore) open((fname), O_RDONLY);
#endif
extern void *xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index 12a77b7..03586dd 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -353,7 +353,7 @@ static void fb_drawimage(void)
if (LONE_DASH(G.image_filename)) {
theme_file = stdin;
} else {
- int fd = open_zipped(G.image_filename);
+ int fd = open_zipped(G.image_filename, 1);
if (fd < 0)
bb_simple_perror_msg_and_die(G.image_filename);
theme_file = xfdopen_for_read(fd);
diff --git a/miscutils/man.c b/miscutils/man.c
index d3e832b..94990e1 100644
--- a/miscutils/man.c
+++ b/miscutils/man.c
@@ -102,7 +102,7 @@ static int run_pipe(const char *pager, char *man_filename, int man, int level)
ordinary_manpage:
close(STDIN_FILENO);
- open_zipped(man_filename); /* guaranteed to use fd 0 (STDIN_FILENO) */
+ open_zipped(man_filename, 0); /* guaranteed to use fd 0 (STDIN_FILENO) */
/* "2>&1" is added so that nroff errors are shown in pager too.
* Otherwise it may show just empty screen */
cmd = xasprintf(
--
1.7.10.4
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox