From 9cfd4b125daacff3e09c527e020432e3660ce1f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Sat, 22 Nov 2014 08:59:20 +0000 Subject: main/busybox: fixes and minor new features to fbsplash --- ...e-virtual-y-size-in-mmap-size-calculation.patch | 32 ++++ .../1001-fbsplash-support-console-switching.patch | 186 +++++++++++++++++++++ ...pport-image-and-bar-alignment-and-positio.patch | 184 ++++++++++++++++++++ main/busybox/APKBUILD | 15 +- 4 files changed, 416 insertions(+), 1 deletion(-) create mode 100644 main/busybox/1000-fbsplash-use-virtual-y-size-in-mmap-size-calculation.patch create mode 100644 main/busybox/1001-fbsplash-support-console-switching.patch create mode 100644 main/busybox/1002-fbsplash-support-image-and-bar-alignment-and-positio.patch (limited to 'main') diff --git a/main/busybox/1000-fbsplash-use-virtual-y-size-in-mmap-size-calculation.patch b/main/busybox/1000-fbsplash-use-virtual-y-size-in-mmap-size-calculation.patch new file mode 100644 index 000000000..ddfeb7f96 --- /dev/null +++ b/main/busybox/1000-fbsplash-use-virtual-y-size-in-mmap-size-calculation.patch @@ -0,0 +1,32 @@ +From 7f70f194ae135bd1e856c2dc811b8fa4a56296ea Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= +Date: Thu, 20 Sep 2012 09:41:56 +0300 +Subject: [PATCH] fbsplash: use virtual y size in mmap size calculations +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The virtual y can be larger - and we can be even writing there since +we are taking into account the y offset. Avoids possible crash. + +Signed-off-by: Timo Teräs +--- + miscutils/fbsplash.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c +index 7b695b2..58e491d 100644 +--- a/miscutils/fbsplash.c ++++ b/miscutils/fbsplash.c +@@ -150,7 +150,7 @@ static void fb_open(const char *strfb_device) + + // map the device in memory + G.addr = mmap(NULL, +- G.scr_var.yres * G.scr_fix.line_length, ++ G.scr_var.yres_virtual * G.scr_fix.line_length, + PROT_WRITE, MAP_SHARED, fbfd, 0); + if (G.addr == MAP_FAILED) + bb_perror_msg_and_die("mmap"); +-- +2.1.3 + diff --git a/main/busybox/1001-fbsplash-support-console-switching.patch b/main/busybox/1001-fbsplash-support-console-switching.patch new file mode 100644 index 000000000..2c88e2d78 --- /dev/null +++ b/main/busybox/1001-fbsplash-support-console-switching.patch @@ -0,0 +1,186 @@ +From 78e0c5d3ec8354b94e5d7bd978222651dbb2c8c0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= +Date: Mon, 24 Sep 2012 07:58:29 +0300 +Subject: [PATCH] fbsplash: support console switching +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Timo Teräs +--- + miscutils/fbsplash.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++----- + 1 file changed, 76 insertions(+), 7 deletions(-) + +diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c +index 58e491d..8599f78 100644 +--- a/miscutils/fbsplash.c ++++ b/miscutils/fbsplash.c +@@ -22,7 +22,7 @@ + */ + + //usage:#define fbsplash_trivial_usage +-//usage: "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD]" ++//usage: "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD] [-T tty]" + //usage:#define fbsplash_full_usage "\n\n" + //usage: " -s Image" + //usage: "\n -c Hide cursor" +@@ -32,10 +32,16 @@ + //usage: "\n BAR_R,BAR_G,BAR_B" + //usage: "\n -f Control pipe (else exit after drawing image)" + //usage: "\n commands: 'NN' (% for progress bar) or 'exit'" ++//usage: "\n -T Switch to TTY to hide all console messages" + + #include "libbb.h" + #include + ++#include ++#include ++#include ++#include ++ + /* If you want logging messages on /tmp/fbsplash.log... */ + #define DEBUG 0 + +@@ -47,6 +53,8 @@ struct globals { + unsigned char *addr; // pointer to framebuffer memory + unsigned ns[7]; // n-parameters + const char *image_filename; ++ int silent_tty, fd_tty_s; ++ bool do_not_draw; + struct fb_var_screeninfo scr_var; + struct fb_fix_screeninfo scr_fix; + unsigned bytes_per_pixel; +@@ -455,6 +463,11 @@ static void init(const char *cfg_filename) + config_close(parser); + } + ++static void sighandler(int sig) ++{ ++ ioctl(G.fd_tty_s, VT_RELDISP, sig == SIGUSR1 ? 1 : 2); ++ G.do_not_draw = (sig != SIGUSR2); ++} + + int fbsplash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; + int fbsplash_main(int argc UNUSED_PARAM, char **argv) +@@ -464,6 +477,9 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) + char *num_buf; + unsigned num; + bool bCursorOff; ++ int fd_tty0, active_vt; ++ struct vt_stat vtstat; ++ struct vt_mode vt; + + INIT_G(); + +@@ -471,8 +487,10 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) + fb_device = "/dev/fb0"; + cfg_filename = NULL; + fifo_filename = NULL; +- bCursorOff = 1 & getopt32(argv, "cs:d:i:f:", +- &G.image_filename, &fb_device, &cfg_filename, &fifo_filename); ++ opt_complementary = "T+"; // numeric params ++ bCursorOff = 1 & getopt32(argv, "cs:d:i:f:T:", ++ &G.image_filename, &fb_device, &cfg_filename, &fifo_filename, ++ &G.silent_tty); + + // parse configuration file + if (cfg_filename) +@@ -482,11 +500,43 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) + if (!G.image_filename) + bb_show_usage(); + ++ fd_tty0 = get_console_fd_or_die(); ++ if (G.silent_tty) { ++ char buf[16]; ++ ++ /* Initialize TTY */ ++ bb_signals((1LL << SIGUSR1) | (1LL << SIGUSR2), sighandler); ++ snprintf(buf, sizeof(buf), "/dev/tty%d", G.silent_tty); ++ G.fd_tty_s = xopen(buf, O_RDWR | O_NOCTTY); ++ ++ /* Activate TTY */ ++ xioctl(fd_tty0, VT_GETSTATE, &vtstat); ++ active_vt = vtstat.v_active; ++ console_make_active(fd_tty0, G.silent_tty); ++ ++ /* Get notifications on console changes */ ++ vt.mode = VT_PROCESS; ++ vt.waitv = 0; ++ vt.relsig = SIGUSR1; ++ vt.acqsig = SIGUSR2; ++ ioctl(G.fd_tty_s, VT_SETMODE, &vt); ++ ++ /* Redirect all kernel messages to tty1 so that they don't get ++ * printed over our silent splash image. And clear it. */ ++ buf[0] = TIOCL_SETKMSGREDIRECT; ++ buf[1] = 1; ++ ioctl(G.fd_tty_s, TIOCLINUX, buf); ++ full_write(G.fd_tty_s, "\e[H\e[2J" "\e[?17;0c", 7+8); ++ ioctl(G.fd_tty_s, KDSETMODE, KD_GRAPHICS); ++ } else { ++ G.fd_tty_s = STDOUT_FILENO; ++ } ++ + fb_open(fb_device); + + if (fifo_filename && bCursorOff) { + // hide cursor (BEFORE any fb ops) +- full_write(STDOUT_FILENO, "\033[?25l", 6); ++ full_write(G.fd_tty_s, "\033[?25l", 6); + } + + fb_drawimage(); +@@ -494,6 +544,7 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) + if (!fifo_filename) + return EXIT_SUCCESS; + ++ sig_block(SIGUSR1); + fp = xfopen_stdin(fifo_filename); + if (fp != stdin) { + // For named pipes, we want to support this: +@@ -509,8 +560,9 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) + // and become an additional writer :) + open(fifo_filename, O_WRONLY); // errors are ignored + } +- + fb_drawprogressbar(0); ++ sig_unblock(SIGUSR1); ++ + // Block on read, waiting for some input. + // Use of style I/O allows to correctly + // handle a case when we have many buffered lines +@@ -525,12 +577,29 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) + #if DEBUG + DEBUG_MESSAGE(itoa(num)); + #endif +- fb_drawprogressbar(num); ++ sig_block(SIGUSR1); ++ if (!G.do_not_draw) ++ fb_drawprogressbar(num); ++ sig_unblock(SIGUSR1); + } + free(num_buf); + } + +- if (bCursorOff) // restore cursor ++ if (G.silent_tty) { ++ usleep(100*1000); ++ ++ ioctl(G.fd_tty_s, VT_RELDISP, 1); ++ ioctl(G.fd_tty_s, KDSETMODE, KD_TEXT); ++ vt.mode = VT_AUTO; ++ vt.waitv = 0; ++ ioctl(G.fd_tty_s, VT_SETMODE, &vt); ++ close(G.fd_tty_s); ++ ++ xioctl(fd_tty0, VT_GETSTATE, &vtstat); ++ if (vtstat.v_active == G.silent_tty) ++ console_make_active(fd_tty0, active_vt); ++ ioctl(fd_tty0, VT_DISALLOCATE, (void *)(ptrdiff_t)G.silent_tty); ++ } else if (bCursorOff) // restore cursor + full_write(STDOUT_FILENO, "\033[?25h", 6); + + return EXIT_SUCCESS; +-- +2.1.3 + diff --git a/main/busybox/1002-fbsplash-support-image-and-bar-alignment-and-positio.patch b/main/busybox/1002-fbsplash-support-image-and-bar-alignment-and-positio.patch new file mode 100644 index 000000000..2ed0fa050 --- /dev/null +++ b/main/busybox/1002-fbsplash-support-image-and-bar-alignment-and-positio.patch @@ -0,0 +1,184 @@ +From 99d9c9a46b47190f1d2f061ba11c767b4089cf0a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= +Date: Fri, 21 Nov 2014 16:06:34 +0200 +Subject: [PATCH] fbsplash: support image and bar alignment and positioning +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Timo Teräs +--- + miscutils/fbsplash.c | 91 +++++++++++++++++++++++++++++++++++++++++++--------- + 1 file changed, 76 insertions(+), 15 deletions(-) + +diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c +index 8599f78..660fddd 100644 +--- a/miscutils/fbsplash.c ++++ b/miscutils/fbsplash.c +@@ -28,6 +28,7 @@ + //usage: "\n -c Hide cursor" + //usage: "\n -d Framebuffer device (default /dev/fb0)" + //usage: "\n -i Config file (var=value):" ++//usage: "\n IMAGE_ALIGN" + //usage: "\n BAR_LEFT,BAR_TOP,BAR_WIDTH,BAR_HEIGHT" + //usage: "\n BAR_R,BAR_G,BAR_B" + //usage: "\n -f Control pipe (else exit after drawing image)" +@@ -45,13 +46,38 @@ + /* If you want logging messages on /tmp/fbsplash.log... */ + #define DEBUG 0 + ++enum { ++ image_align, ++ ++ image_posx, ++ image_posy, ++ bar_width, ++ bar_height, ++ bar_posx, ++ bar_posy, ++ bar_colr, ++ bar_colg, ++ bar_colb, ++ ++ debug ++}; ++ ++#define nimage_align ns[image_align] ++#define nbar_width ns[bar_width] ++#define nbar_height ns[bar_height] ++#define nbar_posx ns[bar_posx] ++#define nbar_posy ns[bar_posy] ++#define nbar_colr ns[bar_colr] ++#define nbar_colg ns[bar_colg] ++#define nbar_colb ns[bar_colb] ++ + struct globals { + #if DEBUG + bool bdebug_messages; // enable/disable logging + FILE *logfile_fd; // log file + #endif + unsigned char *addr; // pointer to framebuffer memory +- unsigned ns[7]; // n-parameters ++ unsigned ns[debug+1]; // n-parameters + const char *image_filename; + int silent_tty, fd_tty_s; + bool do_not_draw; +@@ -68,14 +94,6 @@ struct globals { + SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ + } while (0) + +-#define nbar_width ns[0] // progress bar width +-#define nbar_height ns[1] // progress bar height +-#define nbar_posx ns[2] // progress bar horizontal position +-#define nbar_posy ns[3] // progress bar vertical position +-#define nbar_colr ns[4] // progress bar color red component +-#define nbar_colg ns[5] // progress bar color green component +-#define nbar_colb ns[6] // progress bar color blue component +- + #if DEBUG + #define DEBUG_MESSAGE(strMessage, args...) \ + if (G.bdebug_messages) { \ +@@ -356,7 +374,7 @@ static void fb_drawimage(void) + FILE *theme_file; + char *read_ptr; + unsigned char *pixline; +- unsigned i, j, width, height, line_size; ++ int i, j, width, height, line_size, xoffs, yoffs, xstart; + + if (LONE_DASH(G.image_filename)) { + theme_file = stdin; +@@ -404,18 +422,46 @@ static void fb_drawimage(void) + line_size = width*3; + pixline = xmalloc(line_size); + ++#if 0 + if (width > G.scr_var.xres) + width = G.scr_var.xres; + if (height > G.scr_var.yres) + height = G.scr_var.yres; +- for (j = 0; j < height; j++) { ++#endif ++ ++ xoffs = yoffs = 0; ++ switch (G.nimage_align % 3) { ++ case 1: xoffs = (G.scr_var.xres - width) / 2; break; ++ case 2: xoffs = G.scr_var.xres - width; break; ++ } ++ xstart = 0; ++ if (xoffs < 0) { ++ xstart = -xoffs; ++ width -= xstart; ++ xoffs = 0; ++ } ++ xoffs *= G.bytes_per_pixel; ++ if (width > G.scr_var.xres) ++ width = G.scr_var.xres; ++ ++ switch (G.nimage_align / 3) { ++ case 1: yoffs = (G.scr_var.yres - height) / 2; break; ++ case 2: yoffs = G.scr_var.yres - height; break; ++ } ++ ++ for (j = 0; j < height && yoffs < G.scr_var.yres; j++, yoffs++) { + unsigned char *pixel; + unsigned char *src; + + if (fread(pixline, 1, line_size, theme_file) != line_size) + bb_error_msg_and_die("bad PPM file '%s'", G.image_filename); ++ ++ if (yoffs < 0) ++ continue; ++ + pixel = pixline; +- src = G.addr + j * G.scr_fix.line_length; ++ src = G.addr + yoffs * G.scr_fix.line_length + xoffs; ++ + for (i = 0; i < width; i++) { + unsigned thispix = fb_pixel_value(pixel[0], pixel[1], pixel[2]); + fb_write_pixel(src, thispix); +@@ -434,9 +480,17 @@ static void fb_drawimage(void) + */ + static void init(const char *cfg_filename) + { ++ static const char align_names[] ALIGN1 = ++ "LT\0" "CT\0" "RT\0" ++ "LM\0" "CM\0" "RM\0" ++ "LB\0" "CB\0" "RB\0"; + static const char param_names[] ALIGN1 = ++ "IMAGE_ALIGN\0" ++ ++ "IMAGE_X\0" "IMAGE_Y\0" + "BAR_WIDTH\0" "BAR_HEIGHT\0" + "BAR_LEFT\0" "BAR_TOP\0" ++ + "BAR_R\0" "BAR_G\0" "BAR_B\0" + #if DEBUG + "DEBUG\0" +@@ -446,14 +500,21 @@ static void init(const char *cfg_filename) + parser_t *parser = config_open2(cfg_filename, xfopen_stdin); + while (config_read(parser, token, 2, 2, "#=", + (PARSE_NORMAL | PARSE_MIN_DIE) & ~(PARSE_TRIM | PARSE_COLLAPSE))) { +- unsigned val = xatoi_positive(token[1]); ++ unsigned val; + int i = index_in_strings(param_names, token[0]); ++ + if (i < 0) + bb_error_msg_and_die("syntax error: %s", token[0]); +- if (i >= 0 && i < 7) ++ ++ if (i <= image_align) ++ val = index_in_strings(align_names, token[1]); ++ else ++ val = xatoi_positive(token[1]); ++ ++ if (i < debug) + G.ns[i] = val; + #if DEBUG +- if (i == 7) { ++ if (i == debug) { + G.bdebug_messages = val; + if (G.bdebug_messages) + G.logfile_fd = xfopen_for_write("/tmp/fbsplash.log"); +-- +2.1.3 + diff --git a/main/busybox/APKBUILD b/main/busybox/APKBUILD index d84c263cf..dd21d7af6 100644 --- a/main/busybox/APKBUILD +++ b/main/busybox/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: Natanael Copa pkgname=busybox pkgver=1.22.1 -pkgrel=13 +pkgrel=14 pkgdesc="Size optimized toolbox of many common UNIX utilities" url=http://busybox.net arch="all" @@ -37,6 +37,10 @@ source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2 fix-top.patch 0001-diff-add-support-for-no-dereference.patch + 1000-fbsplash-use-virtual-y-size-in-mmap-size-calculation.patch + 1001-fbsplash-support-console-switching.patch + 1002-fbsplash-support-image-and-bar-alignment-and-positio.patch + busyboxconfig glibc.patch" @@ -136,6 +140,9 @@ d372d376820957fd5f2aee158af9867e 0001-sendmail-make-f-optional-document-its-def 7cadebb1071d648b947cfbcca9839721 0001-top-fix-and-merge-code-to-parse-proc-meminfo.patch f2821edec523aadb36c3973d14386c1c fix-top.patch 69fa40bee9abec058427bf67fde1b61e 0001-diff-add-support-for-no-dereference.patch +699ce5aa1095ba4419cd595cec8a8f75 1000-fbsplash-use-virtual-y-size-in-mmap-size-calculation.patch +b56d306ccba574da78dff060b7330806 1001-fbsplash-support-console-switching.patch +4fe5f9e973674c7db3d07f295c363a7c 1002-fbsplash-support-image-and-bar-alignment-and-positio.patch 2fe6e74affe7d4e5e112035cead59432 busyboxconfig befaac2c59c380e36a452b3f1c1d4a3a glibc.patch" sha256sums="ae0b029d0a9e4dd71a077a790840e496dd838998e4571b87b60fed7462b6678b busybox-1.22.1.tar.bz2 @@ -159,6 +166,9 @@ ac2cd5fed91bfaec22ed1f2766396d0feb29b9b96f20b2c12d5d8ac8769afae9 0001-linedit-d 79c6e19853a4ceecfec65311e5f8e66033243b8250829c06420d27d8240f1775 0001-top-fix-and-merge-code-to-parse-proc-meminfo.patch d4673907d58ce80e78a3bfe3c2414b15e7a2b072cfea0c87c2ae9f709744b9ec fix-top.patch 70180473e3939402e460b25de8273a5ce7f62b130a9efe31f33d847b2406ac92 0001-diff-add-support-for-no-dereference.patch +043963183cad556bdae5d5608180f0cb76cf7eede175cd97aa002a787780500f 1000-fbsplash-use-virtual-y-size-in-mmap-size-calculation.patch +b8b0b16ed67b0159256193b1d2108b8ef9aa8a334ab81e463bb970c71257da9a 1001-fbsplash-support-console-switching.patch +e1f3fad8e21dfd72cfcae7ab3ba31d7938e964e0f9ec08b2da0b14d462435424 1002-fbsplash-support-image-and-bar-alignment-and-positio.patch 9bfb197fb57f9b3ac5b7a8800dfda6e5f7bee10db5e892d58176fa3733fe5229 busyboxconfig c604ef791c31d35a8c5ee4558d21428a46f37a6d762c4a7e29864f4037fc44a0 glibc.patch" sha512sums="3e99fe373d638f714c3a61e1b02493d85ca532f472df038f7557db518ded38347072882ed568852941be7aac46fc34007257b4287375335ff5a09b60b295ce80 busybox-1.22.1.tar.bz2 @@ -182,5 +192,8 @@ d466676cd2779ff33f288bb073aa2baa4f3606cf8b96ec514e624a7acb46442a2839ef18c47e19cc fa5f7f43bf8030f4bfcdf09d85e2e314014d5a083a24de95ac2e78c15e0dfebc14e410088e7f8eaeb8cdf24dea64e3b665b99afb8f96259e9908eebce81745bc 0001-top-fix-and-merge-code-to-parse-proc-meminfo.patch 2dea81509f73621e60d95db1b04186056add15fb24d1f9f7b32bb50aee99733d3cf45404c33b7ca6993cff23d76f31c0bcf38c04ac741dcdd2baaf3bc2afd707 fix-top.patch a35b66cd28b79ccc14b47315ac94677fdf8c14d8a6e8956707e71fb50d453dfc5b4b822832cd1faecfe9bf79e687f9b25a1357e0a88db530044c5f8514701c98 0001-diff-add-support-for-no-dereference.patch +2a8e9360e1cedd26bdb70d8cc036ef0abc7588bf2eee147c1c7436d7a40763f8e31d346b980145a36649130a2f811d299e4f46f7e1b60a8165a60ae9e79727d5 1000-fbsplash-use-virtual-y-size-in-mmap-size-calculation.patch +a181dd54e8e11cf1199edb1b1fcd4b7402bbf142593b6014f32c6815bb7093b56899ad0fcc9f73c382f56203ac5274fb3d51fa070feb541436f23c31680f1a69 1001-fbsplash-support-console-switching.patch +c33073416f7da2805a20f3f456f869217171c8fbfdef85f4ae481307aeb1e1b5717084bbbc619010fa5500c3f3f49b6468d5c122024fcc49d637c82427a3f553 1002-fbsplash-support-image-and-bar-alignment-and-positio.patch 35ab915e729e73c4909793f58530edcfc10f10d750df0d41913892137f799f773a7bb476e29ed742c86d0f279603f85ed9bf5c660714571bc5f5179ea852aade busyboxconfig 1d2739379dab1deb3eae7cffd4845300eb7d30f7343b4a1209b21a5680860d55080ad45fdefe098b249ce3040c01951fa7f0a79cd447b2d7b260eb000099d9dc glibc.patch" -- cgit v1.2.3