$NetBSD: patch-ac,v 1.1.1.1 2007/04/29 16:15:17 dhowland Exp $

--- src/disc/cdrom.py.orig	2007-03-28 05:18:02.000000000 -0400
+++ src/disc/cdrom.py
@@ -112,16 +112,20 @@ def _drive_status(device, handle_mix = 0
     # XXX 0xc0086305 below creates a warning, but 0xc0086305L
     # doesn't work. Suppress that warning for Linux users,
     # until a better solution can be found.
-    if os.uname()[0] == 'FreeBSD':
-        CDIOREADTOCENTRYS = 0xc0086305L
+    if ((os.uname()[0] == 'FreeBSD') or (os.uname()[0] == 'NetBSD')):
+	CDIOREADTOCENTRYS = int(-(0xc0086305 ^ 0xffffffff)-1)
         CD_MSF_FORMAT = 2
 
     fd = None
     try:
         fd = os.open(device, os.O_RDONLY | os.O_NONBLOCK)
-        if os.uname()[0] == 'FreeBSD':
+        if ((os.uname()[0] == 'FreeBSD') or (os.uname()[0] == 'NetBSD')):
             try:
-                cd_toc_entry = array.array('c', '\000'*4096)
+                if (os.uname()[0] == 'NetBSD'):
+		    #length value has to fit inside u_char
+		    cd_toc_entry = array.array('c', '\000'*255)
+		else:
+		    cd_toc_entry = array.array('c', '\000'*4096)
                 (address, length) = cd_toc_entry.buffer_info()
                 buf = pack('BBHP', CD_MSF_FORMAT, 0, length, address)
                 s = ioctl(fd, CDIOREADTOCENTRYS, buf)
@@ -152,7 +156,7 @@ def _drive_status(device, handle_mix = 0
             pass
         return 0
 
-    if os.uname()[0] == 'FreeBSD':
+    if ((os.uname()[0] == 'FreeBSD') or (os.uname()[0] == 'NetBSD')):
         s = 0
         # We already have the TOC from above
         for i in range(0, 4096, 8):
@@ -227,7 +231,7 @@ def status(device, handle_mix=0):
     else:
         f = open(device,'rb')
 
-        if os.uname()[0] == 'FreeBSD':
+	if ((os.uname()[0] == 'FreeBSD') or (os.uname()[0] == 'NetBSD')):
             # FreeBSD can only seek to 2048 multiple boundaries.
             # Below works on Linux and FreeBSD:
             f.seek(32768)
