--- /dev/null
+Package: lilo
+Subject: save errno for second command
+Author: Joachim Wiedorn <ad_debian at joonet.de>
+Forwarded: yes
+Last-Update: 2011-02-17
+
+The problem is that fprintf can alter the value of errno
+(see man perror). In a weired case the user get a bogus error
+because the real error was hidden by fprintf.
+---
+
+diff -urN s11/src/device.c s12/src/device.c
+--- s11/src/device.c 2011-02-17 22:07:17.167142581 +0100
++++ s12/src/device.c 2011-02-17 22:20:03.047152869 +0100
+@@ -197,6 +197,7 @@
+ char name[PATH_MAX];
+ ST_BUF st;
+ int count;
++ int err;
+
+ if (lookup_dev(name,dev,number)) dev->delete = 0;
+ else {
+@@ -235,11 +236,12 @@
+ #endif
+ if (flags == O_BYPASS) dev->fd = -1;
+ else if ((dev->fd = open(name,flags)) < 0) {
+- fprintf (errstd, "Cannot proceed. Maybe you need to add "
++ err = errno;
++ fprintf (errstd, "Cannot proceed. Maybe you need to add "
+ "this to your lilo.conf:\n"
+ "\tdisk=%s inaccessible\n"
+ "(real error shown below)\n", name);
+- die("open %s: %s",name,strerror(errno));
++ die("open %s: %s",name,strerror(err));
+ }
+ dev->name = stralloc(name);
+ return dev->fd;
+@@ -714,11 +716,11 @@
+
+ fd = dev_open(&dev, device, option ? O_RDWR : O_RDONLY);
+ if (read(fd, &buf, sizeof(buf)) != sizeof(buf)) {
+- fprintf (errstd, "Cannot proceed. Maybe you need to add "
++ fprintf (errstd, "Cannot proceed. Maybe you need to add "
+ "this to your lilo.conf:\n"
+ "\tdisk=%s inaccessible\n"
+ "(real error shown below)\n", dev.name);
+- die("VolumeID read error: sector 0 of %s not readable", dev.name);
++ die("VolumeID read error: sector 0 of %s not readable", dev.name);
+ }
+ if (option==ID_SET) {
+ make_backup(NULL, 0, &buf, device,