I've attached a new version of the patch which was recreated against the current upstream version (0.4-15).

Matthew, I got no feedback from the last version of the patch, I hope that you'll be able to give some on this version now that it applies cleanly again after the libusplash splitout and added svga support...

--
David Härdeman
diff -ur usplash-0.4-orig/initramfs/scripts/init-top/usplash 
usplash-0.4/initramfs/scripts/init-top/usplash
--- usplash-0.4-orig/initramfs/scripts/init-top/usplash 2006-08-07 
22:02:00.000000000 +0200
+++ usplash-0.4/initramfs/scripts/init-top/usplash      2006-09-04 
00:10:51.000000000 +0200
@@ -33,6 +33,8 @@
         for i in 0 1 2 3 4 5 6 7 8; do
                 mknod /dev/tty$i c 4 $i
        done
+       modprobe -q i8042
+       modprobe -q atkbd
        /sbin/usplash -c -x "$xres" -y "$yres" &
        sleep 1
 fi
diff -ur usplash-0.4-orig/libusplash.c usplash-0.4/libusplash.c
--- usplash-0.4-orig/libusplash.c       2006-08-24 01:20:33.000000000 +0200
+++ usplash-0.4/libusplash.c    2006-09-04 00:32:39.000000000 +0200
@@ -20,6 +20,7 @@
  */
 
 #include <linux/vt.h>
+#include <linux/limits.h>
 
 #include <sys/select.h>
 #include <sys/time.h>
@@ -53,6 +54,7 @@
 void draw_text         (const char *string, size_t len);
 void draw_line         (const char *string, size_t len);
 void draw_status       (const char *string, size_t len, int mode);
+int handle_input       (const char *string, size_t len, int quiet);
 
 /* Non-static so that svgalib can call it. Damned svgalib. */
 void usplash_restore_console   (void);
@@ -99,6 +101,9 @@
        ioctl (fd, VT_ACTIVATE, vt);
        ioctl (fd, VT_WAITACTIVE, vt);
        close (fd);
+
+       close (STDIN_FILENO);
+       open (vtname, O_RDONLY);
 }
 
 void
@@ -291,3 +296,77 @@
 
        usplash_text (x1, y1, string, len, fg, theme->text_background);
 }
+
+int
+handle_input (const char *string, const size_t len, const int quiet)
+{
+       int i;
+       char input;
+       int x1, y1, x2, y2, xpos;
+       ssize_t wlen;
+       int fifo_outfd;
+       char inputbuf[PIPE_BUF] = "";
+
+       /* some variables which we'll need */
+       x1 = left_edge + theme->text_x;
+       x2 = x1 + theme->text_width;
+
+       y2 = top_edge + theme->text_y + theme->text_height;
+       y1 = y2 - theme->line_height;
+
+       /* draw the prompt */
+       draw_line (string, len);
+       xpos = x1;
+       for (i = 0; i < len; i++)
+               xpos += usplash_getfontwidth (*(string + i));
+
+       /* Get user input */
+       for (i = 0; i < PIPE_BUF - 1; i++) {
+               input = getchar ();
+               if (input == '\n' || input == '\r' || input == '\0')
+                       break;
+
+               inputbuf[i] = input;
+
+               if (quiet)
+                       input = '*';
+
+               /* Make sure the text doesn't overflow */
+               if (xpos + usplash_getfontwidth (input) > x2) {
+                       usplash_move (x1,
+                                  top_edge + theme->text_y + 
theme->line_height,
+                                  x1,
+                                  top_edge + theme->text_y,
+                                  theme->text_width,
+                                  theme->text_height - theme->line_height);
+                       usplash_clear (x1, y1, x2, y2, theme->text_background);
+                       xpos = x1;
+               }
+
+               usplash_text (xpos, y1, &input, 1,
+                             theme->text_foreground, theme->text_background);
+               xpos += usplash_getfontwidth (input);
+       }
+       inputbuf[i] = '\0';
+
+       /* We wait for timeout seconds for someone to read the user input */
+       for (i = 1; i != timeout + 1; i++) {
+               fifo_outfd = open (USPLASH_OUTFIFO, O_WRONLY|O_NONBLOCK);
+               if (fifo_outfd < 0)
+                       sleep(1);
+               else
+                       break;
+       }
+
+       if (fifo_outfd < 0)
+               return 1;
+
+       wlen = write (fifo_outfd, inputbuf, strlen(inputbuf) + 1);
+       if (wlen < 0)
+               return 1;
+
+       close(fifo_outfd);
+       memset(inputbuf, 0, PIPE_BUF);
+       return 0;
+}
+
diff -ur usplash-0.4-orig/libusplash.h usplash-0.4/libusplash.h
--- usplash-0.4-orig/libusplash.h       2006-08-24 01:36:08.000000000 +0200
+++ usplash-0.4/libusplash.h    2006-09-04 00:12:25.000000000 +0200
@@ -9,6 +9,8 @@
 void draw_text         (const char *string, size_t len);
 void draw_line         (const char *string, size_t len);
 void draw_status       (const char *string, size_t len, int mode);
