From: Joachim Wiedorn Date: Fri, 11 Mar 2011 19:36:54 +0000 (+0100) Subject: Fix: save errno for second command X-Git-Tag: debian/23.1-2~24 X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=bc8fc5ad2c94db7f2ee096e1de07893e439d779a;p=rrq%2Fmaintain_lilo.git Fix: save errno for second command --- diff --git a/debian/changelog b/debian/changelog index c764729..d726381 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ lilo (1:23.1-2) unstable; urgency=low * debian/control: - Remove dependency to lilo in package lilo-doc. (Closes: #613753) + * Fix: save errno for second command (device.c). -- Joachim Wiedorn Thu, 17 Feb 2011 21:39:38 +0100 diff --git a/debian/patches/12_save-errno-for-second-command.patch b/debian/patches/12_save-errno-for-second-command.patch new file mode 100644 index 0000000..f21597d --- /dev/null +++ b/debian/patches/12_save-errno-for-second-command.patch @@ -0,0 +1,51 @@ +Package: lilo +Subject: save errno for second command +Author: Joachim Wiedorn +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, diff --git a/debian/patches/series b/debian/patches/series index fa3c5e2..e9ca378 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -9,3 +9,4 @@ 09_use-of-newer-debhelper.patch 10_add-info-about-h-option.patch 11_remove-obsolete-bios-workaround.patch +12_save-errno-for-second-command.patch diff --git a/debian/patches/ubuntu.series b/debian/patches/ubuntu.series index fcf4139..de8414a 100644 --- a/debian/patches/ubuntu.series +++ b/debian/patches/ubuntu.series @@ -9,3 +9,4 @@ 09_use-of-newer-debhelper.patch 10_add-info-about-h-option.patch 11_remove-obsolete-bios-workaround.patch +12_save-errno-for-second-command.patch