[kde-freebsd] k3b freebsd contact
Andriy Gapon
avg at icyb.net.ua
Thu Oct 15 12:15:52 CEST 2009
on 14/10/2009 23:24 Heiner said the following:
> On Wednesday 14 October 2009, Andriy Gapon wrote:
>> 1. Without this k3b doesn't find my DVD writer. It seems that it tries
>> cam_open_pass on /dev/cd0 which fails.
>> Index: libk3bdevice/k3bdevice.cpp
>> ===================================================================
>> --- libk3bdevice/k3bdevice.cpp (revision 1034980)
>> +++ libk3bdevice/k3bdevice.cpp (working copy)
>> @@ -157,7 +157,7 @@
>> #ifdef Q_OS_FREEBSD
>> K3b::Device::Device::Handle K3b::Device::openDevice( const char* name,
>> bool write ) {
>> - K3b::Device::Device::Handle handle = cam_open_pass (name, O_RDWR,0 /*
>> NULL */); + K3b::Device::Device::Handle handle = cam_open_device( name,
>> O_RDWR ); kDebug() << "(K3b::Device::openDevice) open device " << name <<
>> ((handle)?" succeeded.":" failed.") << endl;
>> return handle;
>
> Hi!
>
> I am not sure, if this is a good idea. FreeBSD requires two devices to access
> the CD: the /dev/cdX and the /dev/passX device (and sometimes the bus, targt,
> lun ids). On the console, I read during the k3b startup:
Heiner,
I think that what you wrote is not entirely correct.
We don't have to access /dev/passX explicitly, passX is a pass-through companion
of a "real" device like cdX or daX. We can access cdX for reading and writing. For
sending custom SCSI command we need to use pass device.
We can manually find out which passX corresponds to cd0 and then use cam_open_pass
- this what your code does in current version of k3b in ports, I think.
But we also can simply call cam_open_device on cd0 and it would find appropriate
passX device internally. Resulting cam(3) 'handle' will be the same in both cases.
Bus, target, lun are available from the handle (struct cam_device), of course.
See descriptions of cam_open_pass() and cam_open_device() in cam(3).
There is the following note in that manual page:
cam_open_device() is rather simple
to use, but it is not really suitable for general use because its behav‐
ior is not necessarily deterministic. Programmers writing new applica‐
tions should make the extra effort to use one of the other open routines
documented below.
But I am not sure now valid it is. Because I can't imagine that it is principally
impossible to put the same code into libcam that a programmer would put in his
code. I.e. I don't think that I could do cdX to passX any smarter than
cam_open_device does it. And if I could, then I'd rather put that code into
cam_open_device anyway, so that everyone could benefit from it.
> (BSDDeviceScan) number of matches 23
> (BSDDeviceScan) periph: cd0
> (BSDDeviceScan) periph: pass0
> (BSDDeviceScan) add device /dev/cd0:2:0:0 (/dev/pass0)
> (K3bDevice::Device) /dev/cd0: init()
> (K3bDevice::openDevice) open device /dev/pass0 succeeded.
>
> This means, that my /dev/cd0 is aquivalent to /dev/pass1 and has the ids
> 2:0:0. From your error description, I guess, that on your system the cdX and
> passX are mixed. So I expect the following on your console:
>
> (BSDDeviceScan) number of matches 23
> (BSDDeviceScan) periph: pass0 <- should be cd0
> (BSDDeviceScan) periph: cd0 <- should be pass0
> (BSDDeviceScan) add device /dev/pass0:2:0:0 (/dev/cd0) <- wrong!!
> (K3bDevice::Device) /dev/pass0: init() <- should be cd0
> (K3bDevice::openDevice) open device /dev/cd0 failed. <- should be pass0
No, this is not what happens.
> Your patch would make init run on your system but break it on other systems.
No, everything works OK.
> Furthermore other things won't work on your system as well (if cdX is
> expected).
Not sure what things you mean.
Haven't noticed any problems so far.
> I would recommend to look at K3bDevice::DeviceManager::BSDDeviceScan().
> Obvioulsy in FreeBSD 8 the cam has changed and the devices might be ordered
> differently. The code you see there was initially taken from the camcontrol
> sources, so looking, what "camcontrol devlist" in its sources does is a good
> start. I guess, that something has changed here since FreeBSD 7.x A fix
> should make sure, that device->m_passDevice always points to a passX and
> cddev to the cdX.
The thing is that there is no BSDDeviceScan in the latest version of k3b (e.g. in
svn or 1.66.0). The way of discovering devices is different now.
--
Andriy Gapon
More information about the kde-freebsd
mailing list