mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andries Brouwer <aebr@win.tue.nl>
To: Andries Brouwer <aebr@win.tue.nl>,
	Pierre Ossman <drzeus-list@drzeus.cx>,
	Al Viro <viro@ftp.uk.linux.org>, Jens Axboe <axboe@suse.de>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] MMC block removable flag
Date: Sat, 8 Jan 2005 14:07:11 +0100	[thread overview]
Message-ID: <20050108130711.GD6052@pclin040.win.tue.nl> (raw)
In-Reply-To: <20050108110957.D7065@flint.arm.linux.org.uk>

On Sat, Jan 08, 2005 at 11:09:57AM +0000, Russell King wrote:
> On Fri, Jan 07, 2005 at 03:00:35PM +0100, Andries Brouwer wrote:
> > On Fri, Jan 07, 2005 at 12:39:47PM +0000, Russell King wrote:
> > > Can anyone comment on the purpose of this (GENHD_FL_REMOVABLE) flag?
> > > Al?  Jens?
> > 
> > GENHD_FL_REMOVABLE is set by a number of drivers (floppy, CDROM, ...).
> > It is used in two places:
> > (1) to fill the file /sys/block/*/removable
> > (2) in genhd to suppress listing a nonpartitioned removable device
> > in /proc/partitions.
> > 
> > In other words, it is for user space only, precisely as Pierre Ossman said.
> 
> Your point 2 isn't user space though.

?? (1) Is about filling /sys/... and (2) about filling /proc/...
Both only have info for user space. The kernel does not react
to this flag.

> Also, it's buggy.  Consider a SCSI PCMCIA card with SCSI disks attached.
> When you eject that card, your SCSI disks disappear, yet they aren't
> marked as removable.  If user space is relying on /sys/block/*/removable
> to tell it if things may go away, then user space is buggy.

I think user space is pragmatic rather than correct.
When undesirable things happen someone will complain,
and the problem will be corrected somehow.

The distinction removable / non-removable is too primitive,
there are many variations involving chains of devices.

> Maybe it's for devices which may be present (eg, floppy driver), but
> which have removable media (eg, floppy disk), rather than removable
> devices?

I told you what it does. But you ask what it is intended for.
Then you must go to the person who first introduced it.
I guess that might have been Richard Gooch. The flag came in
in patch-2.3.46 with devfs. If it is was set, devfs would set
DEVFS_FL_REMOVABLE.

+- Added DEVFS_FL_REMOVABLE flag
+
+- Check for disc change when listing directories with
+  removable media devices

One has code like

+    if (flags & DEVFS_FL_REMOVABLE)
+    {
+       de->u.fcb.removable = TRUE;
+       ++de->parent->u.dir.num_removable;
+    }

and

+static void scan_dir_for_removable (struct devfs_entry *dir)
+/*  [SUMMARY] Scan a directory for removable media devices and check media.
+    <dir> The directory.
+    [RETURNS] Nothing.
+*/
+{
+    struct devfs_entry *de;
+
+    if (dir->u.dir.num_removable < 1) return;
+    for (de = dir->u.dir.first; de != NULL; de = de->next)
+    {
+       if (!de->registered) continue;
+       if ( !S_ISBLK (de->mode) ) continue;
+       if (!de->u.fcb.removable) continue;
+       check_disc_changed (de);
+    }
+}   /*  End Function scan_dir_for_removable  */

So here you have it. It is a devfs thing and could have been
removed when devfs was removed. However, today it is exported
in sysfs, and one must worry about possible users in user space.

Andries

      parent reply	other threads:[~2005-01-08 13:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-30  2:14 Pierre Ossman
2004-12-30  9:54 ` Russell King
2004-12-30 15:56   ` Pierre Ossman
2005-01-07 12:39     ` Russell King
2005-01-07 14:00       ` Andries Brouwer
2005-01-08 11:09         ` Russell King
2005-01-08 12:05           ` Christoph Hellwig
2005-01-08 12:45             ` Russell King
2005-01-08 13:07           ` Andries Brouwer [this message]

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=20050108130711.GD6052@pclin040.win.tue.nl \
    --to=aebr@win.tue.nl \
    --cc=axboe@suse.de \
    --cc=drzeus-list@drzeus.cx \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ftp.uk.linux.org \
    /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

all inboxes | Powered by JetHome®