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 #ifdef MODULE
   2 #include <linux/autoconf.h>
   3 #include <linux/module.h>
   4 #include <linux/version.h>
   5 #endif /* MODULE */
   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 "../block/blk.h"
  17 #include "scsi.h"
  18 #include "scsi_ioctl.h"
  19 #include "hosts.h"
  20 #include "sd.h"
  21 
  22 extern int revalidate_scsidisk(int, int);
  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     int 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_REQ:   /* 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         diskinfo[0] = 0;
  40         diskinfo[1] = 0;
  41         diskinfo[2] = 0;
  42         if(host->hostt->bios_param != NULL)
  43             host->hostt->bios_param(&rscsi_disks[MINOR(dev) >> 4],
  44                                     dev,
  45                                     &diskinfo[0]);
  46         put_user(diskinfo[0], &loc->heads);
  47         put_user(diskinfo[1], &loc->sectors);
  48         put_user(diskinfo[2], &loc->cylinders);
  49         put_user(sd[MINOR(inode->i_rdev)].start_sect, &loc->start);
  50         return 0;
  51     case BLKGETSIZE:   /* Return device size */
  52         if (!arg)  return -EINVAL;
  53         error = verify_area(VERIFY_WRITE, (long *) arg, sizeof(long));
  54         if (error)
  55             return error;
  56         put_user(sd[MINOR(inode->i_rdev)].nr_sects,
  57                  (long *) arg);
  58         return 0;
  59     case BLKRASET:
  60         if(!suser())  return -EACCES;
  61         if(!inode->i_rdev) return -EINVAL;
  62         if(arg > 0xff) return -EINVAL;
  63         read_ahead[MAJOR(inode->i_rdev)] = arg;
  64         return 0;
  65     case BLKFLSBUF:
  66         if(!suser())  return -EACCES;
  67         if(!inode->i_rdev) return -EINVAL;
  68         fsync_dev(inode->i_rdev);
  69         invalidate_buffers(inode->i_rdev);
  70         return 0;
  71         
  72     case BLKRRPART: /* Re-read partition tables */
  73         return revalidate_scsidisk(dev, 1);
  74     default:
  75         return scsi_ioctl(rscsi_disks[MINOR(dev) >> 4].device , cmd, (void *) arg);
  76     }
  77 }
  78 
  79 /*
  80  * Overrides for Emacs so that we follow Linus's tabbing style.
  81  * Emacs will notice this stuff at the end of the file and automatically
  82  * adjust the settings for this buffer only.  This must remain at the end
  83  * of the file.
  84  * ---------------------------------------------------------------------------
  85  * Local variables:
  86  * c-indent-level: 4
  87  * c-brace-imaginary-offset: 0
  88  * c-brace-offset: -4
  89  * c-argdecl-indent: 4
  90  * c-label-offset: -4
  91  * c-continued-statement-offset: 4
  92  * c-continued-brace-offset: 0
  93  * indent-tabs-mode: nil
  94  * tab-width: 8
  95  * End:
  96  */

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