[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: BD-RE mount problem


i can reproduce the symptoms by a read-only situation of drive and
media. (It should not happen with BD-RE in a BD writer, of course.)

open_sr0.c with O_NDELAY yielded:
> open: fd= 3 , errno= 0
> write: ret= 2048 , errno= 0

I get the same behavior when i put a DVD into a DVD-ROM drive.
It allows me to dump my data into a black hole and reports no error
to the userspace program.
In /var/log/messages i find

  sr 6:0:0:0: [sr1] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
  sr 6:0:0:0: [sr1] Sense Key : Illegal Request [current]
  sr 6:0:0:0: [sr1] Add. Sense: Invalid command operation code
  sr 6:0:0:0: [sr1] CDB: Write(10): 2a 00 00 00 00 00 00 00 01 00
  lost page write due to I/O error on sr1

Looks like an old kernel bug resp. unwanted way to silently
shoot your own foot.
It happens too with 8 subsequent write() calls with sleep(1) inbetween.
No delayed error is returned.


I dug out the reason why libburn (underneath xorriso) uses O_NDELAY
when it opens the drive device file.

A note to myself in libburn/sg-linux.c:

           O_NONBLOCK is prescribed by <linux/cdrom.h>
           Switched to O_NDELAY for LKML statement 2007/4/11/141 by Alan Cox:
           "open() has side effects. The CD layer allows you to open
            with O_NDELAY if you want to avoid them."

In Debian squeeze's /usr/include/linux/cdrom.h:

 * Additionally, as of Linux 2.1.x, all Linux application programs
 * should use the O_NONBLOCK option when opening a CD-ROM device
 * for subsequent ioctl commands.  This allows for neat system errors
 * like "No medium found" or "Wrong medium type" upon attempting to
 * mount or play an empty slot, mount an audio disc, or play a data disc.

This explains why open() does not fail with O_NDELAY (= O_NOBLOCK):
For ioctl(SG_IO) one needs w-permission. So it must tolerate
But why does not write(2) fail afterwards ?

Have a nice day :)


Reply to: