ia64/xen-unstable

changeset 629:035d887bdfc7

bitkeeper revision 1.339.1.13 (3f133e41JY3T8AGVWEoFdVWiKkJdvQ)

xeno.c:
Fix Xenolinux to mark protected disc partitions as read-only.
author kaf24@scramble.cl.cam.ac.uk
date Mon Jul 14 23:35:29 2003 +0000 (2003-07-14)
parents 6d07235a19e8
children 4fd1861ec41a 2aedb293ebd7
files xenolinux-2.4.21-sparse/fs/partitions/xeno.c
line diff
     1.1 --- a/xenolinux-2.4.21-sparse/fs/partitions/xeno.c	Mon Jul 14 22:10:03 2003 +0000
     1.2 +++ b/xenolinux-2.4.21-sparse/fs/partitions/xeno.c	Mon Jul 14 23:35:29 2003 +0000
     1.3 @@ -3,6 +3,7 @@
     1.4  #include <linux/kernel.h>
     1.5  #include <asm/hypervisor.h>
     1.6  #include <linux/fs.h>
     1.7 +#include <linux/blk.h>
     1.8  #include <linux/slab.h>
     1.9  #include <linux/genhd.h>
    1.10  #include <asm/hypervisor-ifs/block.h>
    1.11 @@ -21,57 +22,57 @@ int xeno_partition(struct gendisk *hd,
    1.12  		   int first_part_minor)
    1.13  {
    1.14      physdisk_probebuf_t *buf;
    1.15 -    int i;
    1.16 -    int minor;
    1.17 -    int count;
    1.18 +    int i, minor;
    1.19      
    1.20 -    buf = kmalloc(sizeof(*buf), GFP_KERNEL);
    1.21 -    if (!buf)
    1.22 +    /* Privileged domains can read partition info themselves. */
    1.23 +    if (start_info.flags & SIF_PRIVILEGED)
    1.24 +        return 0;
    1.25 +
    1.26 +    /* This only deals with raw/direct devices (IDE & SCSI). */
    1.27 +    switch ( xldev_to_physdev(bdev->bd_dev) & XENDEV_TYPE_MASK )
    1.28 +    {
    1.29 +    case XENDEV_IDE:
    1.30 +    case XENDEV_SCSI:
    1.31 +        break;
    1.32 +    default:
    1.33 +        return 0;
    1.34 +    }
    1.35 +
    1.36 +    if ( (buf = kmalloc(sizeof(*buf), GFP_KERNEL)) == NULL )
    1.37          return -ENOMEM;
    1.38 +
    1.39      buf->domain = start_info.dom_id;
    1.40      buf->start_ind = 0;
    1.41      buf->n_aces = PHYSDISK_MAX_ACES_PER_REQUEST;
    1.42  
    1.43      xenolinux_control_msg(XEN_BLOCK_PHYSDEV_PROBE, (char *)buf,
    1.44  			  sizeof(*buf));
    1.45 -    if (buf->n_aces == 0) {
    1.46 -        kfree(buf);
    1.47 -	return 0;
    1.48 -    }
    1.49  
    1.50 -    if (buf->n_aces == PHYSDISK_MAX_ACES_PER_REQUEST) {
    1.51 -        kfree(buf);
    1.52 -	return 0;
    1.53 -    }
    1.54 -
    1.55 -    count = 0;
    1.56 +    if ( buf->n_aces == PHYSDISK_MAX_ACES_PER_REQUEST )
    1.57 +        printk(KERN_ALERT "Too many returns for xeno partition parser\n");
    1.58  
    1.59 -    for (i = 0; i < buf->n_aces; i++) {
    1.60 -        if (buf->entries[i].partition == 0) {
    1.61 +    for ( i = 0; i < buf->n_aces; i++ )
    1.62 +    {
    1.63 +        if (buf->entries[i].partition == 0)
    1.64 +	    continue;
    1.65 +	if (buf->entries[i].device != xldev_to_physdev(bdev->bd_dev))
    1.66  	    continue;
    1.67 -	}
    1.68 -	/* Make sure the partition is actually supposed to be on this
    1.69 -	   disk. */
    1.70 -	if (buf->entries[i].device != xldev_to_physdev(bdev->bd_dev)) {
    1.71 -	    continue;
    1.72 -	}
    1.73 -	/* This is a bit of a hack - the partition numbers are
    1.74 -	   specified by the hypervisor, and if we want them to match
    1.75 -	   up, this is what we need to do. */
    1.76 -	count ++;
    1.77 +        if (!(buf->entries[i].mode & PHYSDISK_MODE_W))
    1.78 +        {
    1.79 +            if (!(buf->entries[i].mode & PHYSDISK_MODE_R))
    1.80 +                continue;
    1.81 +            set_device_ro(bdev->bd_dev, 1);
    1.82 +        }
    1.83  	minor = buf->entries[i].partition + first_part_minor - 1;
    1.84  	add_gd_partition(hd,
    1.85  			 minor,
    1.86  			 buf->entries[i].start_sect,
    1.87  			 buf->entries[i].n_sectors);
    1.88      }  
    1.89 +
    1.90      kfree(buf);
    1.91  
    1.92 -    /* If we didn't find any suitable Xeno partitions, try the other
    1.93 -       types. */
    1.94 -    if (!count)
    1.95 -        return 0;
    1.96 +    printk("\n");
    1.97  
    1.98 -    printk("\n");
    1.99      return 1;
   1.100  }