ia64/xen-unstable

changeset 2572:5109394e871c

bitkeeper revision 1.1159.97.1 (415c1355G0vdS-y56tfhWtVP73n6pQ)

The blkfront driver now invents a disk geometry consistent with the size of the device if anyone calls the HDIO_GETGEO ioctl
author iap10@labyrinth.cl.cam.ac.uk
date Thu Sep 30 14:08:21 2004 +0000 (2004-09-30)
parents e9d6f07d0e52
children a98106d86aa2
files linux-2.6.8.1-xen-sparse/drivers/xen/blkfront/blkfront.c
line diff
     1.1 --- a/linux-2.6.8.1-xen-sparse/drivers/xen/blkfront/blkfront.c	Wed Sep 29 13:16:35 2004 +0000
     1.2 +++ b/linux-2.6.8.1-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Sep 30 14:08:21 2004 +0000
     1.3 @@ -554,6 +554,8 @@ int blkif_ioctl(struct inode *inode, str
     1.4      struct gendisk *gd;     
     1.5      struct hd_struct *part; 
     1.6      int i;
     1.7 +    unsigned short cylinders;
     1.8 +    byte heads, sectors;
     1.9  
    1.10      /* NB. No need to check permissions. That is done for us. */
    1.11      
    1.12 @@ -598,23 +600,39 @@ int blkif_ioctl(struct inode *inode, str
    1.13          break;
    1.14  
    1.15      case HDIO_GETGEO:
    1.16 -        /* note: these values are complete garbage */
    1.17          DPRINTK_IOCTL("   HDIO_GETGEO: %x\n", HDIO_GETGEO);
    1.18          if (!argument) return -EINVAL;
    1.19 +
    1.20 +        /* We don't have real geometry info, but let's at least return
    1.21 +	   values consistent with the size of the device */
    1.22 +
    1.23 +        heads = 0xff;
    1.24 +        sectors = 0x3f; 
    1.25 +        cylinders = part->nr_sects / (heads * sectors);
    1.26 +
    1.27          if (put_user(0x00,  (unsigned long *) &geo->start)) return -EFAULT;
    1.28 -        if (put_user(0xff,  (byte *)&geo->heads)) return -EFAULT;
    1.29 -        if (put_user(0x3f,  (byte *)&geo->sectors)) return -EFAULT;
    1.30 -        if (put_user(0x106, (unsigned short *)&geo->cylinders)) return -EFAULT;
    1.31 +        if (put_user(heads,  (byte *)&geo->heads)) return -EFAULT;
    1.32 +        if (put_user(sectors,  (byte *)&geo->sectors)) return -EFAULT;
    1.33 +        if (put_user(cylinders, (unsigned short *)&geo->cylinders)) return -EFAULT;
    1.34 +
    1.35          return 0;
    1.36  
    1.37      case HDIO_GETGEO_BIG: 
    1.38 -        /* note: these values are complete garbage */
    1.39          DPRINTK_IOCTL("   HDIO_GETGEO_BIG: %x\n", HDIO_GETGEO_BIG);
    1.40          if (!argument) return -EINVAL;
    1.41 +
    1.42 +        /* We don't have real geometry info, but let's at least return
    1.43 +	   values consistent with the size of the device */
    1.44 +
    1.45 +        heads = 0xff;
    1.46 +        sectors = 0x3f; 
    1.47 +        cylinders = part->nr_sects / (heads * sectors);
    1.48 +
    1.49          if (put_user(0x00,  (unsigned long *) &geo->start))  return -EFAULT;
    1.50 -        if (put_user(0xff,  (byte *)&geo->heads))   return -EFAULT;
    1.51 -        if (put_user(0x3f,  (byte *)&geo->sectors)) return -EFAULT;
    1.52 -        if (put_user(0x106, (unsigned int *) &geo->cylinders)) return -EFAULT;
    1.53 +        if (put_user(heads,  (byte *)&geo->heads))   return -EFAULT;
    1.54 +        if (put_user(sectors,  (byte *)&geo->sectors)) return -EFAULT;
    1.55 +        if (put_user(cylinders, (unsigned int *) &geo->cylinders)) return -EFAULT;
    1.56 +
    1.57          return 0;
    1.58  
    1.59      case CDROMMULTISESSION: