public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ed Sweetman <ed.sweetman@wmich.edu>
To: Walt H <waltabbyh@comcast.net>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Can't eject a previously mounted CD?
Date: Mon, 29 Dec 2003 02:56:58 -0500	[thread overview]
Message-ID: <3FEFDE4A.1030208@wmich.edu> (raw)
In-Reply-To: <3FEFA36A.5050307@comcast.net>

In your patch here i think the person who made the code originally 
confused or got wrong the conditions of success for opening the cdrom 
drive. This is in the same function as the patch applies to.

        if ((fp->f_flags & O_NONBLOCK) && (cdi->options & 
CDO_USE_FFLAGS))
                 ret = cdi->ops->open(cdi, 1); 

         else 

                 ret = open_for_data(cdi); 

 

         if (!ret) cdi->use_count++;

Here we see that if the open fails we incriment our use_count.  But this 
doesn't make sense. We increment the use_count at the  beginning of the 
function as a "lock" so that we can't do anything while the open 
function is executing like rmmod the cdrom (supposedly?).  Now removing 
the if(!ret) line makes sense. Under the out: label, if the open fails, 
then we close our makeshift lock on the device because our function is 
done. If it succeeded, then the use_count stays at 1 we go along our 
merry way.

> -Walt
> 
> --- /usr/src/linux/drivers/cdrom/cdrom.c        2003-12-25 09:53:59.000000000 -0800
> +++ linux-2.6.0-mm1/drivers/cdrom/cdrom.c       2003-12-28 19:42:04.174098225 -0800
> @@ -744,4 +744,7 @@
>         }
> 
> +       if (cdi->use_count > 0)
> +               cdi->use_count--;
> +
>         /* if this was a O_NONBLOCK open and we should honor the flags,
>          * do a quick open without drive/disc integrity checks. */
> @@ -931,5 +934,5 @@
>         struct cdrom_device_ops *cdo = cdi->ops;
> 
> -       cdinfo(CD_CLOSE, "entering cdrom_release\n");
> +       cdinfo(CD_CLOSE, "entering cdrom_release\n");
> 
>         if (cdi->use_count > 0)
> 
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 



  parent reply	other threads:[~2003-12-29  7:57 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-29  1:56 Can't eject a previously mounted CD? Walt H
2003-12-29  2:04 ` Ed Sweetman
2003-12-29  3:45   ` Walt H
2003-12-29  6:23     ` Ed Sweetman
2003-12-29  7:41       ` Ed Sweetman
2003-12-29  7:56     ` Ed Sweetman [this message]
2003-12-29 16:36       ` Walt H
2003-12-29 17:53         ` Ed Sweetman
2003-12-29 18:05           ` Walt H
2003-12-29 19:23           ` Walt H
2003-12-29 19:40             ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2003-12-27  0:31 Matt
2003-12-27  0:44 ` Rob Love
2003-12-27  1:13   ` Ed Sweetman
2003-12-27 15:11     ` Matt
2003-12-27  3:12 ` Joshua Kwan
2003-12-26  8:15 Joshua Kwan
2003-12-26 10:34 ` Vojtech Pavlik
2003-12-26 19:44   ` Joshua Kwan
2003-12-26 19:54     ` Samuel Flory
2003-12-26 20:27       ` Joshua Kwan
2003-12-26 23:26         ` Ed Sweetman
2003-12-26 23:56           ` Nuno Silva
2003-12-27  2:28             ` Joshua Kwan
2003-12-29  0:20         ` Samuel Flory
2003-12-29  0:28           ` Ed Sweetman
2003-12-29  1:36             ` Ed Sweetman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3FEFDE4A.1030208@wmich.edu \
    --to=ed.sweetman@wmich.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=waltabbyh@comcast.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox