Please see similar source code from the deprecated HAL.:
hal/hald/linux/addons/addon-storage.c:
While UDIsks add O_EXCL unconditionally, HAL tries O_EXCL first, and
if the device is busy, in some cases it does it without that flag.

static gboolean
poll_for_media_force (void)
{
        int fd;
        int got_media;
        int old_media_status;

        got_media = FALSE;

        old_media_status = media_status;
        if (is_cdrom) {
                int drive;
                
                fd = open (device_file, O_RDONLY | O_NONBLOCK | O_EXCL);
                
                if (fd < 0 && errno == EBUSY) {
                        /* this means the disc is mounted or some other app,
                         * like a cd burner, has already opened O_EXCL */
                        
                        /* HOWEVER, when starting hald, a disc may be
                         * mounted; so check /etc/mtab to see if it
                         * actually is mounted. If it is we retry to open
                         * without O_EXCL
                         */
                        if (!is_mounted (device_file)) {
                                if (!is_locked_via_o_excl) {
                                        is_locked_via_o_excl = TRUE;
                                        update_proc_title ();
                                } else {
                                        is_locked_via_o_excl = TRUE;
                                }
                                goto skip_check;
                        }
                        
                        fd = open (device_file, O_RDONLY | O_NONBLOCK);
                }
....
_______________________________________________
devkit-devel mailing list
devkit-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/devkit-devel

Reply via email to