root/drivers/scsi/sd_ioctl.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. sd_ioctl

   1 /*
   2  * drivers/scsi/sd_ioctl.c
   3  *
   4  * ioctl handling for SCSI disks
   5  */
   6 
   7 #include <linux/config.h>
   8 #include <linux/kernel.h>
   9 #include <linux/sched.h>
  10 #include <linux/mm.h>
  11 #include <linux/fs.h>
  12 #include <linux/hdreg.h>
  13 #include <linux/errno.h>
  14 
  15 #include <asm/segment.h>
  16 
  17 #include <linux/blk.h>
  18 #include "scsi.h"
  19 #include "scsi_ioctl.h"
  20 #include "hosts.h"
  21 #include "sd.h"
  22 #include <linux/scsicam.h>     /* must follow "hosts.h" */
  23 
  24 int sd_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg)
     /* [previous][next][first][last][top][bottom][index][help] */
  25 {
  26     kdev_t dev = inode->i_rdev;
  27     int error;
  28     struct Scsi_Host * host;
  29     int diskinfo[4];
  30     struct hd_geometry *loc = (struct hd_geometry *) arg;
  31     
  32     switch (cmd) {
  33     case HDIO_GETGEO:   /* Return BIOS disk parameters */
  34         if (!loc)  return -EINVAL;
  35         error = verify_area(VERIFY_WRITE, loc, sizeof(*loc));
  36         if (error)
  37             return error;
  38         host = rscsi_disks[MINOR(dev) >> 4].device->host;
  39 
  40 /* default to most commonly used values */
  41 
  42         diskinfo[0] = 0x40;
  43         diskinfo[1] = 0x20;
  44         diskinfo[2] = rscsi_disks[MINOR(dev) >> 4].capacity >> 11;
  45 
  46 /* override with calculated, extended default, or driver values */
  47 
  48 #ifdef CONFIG_SCSI_AUTO_BIOSP
  49         scsicam_bios_param(&rscsi_disks[MINOR(dev) >> 4],
  50                                     dev, &diskinfo[0]);
  51 #else
  52         if(host->hostt->bios_param != NULL)
  53             host->hostt->bios_param(&rscsi_disks[MINOR(dev) >> 4],
  54                                     dev,
  55                                     &diskinfo[0]);
  56 #endif
  57 
  58         put_user(diskinfo[0], &loc->heads);
  59         put_user(diskinfo[1], &loc->sectors);
  60         put_user(diskinfo[2], &loc->cylinders);
  61         put_user(sd[MINOR(inode->i_rdev)].start_sect, &loc->start);
  62         return 0;
  63     case BLKGETSIZE:   /* Return device size */
  64         if (!arg)  return -EINVAL;
  65         error = verify_area(VERIFY_WRITE, (long *) arg, sizeof(long));
  66         if (error)
  67             return error;
  68         put_user(sd[MINOR(inode->i_rdev)].nr_sects,
  69                  (long *) arg);
  70         return 0;
  71 
  72     case BLKRASET:
  73         if (!suser())
  74                 return -EACCES;
  75         if(!(inode->i_rdev)) return -EINVAL;
  76         if(arg > 0xff) return -EINVAL;
  77         read_ahead[MAJOR(inode->i_rdev)] = arg;
  78         return 0;
  79 
  80     case BLKRAGET:
  81         if (!arg)
  82                 return -EINVAL;
  83         error = verify_area(VERIFY_WRITE, (int *) arg, sizeof(int));
  84         if (error)
  85             return error;
  86         put_user(read_ahead[MAJOR(inode->i_rdev)], (int *) arg);
  87         return 0;
  88 
  89     case BLKFLSBUF:
  90         if(!suser())  return -EACCES;
  91         if(!(inode->i_rdev)) return -EINVAL;
  92         fsync_dev(inode->i_rdev);
  93         invalidate_buffers(inode->i_rdev);
  94         return 0;
  95         
  96     case BLKRRPART: /* Re-read partition tables */
  97         return revalidate_scsidisk(dev, 1);
  98     default:
  99         return scsi_ioctl(rscsi_disks[MINOR(dev) >> 4].device , cmd, (void *) arg);
 100     }
 101 }
 102 
 103 /*
 104  * Overrides for Emacs so that we follow Linus's tabbing style.
 105  * Emacs will notice this stuff at the end of the file and automatically
 106  * adjust the settings for this buffer only.  This must remain at the end
 107  * of the file.
 108  * ---------------------------------------------------------------------------
 109  * Local variables:
 110  * c-indent-level: 4
 111  * c-brace-imaginary-offset: 0
 112  * c-brace-offset: -4
 113  * c-argdecl-indent: 4
 114  * c-label-offset: -4
 115  * c-continued-statement-offset: 4
 116  * c-continued-brace-offset: 0
 117  * indent-tabs-mode: nil
 118  * tab-width: 8
 119  * End:
 120  */

/* [previous][next][first][last][top][bottom][index][help] */