-/* Simple hack so that client XenoLinux's can sort-of see parts of the
- host partition table. */
+
#include <linux/kernel.h>
#include <asm/hypervisor.h>
#include <linux/fs.h>
/* Grab the physdisk partitions list from the hypervisor. */
int xeno_partition(struct gendisk *hd,
- struct block_device *bdev,
- unsigned long first_sec,
- int first_part_minor)
+ struct block_device *bdev,
+ unsigned long first_sec,
+ int first_part_minor)
{
physdisk_probebuf_t *buf;
int i, minor;
buf->n_aces = PHYSDISK_MAX_ACES_PER_REQUEST;
xenolinux_control_msg(XEN_BLOCK_PHYSDEV_PROBE, (char *)buf,
- sizeof(*buf));
+ sizeof(*buf));
if ( buf->n_aces == PHYSDISK_MAX_ACES_PER_REQUEST )
printk(KERN_ALERT "Too many returns for xeno partition parser\n");
+ /* Check for access to whole disk, allowing direct p.t. access. */
+ for ( i = 0; i < buf->n_aces; i++ )
+ {
+ if ( (buf->entries[i].device == xldev_to_physdev(bdev->bd_dev)) &&
+ (buf->entries[i].partition == 0) )
+ {
+ kfree(buf);
+ return 0;
+ }
+ }
+
+ /* No direct access so trawl through the access lists instead. */
for ( i = 0; i < buf->n_aces; i++ )
{
- if (buf->entries[i].partition == 0)
- continue;
- if (buf->entries[i].device != xldev_to_physdev(bdev->bd_dev))
- continue;
+ if (buf->entries[i].device != xldev_to_physdev(bdev->bd_dev))
+ continue;
if (!(buf->entries[i].mode & PHYSDISK_MODE_W))
{
if (!(buf->entries[i].mode & PHYSDISK_MODE_R))
continue;
set_device_ro(bdev->bd_dev, 1);
}
- minor = buf->entries[i].partition + first_part_minor - 1;
- add_gd_partition(hd,
- minor,
- buf->entries[i].start_sect,
- buf->entries[i].n_sectors);
- }
+ minor = buf->entries[i].partition + first_part_minor - 1;
+ add_gd_partition(hd,
+ minor,
+ buf->entries[i].start_sect,
+ buf->entries[i].n_sectors);
+ }
kfree(buf);