Against current branch (so 100% incompatible with release branch), updated patch. Please test.
--
These are your friends - Adem
GPG: FEA2 A3FE Adriaan de Groot
Index: audiocd.cpp
===================================================================
--- audiocd.cpp (revision 494420)
+++ audiocd.cpp (working copy)
@@ -56,6 +56,12 @@
#include <client.h>
#include "kcompactdisc.h"
+/* To work around brain-deadness of cdparanoia in FreeBSD, we need
+ to reverse-map an open file-descriptor to a pathname. This is a
+ "best guess" approach.
+*/
+static QString reverseMap( int fd ) ;
+
using namespace KIO;
using namespace KCDDB;
@@ -218,7 +224,36 @@
#if defined(Q_OS_LINUX)
d->cd.setDevice(drive->cdda_device_name, 50, false);
#elif defined(Q_OS_FREEBSD)
- d->cd.setDevice(drive->dev->device_path);
+ if ( !(drive->dev) || (COOKED_IOCTL == drive->interface) )
+ {
+ kdDebug(7117) << "The device does not seem to be a SCSI drive." << endl;
+
+ if ( !(d->device.isEmpty()) )
+ {
+ kdDebug(7117) << "Using explicitly requested device " << d->device << endl;
+ d->cd.setDevice( d->device );
+ }
+ else
+ {
+ d->cd.setDevice( reverseMap( drive->ioctl_fd ) );
+ }
+ }
+ else
+ {
+ if ( strlen(drive->dev->device_path) )
+ {
+ kdDebug(7117) << "Using SCSI device " << drive->dev->device_path << endl;
+ d->cd.setDevice(drive->dev->device_path);
+ }
+ else
+ {
+ kdDebug(7117) << "No device_path was set." << endl;
+ char devname[MAXPATHLEN];
+ snprintf(devname, MAXPATHLEN, "/dev/%s%i", drive->dev->given_dev_name, drive->dev->given_unit_number);
+ kdDebug(7117) << " Using derived name " << devname << endl;
+ d->cd.setDevice( devname );
+ }
+ }
#endif
if (d->cd.discId() != d->discid && d->cd.discId() != d->cd.missingDisc){
@@ -1099,3 +1134,52 @@
}
}
+
+static QString reverseMap( int fd )
+{
+#ifndef Q_OS_FREEBSD
+ return QString();
+#else
+
+ typedef QPair<dev_t,ino_t> DeviceAndInode;
+ DeviceAndInode targetUnit;
+ struct stat s;
+
+ /* Potential CDROM device names. This list is only partial. */
+ static const char *potentialPaths[] = {
+ "/dev/acd0",
+ "/dev/acd1",
+ "/dev/acd0c",
+ "/dev/acd1c",
+ "/dev/acd2",
+ "/dev/acd2c"
+ } ;
+
+
+ if ( fstat(fd,&s)<0 )
+ {
+ kdDebug(7117) << "ioctl() fd is not fstat()able." << endl;
+ return QString();
+ }
+
+ targetUnit = DeviceAndInode(s.st_dev,s.st_ino);
+
+ const char **currentPath = potentialPaths;
+ while ( *currentPath )
+ {
+ if ( stat(*currentPath,&s) == 0 )
+ {
+ DeviceAndInode currentUnit = DeviceAndInode(s.st_dev,s.st_ino);
+
+ if ( targetUnit == currentUnit )
+ {
+ return QString(*currentPath);
+ }
+ }
+
+ currentPath++;
+ }
+
+ return QString();
+#endif
+}
pgpVzwFi2ECFP.pgp
Description: PGP signature
_______________________________________________ kde-freebsd mailing list [email protected] http://freebsd.kde.org/mailman/listinfo/kde-freebsd
