Comment 5 for bug 23203

Revision history for this message
Matthieu Patou (mat-matws) wrote :

The root problem is that cdrecord scan /dev/sg* device when you specify dev=bus,target,lun, because 1,0,0 is not necesserly mapped to /dev/sg1.
If you have a sata or scsi drive then you've got a /dev/sg* entry for this device and since it's a drive a simple user has no read/write access (hopefully).
What's happening is the following :you have (or k3b) had specifed a dev=bus,target,lun to cdrecord, so it will try to scan your /dev/sgx devices in order to know which corresponds to the value of bus,target and lun specified in the command line.
The devices will be scaned starting from /dev/sg0,if a hard drive has a number smaller than the cd burner, cdrecord will fail to open it and so quit and won't try devices after it.

So to sum up the problem is not that cdrecord maps incorrectly the bus,target,lun to /dev/sg* but just than it gives up a too easily and its errors message are not precise enougth.

you can check my assertion by :

* renaming /dev/sg0 to /dev/sg27
* renaming /dev/sg1 to /dev/sg14

* run as root (or sudo) cdrecord -scanbus and you will see that what ever the sg number is your cdburner has always the same bus,target,lun address.

* try to burn a cd as a normal user and see that it works (or burn to more precise).

The solution to the bug are not obvious:
* maybe it's possible to change udev rules to number the cdburner before the disks
* Add a parameter to cdrecord to tell him not to exist on the first device guess error, and to yell only if it fails to find the device specified in the parameter
* run cdrecord with setuid (or setgid)