+int handle_input       (const char *string, size_t len, int quiet);
+
 int  usplash_setup     (int xres, int yres);
 void usplash_restore_console   (void);
 int strncspn (const char *s, size_t n, const char *reject);
diff -ur usplash-0.4-orig/usplash_backend.h usplash-0.4/usplash_backend.h
--- usplash-0.4-orig/usplash_backend.h  2006-08-03 02:23:49.000000000 +0200
+++ usplash-0.4/usplash_backend.h       2006-09-04 00:26:41.000000000 +0200
@@ -1,4 +1,5 @@
 int usplash_setfont (void* font);
+int usplash_getfontwidth (char c);
 int usplash_init ();
 void usplash_set_resolution (int x, int y);
 void usplash_set_palette (int ncols, unsigned char palette[][3]);
diff -ur usplash-0.4-orig/usplash_bogl.c usplash-0.4/usplash_bogl.c
--- usplash-0.4-orig/usplash_bogl.c     2006-08-16 17:53:32.000000000 +0200
+++ usplash-0.4/usplash_bogl.c  2006-09-04 00:26:14.000000000 +0200
@@ -11,6 +11,10 @@
        return 0;
 }
 
+int usplash_getfontwidth (char c) {
+       return bogl_metrics (&c, 1, usplash_bogl_font);
+}
+
 int usplash_init () {
        if (! bogl_init ()) {
                fprintf (stderr, "bogl_init failed: %s\n", bogl_error());
diff -ur usplash-0.4-orig/usplash.c usplash-0.4/usplash.c
--- usplash-0.4-orig/usplash.c  2006-08-24 01:35:49.000000000 +0200
+++ usplash-0.4/usplash.c       2006-09-04 00:10:51.000000000 +0200
@@ -90,6 +90,14 @@
                }
        }
 
+       if (mkfifo (USPLASH_OUTFIFO, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) < 0) {
+               if (errno != EEXIST) {
+                       perror ("mkfifo");
+                       ret = 1;
+                       goto exit;
+               }
+       }
+
        fifo_fd = open (USPLASH_FIFO, O_RDONLY|O_NONBLOCK);
        if (fifo_fd < 0) {
                perror ("open");
@@ -236,6 +244,13 @@
 
        } else if (! strncmp (command, "PROGRESS", commandlen)) {
                draw_progressbar (atoi (string));
+
+       } else if (! strncmp (command, "INPUT", commandlen)) {
+               return handle_input (string, len, 0);
+
+       } else if (! strncmp (command, "INPUTQUIET", commandlen)) {
+               return handle_input (string, len, 1);
+
        }
 
        return 0;
diff -ur usplash-0.4-orig/usplash.h usplash-0.4/usplash.h
--- usplash-0.4-orig/usplash.h  2006-08-16 17:53:32.000000000 +0200
+++ usplash-0.4/usplash.h       2006-09-04 00:10:51.000000000 +0200
@@ -27,6 +27,9 @@
 /* Filename of usplash control fifo within the USPLASH_DIR directory*/
 #define USPLASH_FIFO  "usplash_fifo"
 
+/* Filename of usplash user feedback fifo within the USPLASH_DIR directory*/
+#define USPLASH_OUTFIFO  "usplash_outfifo"
+
 /* Location of usplash theme */
 #define USPLASH_THEME "/usr/lib/usplash/usplash-artwork.so"
 
diff -ur usplash-0.4-orig/usplash_svga.c usplash-0.4/usplash_svga.c
--- usplash-0.4-orig/usplash_svga.c     2006-08-23 21:29:50.000000000 +0200
+++ usplash-0.4/usplash_svga.c  2006-09-04 00:24:32.000000000 +0200
@@ -44,6 +44,10 @@
        return 0;
 }
 
+int usplash_getfontwidth (char c) {
+       return 8;
+}
+
 int usplash_init () {
        int rc = 0;
        
diff -ur usplash-0.4-orig/usplash_write.8 usplash-0.4/usplash_write.8
--- usplash-0.4-orig/usplash_write.8    2006-07-28 15:37:29.000000000 +0200
+++ usplash-0.4/usplash_write.8 2006-09-04 00:10:51.000000000 +0200
@@ -50,6 +50,17 @@
 Update the progress bar to show that the given percentage (0-100) of the
 process has been completed.
 .\"
+.TP
+.BI INPUT " prompt"
+Displays the given prompt and waits for one line of user input. The line
+can then be read from /dev/.initramfs/usplash_outfifo within the timeout
+period.
+.\"
+.TP
+.BI INPUTQUIET " prompt"
+Works in the same way as INPUT above with the exception that the user input
+is not echoed to the console. Useful for password prompts.
+.\"
 .SH EXIT STATUS
 .B usplash_write
 always returns an exit status of zero.

Reply via email to