Hi,

The following diff fixes the use of a device node as a disk in fs-uae.

Some of this stuff I sent upstream and they accepted it.

While I am here, annotate existing diffs with their meaning.

OK?

Index: Makefile
===================================================================
RCS file: /cvs/ports/emulators/fs-uae/Makefile,v
retrieving revision 1.11
diff -u -p -r1.11 Makefile
--- Makefile    7 Jul 2013 19:32:38 -0000       1.11
+++ Makefile    4 Sep 2013 19:40:21 -0000
@@ -5,6 +5,7 @@ BROKEN-sparc64 =        error: invalid 'asm': i
 
 COMMENT =              modern Amiga emulator
 V =                    2.2.3
+REVISION =             0
 MODPY_EGG_VERSION =    ${V}
 DISTNAME =             fs-uae-$V
 CATEGORIES =           emulators
Index: patches/patch-Makefile
===================================================================
RCS file: /cvs/ports/emulators/fs-uae/patches/patch-Makefile,v
retrieving revision 1.2
diff -u -p -r1.2 patch-Makefile
--- patches/patch-Makefile      31 Mar 2013 20:16:10 -0000      1.2
+++ patches/patch-Makefile      4 Sep 2013 19:40:21 -0000
@@ -1,4 +1,7 @@
 $OpenBSD: patch-Makefile,v 1.2 2013/03/31 20:16:10 edd Exp $
+
+Disable custom optimisation flags.
+
 --- Makefile.orig      Sun Mar 24 23:49:51 2013
 +++ Makefile   Sun Mar 24 23:50:00 2013
 @@ -88,14 +88,6 @@ endif
