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

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