public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] error value for opening block devices
@ 2004-03-20 10:13 Ulrich Drepper
  2004-03-22  3:57 ` Randy.Dunlap
  0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Drepper @ 2004-03-20 10:13 UTC (permalink / raw)
  To: Andrew Morton, Linux Kernel; +Cc: Linus Torvalds

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]

Opening a non-existing block device currently yields an ENXIO error.
Doing the same for char devices produces the correct error ENODEV.

The attached patch fixes the symptoms.  Somebody with more knowledge
will have to decide whether there are any negative side effects.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖

[-- Attachment #2: d-blk-enodev --]
[-- Type: text/plain, Size: 523 bytes --]

--- fs/block_dev.c-save	2004-03-12 11:44:14.000000000 -0800
+++ fs/block_dev.c	2004-03-20 01:53:19.000000000 -0800
@@ -550,7 +550,7 @@ static int do_open(struct block_device *
 {
 	struct module *owner = NULL;
 	struct gendisk *disk;
-	int ret = -ENXIO;
+	int ret = -ENODEV;
 	int part;
 
 	file->f_mapping = bdev->bd_inode->i_mapping;
@@ -563,6 +563,7 @@ static int do_open(struct block_device *
 	}
 	owner = disk->fops->owner;
 
+	ret = -ENXIO;
 	down(&bdev->bd_sem);
 	if (!bdev->bd_openers) {
 		bdev->bd_disk = disk;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] error value for opening block devices
  2004-03-20 10:13 [PATCH] error value for opening block devices Ulrich Drepper
@ 2004-03-22  3:57 ` Randy.Dunlap
  2004-03-22  4:13   ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Randy.Dunlap @ 2004-03-22  3:57 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: akpm, linux-kernel, torvalds

On Sat, 20 Mar 2004 02:13:47 -0800 Ulrich Drepper wrote:

| Opening a non-existing block device currently yields an ENXIO error.
| Doing the same for char devices produces the correct error ENODEV.
| 
| The attached patch fixes the symptoms.  Somebody with more knowledge
| will have to decide whether there are any negative side effects.

(now that this is merged...)

Isn't this going in the wrong direction, or am I just
mis-interpreting SUSv3?

Compare LSB bugzilla #115:
http://bugs.linuxbase.org/show_bug.cgi?id=115

open - open a file

...

ERRORS

[ENXIO]
O_NONBLOCK is set, the named file is a FIFO, O_WRONLY is set, and
no process has the file open for reading.

[ENXIO]
The named file is a character special or block special file, and
the device associated with this special file does not exist.


(Note:  ENODEV is not listed as a possible return value.)

--
~Randy
"You can't do anything without having to do something else first."
-- Belefant's Law

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] error value for opening block devices
  2004-03-22  3:57 ` Randy.Dunlap
@ 2004-03-22  4:13   ` Andrew Morton
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2004-03-22  4:13 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: drepper, linux-kernel, torvalds

"Randy.Dunlap" <rddunlap@osdl.org> wrote:
>
> [ENXIO]
>  The named file is a character special or block special file, and
>  the device associated with this special file does not exist.

Ho hum... It's chrdev_open which needs to be converted to return -ENXIO.

 25-akpm/fs/block_dev.c |    3 +--
 25-akpm/fs/char_dev.c  |    8 ++++----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff -puN fs/char_dev.c~chrdev_open-retval-fix fs/char_dev.c
--- 25/fs/char_dev.c~chrdev_open-retval-fix	2004-03-21 20:10:02.961332256 -0800
+++ 25-akpm/fs/char_dev.c	2004-03-21 20:13:18.975533568 -0800
@@ -265,7 +265,7 @@ int chrdev_open(struct inode * inode, st
 		spin_unlock(&cdev_lock);
 		kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
 		if (!kobj)
-			return -ENODEV;
+			return -ENXIO;
 		new = container_of(kobj, struct cdev, kobj);
 		spin_lock(&cdev_lock);
 		p = inode->i_cdev;
@@ -275,9 +275,9 @@ int chrdev_open(struct inode * inode, st
 			list_add(&inode->i_devices, &p->list);
 			new = NULL;
 		} else if (!cdev_get(p))
-			ret = -ENODEV;
+			ret = -ENXIO;
 	} else if (!cdev_get(p))
-		ret = -ENODEV;
+		ret = -ENXIO;
 	spin_unlock(&cdev_lock);
 	cdev_put(new);
 	if (ret)
@@ -285,7 +285,7 @@ int chrdev_open(struct inode * inode, st
 	filp->f_op = fops_get(p->ops);
 	if (!filp->f_op) {
 		cdev_put(p);
-		return -ENODEV;
+		return -ENXIO;
 	}
 	if (filp->f_op->open) {
 		lock_kernel();
diff -puN fs/block_dev.c~chrdev_open-retval-fix fs/block_dev.c
--- 25/fs/block_dev.c~chrdev_open-retval-fix	2004-03-21 20:10:02.978329672 -0800
+++ 25-akpm/fs/block_dev.c	2004-03-21 20:13:29.843881328 -0800
@@ -550,7 +550,7 @@ static int do_open(struct block_device *
 {
 	struct module *owner = NULL;
 	struct gendisk *disk;
-	int ret = -ENODEV;
+	int ret = -ENXIO;
 	int part;
 
 	file->f_mapping = bdev->bd_inode->i_mapping;
@@ -563,7 +563,6 @@ static int do_open(struct block_device *
 	}
 	owner = disk->fops->owner;
 
-	ret = -ENXIO;
 	down(&bdev->bd_sem);
 	if (!bdev->bd_openers) {
 		bdev->bd_disk = disk;

_


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-03-22  4:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-20 10:13 [PATCH] error value for opening block devices Ulrich Drepper
2004-03-22  3:57 ` Randy.Dunlap
2004-03-22  4:13   ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox