X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=casper-md5check%2Fcasper-md5check.c;h=1e9d1bb24cf9e554a9251ea0eab112ad65a3a8a8;hb=269ea83c30e08ac2f82cea67b5d6ac065a67cbef;hp=0571e4941e7c0701352636560dcd7a5378a616d9;hpb=4a0b1ba4d428c623d14bae7f0db85c80abb0da0a;p=live-boot-grml.git diff --git a/casper-md5check/casper-md5check.c b/casper-md5check/casper-md5check.c index 0571e49..1e9d1bb 100644 --- a/casper-md5check/casper-md5check.c +++ b/casper-md5check/casper-md5check.c @@ -100,6 +100,23 @@ void usplash_text(int fd, char *format, ...) { free(s1); } +void usplash_urgent(int fd, char *format, ...) { + char *s, *s1; + va_list argp; + + va_start(argp, format); + vasprintf(&s, format, argp); + va_end(argp); + + asprintf(&s1, "TEXT-URGENT %s", s); + + write_and_retry(fd, s1); + + free(s); + free(s1); +} + + void usplash_success(int fd, char *format, ...) { char *s, *s1; va_list argp; @@ -173,10 +190,13 @@ int main(int argc, char **argv) { if (pipe_fd == -1) { /* We can't really do anything useful here */ + perror("Opening pipe"); exit(1); } + usplash_progress(pipe_fd, 0); + usplash_urgent(pipe_fd, "Checking integrity, this may take some time"); md5_file = fopen(argv[2], "r"); if (!md5_file) { perror("fopen md5_file"); @@ -214,7 +234,7 @@ int main(int argc, char **argv) { while (rsize > 0) { csize += rsize; - usplash_progress(pipe_fd, floorl(100*csize/tsize)); + usplash_progress(pipe_fd, floorl(100*((long double)csize)/tsize)); md5_append(&state, (const md5_byte_t *)buf, rsize); rsize = read(check_fd, buf, sizeof(buf)); @@ -235,9 +255,9 @@ int main(int argc, char **argv) { free(checksum); free(checkfile); } - usplash_text(pipe_fd, "Check finished, %d checksums failed", failed); - usplash_text(pipe_fd, "Press any key to reboot your system"); - usplash_timeout(pipe_fd, 0); + usplash_urgent(pipe_fd, "Check finished, %d checksums failed", failed); + usplash_urgent(pipe_fd, "Press any key to reboot your system"); + usplash_timeout(pipe_fd, 86400); set_nocanonical_tty(0); getchar(); reboot(LINUX_REBOOT_CMD_RESTART);