Index: patches/patch-launcher_fs_uae_launcher_ChecksumTool_py
===================================================================
RCS file: patches/patch-launcher_fs_uae_launcher_ChecksumTool_py
diff -N patches/patch-launcher_fs_uae_launcher_ChecksumTool_py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-launcher_fs_uae_launcher_ChecksumTool_py      4 Sep 2013 
19:40:21 -0000
@@ -0,0 +1,43 @@
+$OpenBSD$
+
+Make checksumtool size aware.
+
+--- launcher/fs_uae_launcher/ChecksumTool.py.orig      Wed Sep  4 10:09:47 2013
++++ launcher/fs_uae_launcher/ChecksumTool.py   Wed Sep  4 10:09:50 2013
+@@ -8,8 +8,13 @@ import fs_uae_launcher.fsui as fsui
+ from .Archive import Archive
+ from .ROMManager import ROMManager
+ 
++import os.path
++
+ class ChecksumTool():
+ 
++    TOO_BIG = 64*1024*1024
++    ZERO_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709"
++
+     def __init__(self, parent):
+         self.parent = parent
+         #fsui.Window.__init__(self, parent, "Checksumming")
+@@ -21,7 +26,21 @@ class ChecksumTool():
+         ##self.center_on_parent()
+ 
+     def checksum(self, path):
+-        print("checksum", repr(path))
++        # first check that we even want to checksum
++        size = os.path.getsize(path)
++        if size >= ChecksumTool.TOO_BIG:
++            print("checksumtool: not checksumming large file: %s" % path)
++            return ""
++        elif size == 0:
++            # either a real 0-byte file or a device node on a BSD           
++            # system (could be large). To reliably get the size we could    
++            # use ioctl, but we simply return the checksum for a 0-byte     
++            # file anyway                                               
++            print("checksumtool: not checksumming zero "
++                    "sized file/device: %s" % path)
++            return ChecksumTool.ZERO_SHA1
++
++        print("checksumtool: checksumming ", repr(path))
+         archive = Archive(path)
+         s = hashlib.sha1()
+         f = archive.open(path)
Index: patches/patch-launcher_fs_uae_launcher_Config_py
===================================================================
RCS file: patches/patch-launcher_fs_uae_launcher_Config_py
diff -N patches/patch-launcher_fs_uae_launcher_Config_py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-launcher_fs_uae_launcher_Config_py    4 Sep 2013 19:40:21 
-0000
@@ -0,0 +1,20 @@
+$OpenBSD$
+
+Don't checksum device nodes (which report as size 0)
+
+--- launcher/fs_uae_launcher/Config.py.orig    Tue Jun 25 20:21:16 2013
++++ launcher/fs_uae_launcher/Config.py Wed Sep  4 10:11:48 2013
+@@ -477,12 +477,7 @@ class Config:
+                 # could set a fake checksum here or something, to indicate
+                 # that it isn't supposed to be set..
+                 return
+-            print("checksumming", repr(path))
+-            if os.path.getsize(path) > 64 * 1024 * 1024:
+-                # not checksumming large files righ now
+-                print("not checksumming large file")
+-                return
+-            if is_rom:
++            elif is_rom:
+                 sha1 = checksum_tool.checksum_rom(path)
+             else:
+                 sha1 = checksum_tool.checksum(path)
Index: patches/patch-launcher_fs_uae_launcher_fsui_wx_filedialog_py
===================================================================
RCS file: patches/patch-launcher_fs_uae_launcher_fsui_wx_filedialog_py
diff -N patches/patch-launcher_fs_uae_launcher_fsui_wx_filedialog_py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-launcher_fs_uae_launcher_fsui_wx_filedialog_py        4 Sep 
2013 19:40:21 -0000
@@ -0,0 +1,15 @@
+$OpenBSD$
+
+Allow device nodes to appear in file choosers.
+
+--- launcher/fs_uae_launcher/fsui/wx/filedialog.py.orig        Wed Sep  4 
09:51:41 2013
++++ launcher/fs_uae_launcher/fsui/wx/filedialog.py     Wed Sep  4 09:51:50 2013
+@@ -7,7 +7,7 @@ import wx
+ 
+ class FileDialog():
+     def __init__(self, parent, message="", directory="", file="",
+-            pattern="*.*", multiple=False, dir_mode=False):
++            pattern="*", multiple=False, dir_mode=False):
+         #if parent:
+         #    p = parent.get_real_parent()
+         #    parent = p._container
Index: patches/patch-launcher_fs_uae_launcher_ui_config_HardDriveGroup_py
===================================================================
RCS file: patches/patch-launcher_fs_uae_launcher_ui_config_HardDriveGroup_py
diff -N patches/patch-launcher_fs_uae_launcher_ui_config_HardDriveGroup_py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-launcher_fs_uae_launcher_ui_config_HardDriveGroup_py  4 Sep 
2013 19:40:21 -0000
@@ -0,0 +1,19 @@
+$OpenBSD$
+
+Moved the size logic into checksumtool instances.
+
+--- launcher/fs_uae_launcher/ui/config/HardDriveGroup.py.orig  Wed Sep  4 
10:15:46 2013
++++ launcher/fs_uae_launcher/ui/config/HardDriveGroup.py       Wed Sep  4 
10:16:08 2013
+@@ -105,11 +105,7 @@ class HardDriveGroup(fsui.Group):
+         if dir_mode:
+             print("not calculating HD checksums for directories")
+         else:
+-            size = os.path.getsize(path)
+-            if size < 64*1024*1024:
+-                sha1 = checksum_tool.checksum(path)
+-            else:
+-                print("not calculating HD checksums HD files > 64MB")
++            sha1 = checksum_tool.checksum(path)
+         full_path = path
+ 
+         # FIXME: use contract function
Index: patches/patch-libfsemu_Makefile
===================================================================
RCS file: /cvs/ports/emulators/fs-uae/patches/patch-libfsemu_Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 patch-libfsemu_Makefile
--- patches/patch-libfsemu_Makefile     31 Mar 2013 20:16:10 -0000      1.3
+++ patches/patch-libfsemu_Makefile     4 Sep 2013 19:40:21 -0000
@@ -1,4 +1,7 @@
 $OpenBSD: patch-libfsemu_Makefile,v 1.3 2013/03/31 20:16:10 edd Exp $
+
+Remove custom optimisation flags.
+
 --- libfsemu/Makefile.orig     Sun Mar 24 23:51:27 2013
 +++ libfsemu/Makefile  Sun Mar 24 23:52:30 2013
 @@ -104,12 +104,6 @@ ifeq ($(devel), 1)
