hal and packet writing

Josh Boyer jwboyer at gmail.com
Wed Sep 24 06:25:44 PDT 2008


Hi All,

I've been looking at an issue we're having using hal to monitor the CD/DVD
drive for eject pressed events when using that drive for packet writing.
The basics of the problem boil down to the way that hal is checking for
media in the drive in conjunction with how packet writing works.

Hal will attempt to open the device, in this case /dev/sr0, with O_EXCL at
first.  If this fails, it looks to see if the device is mounted and if so
tries to open without O_EXCL.  My assumption here is that hal is trying to
avoid interfering with another process that may have the device opened for
buring an iso, hence the O_EXCL.  Apparently hal finds the condition of the
media being mounted to be safe, which is probably a fair assumption.

However, when packet writing is used a slightly different situation occurs.
A typical packet writing setup looks similar to:

pktsetup pktcdvd0 /dev/sr0
mount -t udf -o rw /dev/pktcdvd/pktcdvd0 /media

At this point, the packet writing code has done an implicit open on the
underlying physical device.  Hal cannot do an open with O_EXCL on /dev/sr0
any longer.  When it tries to check if the media is mounted, it fails because
the mount is on /dev/pktcdvd/pktcdvd0 and not /dev/sr0.  So hal will
essentially skip any checks on the drive until the media is unmounted.  At
that point, the packet writing code will have unlocked the drive door and
any eject events are missed.

I've been trying to think of a solution to having hal be able to monitor the
drive while it is being used for packet writing, but I'm by no means a hal
expert.  Does anyone have any suggestions as to how this could be achieved?

thx,
josh


More information about the hal mailing list