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 #include <linux/kernel.h>
   2 #include <linux/sched.h>
   3 #include <linux/mm.h>
   4 #include <linux/fs.h>
   5 #include <linux/hdreg.h>
   6 #include <linux/errno.h>
   7 
   8 #include <asm/segment.h>
   9 
  10 #include "../block/blk.h"
  11 #include "scsi.h"
  12 #include "scsi_ioctl.h"
  13 #include "hosts.h"
  14 #include "sd.h"
  15 
  16 extern int revalidate_scsidisk(int, int);
  17 
  18 int sd_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg)
     /* [previous][next][first][last][top][bottom][index][help] */
  19 {
  20         int dev = inode->i_rdev;
  21         int error;
  22         struct Scsi_Host * host;
  23         int diskinfo[4];
  24         struct hd_geometry *loc = (struct hd_geometry *) arg;
  25 
  26         switch (cmd) {
  27                 case HDIO_REQ:   /* Return BIOS disk parameters */
  28                         if (!loc)  return -EINVAL;
  29                         error = verify_area(VERIFY_WRITE, loc, sizeof(*loc));
  30                         if (error)
  31                                 return error;
  32                         host = rscsi_disks[MINOR(dev) >> 4].device->host;
  33                         diskinfo[0] = 0;
  34                         diskinfo[1] = 0;
  35                         diskinfo[2] = 0;
  36                         if(host->hostt->bios_param != NULL)
  37                               host->hostt->bios_param(&rscsi_disks[MINOR(dev) >> 4],
  38                                                           dev,
  39                                                           &diskinfo[0]);
  40                         put_fs_byte(diskinfo[0],
  41                                 (char *) &loc->heads);
  42                         put_fs_byte(diskinfo[1],
  43                                 (char *) &loc->sectors);
  44                         put_fs_word(diskinfo[2],
  45                                 (short *) &loc->cylinders);
  46                         put_fs_long(sd[MINOR(inode->i_rdev)].start_sect,
  47                                 (long *) &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_fs_long(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  * Overrides for Emacs so that we follow Linus's tabbing style.
  78  * Emacs will notice this stuff at the end of the file and automatically
  79  * adjust the settings for this buffer only.  This must remain at the end
  80  * of the file.
  81  * ---------------------------------------------------------------------------
  82  * Local variables:
  83  * c-indent-level: 8
  84  * c-brace-imaginary-offset: 0
  85  * c-brace-offset: -8
  86  * c-argdecl-indent: 8
  87  * c-label-offset: -8
  88  * c-continued-statement-offset: 8
  89  * c-continued-brace-offset: 0
  90  * End:
  91  */

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