]> git.gag.com Git - debian/cpmtools/commitdiff
patch to fix libdsk interaction problem master debian/2.23-6
authorBdale Garbee <bdale@gag.com>
Fri, 27 Sep 2024 02:48:49 +0000 (20:48 -0600)
committerBdale Garbee <bdale@gag.com>
Fri, 27 Sep 2024 02:48:49 +0000 (20:48 -0600)
debian/changelog
debian/patches/cpmtools-libdsk-probe-robustness.patch [new file with mode: 0644]
debian/patches/series

index dd009df52c640f75d3dfa67a7a574eb673d1f5e4..2ff3c2190c5fcc3418121629cf7b92ee872c63c1 100644 (file)
@@ -1,3 +1,10 @@
+cpmtools (2.23-6) unstable; urgency=low
+
+  * patch from Jacob Nevins for libdsk probe robustness expected to be in 
+    2.24 when released, closes: #1079619
+
+ -- Bdale Garbee <bdale@gag.com>  Thu, 26 Sep 2024 20:46:26 -0600
+
 cpmtools (2.23-5) unstable; urgency=low
 
   * elide processed man pages from repo, ensure they're removed in
diff --git a/debian/patches/cpmtools-libdsk-probe-robustness.patch b/debian/patches/cpmtools-libdsk-probe-robustness.patch
new file mode 100644 (file)
index 0000000..915007b
--- /dev/null
@@ -0,0 +1,54 @@
+Subject: libdsk: reset geometry if autoprobe isn't sane
+
+So that weirdness from any misfiring auto-geometry heuristic in LibDsk
+doesn't cause trouble later. (We were overwriting the most common
+parameters, but not all of them.)
+(Triggered by Debian bug #1079619, where a spurious dg_sidedness caused
+trouble after LibDsk's Opus Discovery heuristic misfired -- that
+heuristic has been improved in libdsk 1.5.20, but this change provides
+defence in depth.)
+---
+ device_libdsk.c | 18 +++++++++++++++---
+ 1 file changed, 15 insertions(+), 3 deletions(-)
+
+diff --git a/device_libdsk.c b/device_libdsk.c
+index 7baaed4..82b79d1 100644
+--- a/device_libdsk.c
++++ b/device_libdsk.c
+@@ -72,6 +72,7 @@ const char *Device_open(struct Device *this, const char *filename, int mode, con
+ const char *Device_setGeometry(struct Device *this, int secLength, int sectrk, int tracks, off_t offset, const char *libdskGeometry)
+ {
+   char *boo;
++  int probeOk;
+   this->secLength=secLength;
+   this->sectrk=sectrk;
+@@ -85,11 +86,22 @@ const char *Device_setGeometry(struct Device *this, int secLength, int sectrk, i
+     return lookupFormat(&this->geom, libdskGeometry);
+   }
+   
++  /* Did the autoprobe guess right about the number of sectors & cylinders? */
++  if (this->geom.dg_cylinders * this->geom.dg_heads == tracks)
++  {
++    probeOk = 1;
++  }
++  else
++  {
++    /* If not, reset to a minimal geometry (to undo any randomness from
++     * a failed autoprobe), and guess some parameters */
++    probeOk = 0;
++    dg_stdformat(&this->geom, FMT_180K, NULL, NULL);
++  }
+   this->geom.dg_secsize   = secLength;
+   this->geom.dg_sectors   = sectrk;
+-  /* Did the autoprobe guess right about the number of sectors & cylinders? */
+-  if (this->geom.dg_cylinders * this->geom.dg_heads == tracks) return NULL;
+-  /* Otherwise we guess: <= 43 tracks: single-sided. Else double. This
++  if (probeOk) return NULL;
++  /* We guess: <= 43 tracks: single-sided. Else double. This
+    * fails for 80-track single-sided if there are any such beasts */
+   if (tracks <= 43) 
+   {
+-- 
+2.30.2
+
index 36ff2b3b3ad7b566f5ed341ca8ca305afd754d4e..383978c09b927dcc5a22e8ea40e2cb5d3bc29370 100644 (file)
@@ -1,2 +1,3 @@
 man-page-typos.diff
 man-page-font.diff
+cpmtools-libdsk-probe-robustness.patch