Index: patches/patch-src_fs-uae_main_c
===================================================================
RCS file: /cvs/ports/emulators/fs-uae/patches/patch-src_fs-uae_main_c,v
retrieving revision 1.2
diff -u -p -r1.2 patch-src_fs-uae_main_c
--- patches/patch-src_fs-uae_main_c     4 May 2013 17:17:05 -0000       1.2
+++ patches/patch-src_fs-uae_main_c     4 Sep 2013 19:40:21 -0000
@@ -1,4 +1,7 @@
 $OpenBSD: patch-src_fs-uae_main_c,v 1.2 2013/05/04 17:17:05 edd Exp $
+
+Unbreak joystick detection. Committed upstream.
+
 --- src/fs-uae/main.c.orig     Fri Apr 19 18:06:24 2013
 +++ src/fs-uae/main.c  Sat May  4 17:04:30 2013
 @@ -569,6 +569,7 @@ void list_joysticks() {
Index: patches/patch-src_od-fs_hardfile_host_cpp
===================================================================
RCS file: patches/patch-src_od-fs_hardfile_host_cpp
diff -N patches/patch-src_od-fs_hardfile_host_cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_od-fs_hardfile_host_cpp   4 Sep 2013 19:40:21 -0000
@@ -0,0 +1,80 @@
+$OpenBSD$
+
+Fix device node hard disk access. Committed upstream.
+
+--- src/od-fs/hardfile_host.cpp.orig   Tue Jun 25 20:21:17 2013
++++ src/od-fs/hardfile_host.cpp        Tue Sep  3 21:04:55 2013
+@@ -19,6 +19,14 @@
+ #include <sys/disk.h>
+ #endif
+ 
++#ifdef OPENBSD
++#include <sys/types.h>
++#include <sys/disklabel.h>
++#include <sys/dkio.h>
++#include <sys/ioctl.h>
++#include <fcntl.h>
++#endif
++
+ #define hfd_log write_log
+ static int g_debug = 0;
+ 
+@@ -291,8 +299,9 @@ int hdf_open_target (struct hardfiledata *hfd, const c
+         if (h != INVALID_HANDLE_VALUE) {
+             // determine size of hdf file
+             int ret;
+-            off_t low;
+-#ifdef MACOSX
++            off_t low = -1;
++
++#if defined(MACOSX) || defined(OPENBSD)
+             // check type of file
+             struct stat st;
+             ret = stat(name,&st);
+@@ -300,11 +309,12 @@ int hdf_open_target (struct hardfiledata *hfd, const c
+                 write_log("osx: can't stat '%s'\n", name);
+                 goto end;
+             }
+-            // block devices need special handling on osx
++            // block devices need special handling on BSD and OSX
+             if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)) {
++                int fh = fileno(h);
++#if defined(MACOSX)
+                 uint32_t block_size;
+                 uint64_t block_count;
+-                int fh = fileno(h);
+                 // get number of blocks
+                 ret = ioctl(fh, DKIOCGETBLOCKCOUNT, &block_count);
+                 if (ret) {
+@@ -322,19 +332,20 @@ int hdf_open_target (struct hardfiledata *hfd, const c
+                 write_log("osx: found raw device: block_size=%u "
+                         "block_count=%llu\n", block_size, block_count);
+                 low = block_size * block_count;
+-            }
+-            else {
++#elif defined(OPENBSD)
++                struct disklabel label;
++                if (ioctl(fh, DIOCGDINFO, &label) < 0) {
++                    write_log("openbsd: can't get disklabel of '%s' (%d)\n", 
name);
++                    goto end;
++                }
++                write_log("openbsd: bytes per sector: %u\n", label.d_secsize);
++                write_log("openbsd: sectors per unit: %u\n", 
label.d_secperunit);
++                low = label.d_secsize * label.d_secperunit;
++                write_log("openbsd: total bytes: %llu\n", low);
+ #endif
+-            // regular file size: seek to end and ftell
+-            ret = uae_fseeko64 (h, 0, SEEK_END);
+-            if (ret)
+-                goto end;
+-            low = uae_ftello64 (h);
+-            if (low == -1)
+-                goto end;
+-#ifdef MACOSX
+             }
+-#endif
++#endif // OPENBSD || MACOSX
++
+             low &= ~(hfd->blocksize - 1);
+             hfd->physsize = hfd->virtsize = low;
+             if (g_debug) {

-- 
Best Regards
Edd Barrett

http://www.theunixzoo.co.uk

Reply via email to