Comment 16 for bug 1203559

Revision history for this message
Ray Maslinski (ray-maslinski) wrote :

The change of device name should probably also be accompanied by an update to the check_linux_26 function defined in the same scsi-linux-sg.c file, which doesn't appear to deal with kernel major versions > 2:

BOOL check_linux_26() {
        int gen, tmp;
        struct utsname buf;
        return ( 0==uname( &buf ) && sscanf(buf.release, "%d.%d", &gen, &tmp)>1
&& tmp>=6);
}

Note that the check is only looking for the minor version > 6, so the behavior will revert to pre-2.6 device selection for kernel versions 3.0-3.5, 4.0-4.5, etc.

The pre-2.6 behavior uses /dev/sg* devices instead of /dev/scd* (or /dev/sr* with the previously attached patch), probably due to lack of support required in earlier driver versions. While this will probably work most of the time, I think there may be a potential for contention with other applications using the device, as there doesn't appear to be a locking mechanism across the /dev/sg* and /dev/sr* devices. This could allow (for example) an audio player using a /dev/sr* device to interfere with wodim if it's using /dev/sg* for access. Using the same device driver for all access to the cd device should allow for appropriate locking to prevent concurrent access. There's a warning in the code to this effect, though it seems to be disabled:

                                case(SG):
                                        {
                                                if(check_linux_26())
                                                        continue;
#if 0
                                                /*
                                                 * Don't touch it on 2.6 until w
e have a proper locking scheme
                                                 */
                                                        if(nopen<=0)
                                                                fprintf(stderr,
"Warning, using /dev/sg* for SG_IO operation. This method is considered harmful.
\n");
                                                        else if(found_scd)
                                                                continue;
#endif
                                                pattern="/dev/sg%d";
                                                first=0;
                                                last=255;
                                                break;
                                        }

There are a few other places referencing check_linux_26 beyond device selection, presumably these would also behave more correctly with newer kernels with a revised version check.