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

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