ia64/xen-unstable

changeset 941:72b0ba1bfefb

bitkeeper revision 1.596.1.2 (3fb36386_diWp9iTBJCjk8zK8bRIEw)

tweaks
author smh22@labyrinth.cl.cam.ac.uk
date Thu Nov 13 10:57:10 2003 +0000 (2003-11-13)
parents cfd9961afd8b
children 7ae6b4359a0d db2e1ea917df
files xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.c
line diff
     1.1 --- a/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.c	Wed Nov 12 18:59:01 2003 +0000
     1.2 +++ b/xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.c	Thu Nov 13 10:57:10 2003 +0000
     1.3 @@ -69,10 +69,23 @@ int xenolinux_block_open(struct inode *i
     1.4      short xldev = inode->i_rdev; 
     1.5      struct gendisk *gd = xldev_to_gendisk(xldev);
     1.6      xl_disk_t *disk = xldev_to_xldisk(inode->i_rdev);
     1.7 +    short minor = MINOR(xldev); 
     1.8  
     1.9 -    /* Don't allow open if device doesn't exist :-) */
    1.10 -    if(!gd->part[MINOR(xldev)].nr_sects) 
    1.11 -	return -ENXIO; // no such device 
    1.12 +    if(!gd->part[minor].nr_sects) { 
    1.13 +	/* Device either doesn't exist, or has zero capacity; we use 
    1.14 +	   a few cheesy heuristics to return the relevant error code */
    1.15 +	if(disk->capacity || (minor & (gd->max_p - 1))) { 
    1.16 +	    // we have a real device, but no such partition, or we just 
    1.17 +	    // have a partition number so guess this is the problem 
    1.18 +	    return -ENXIO;     // no such device or address 
    1.19 +	} else if (gd->flags[minor >> gd->minor_shift] & GENHD_FL_REMOVABLE) {
    1.20 +	    // this is a removable device => assume that media is missing 
    1.21 +	    return -ENOMEDIUM; // media not present (this is a guess) 
    1.22 +	} else 
    1.23 +	    // just go for the general 'no such device' error
    1.24 +	    return -ENODEV;    // no such device
    1.25 +    }
    1.26 +
    1.27  
    1.28      disk->usage++;
    1.29      DPRINTK("xenolinux_block_open\n");