Skip to content
Snippets Groups Projects
Select Git revision
  • 84f60008b04a6cecaab6f2920a930cd5bf12764b
  • master default
  • trunk
  • RELEASE_6_5_DRIVEDB
  • RELEASE_6_6_DRIVEDB
  • RELEASE_7_0_DRIVEDB
  • RELEASE_7_2_DRIVEDB
  • RELEASE_7_3_DRIVEDB
  • RELEASE_6_0_DRIVEDB
  • RELEASE_6_1_DRIVEDB
  • RELEASE_6_2_DRIVEDB
  • RELEASE_6_3_DRIVEDB
  • RELEASE_6_4_DRIVEDB
  • tags/RELEASE_7_4
  • tags/RELEASE_7_3
  • RELEASE_5_41_DRIVEDB
  • RELEASE_5_42_DRIVEDB
  • RELEASE_5_43_DRIVEDB
  • tags/RELEASE_7_2
  • tags/RELEASE_7_1
  • tags/RELEASE_7_0
  • RELEASE_5_40_DRIVEDB
22 results

scsicmds.cpp

Blame
  • scsicmds.cpp 24.82 KiB
    /*
     * scsicmds.c
     *
     * Home page of code is: http://smartmontools.sourceforge.net
     *
     * Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
     * Copyright (C) 1999-2000 Michael Cornwell <cornwell@acm.org>
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation; either version 2, or (at your option)
     * any later version.
     *
     * You should have received a copy of the GNU General Public License
     * (for example COPYING); if not, write to the Free
     * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     *
     * This code was originally developed as a Senior Thesis by Michael Cornwell
     * at the Concurrent Systems Laboratory (now part of the Storage Systems
     * Research Center), Jack Baskin School of Engineering, University of
     * California, Santa Cruz. http://ssrc.soe.ucsc.edu/
     *
     */
    
    #include <stdio.h>
    #include <string.h>
    #include <getopt.h>
    #include <unistd.h>
    #include <sys/ioctl.h>
    #include <linux/hdreg.h>
    // We do NOT want to include the kernel SCSI header file, just user space one
    #define  _LINUX_SCSI_H
    #include <scsi/scsi.h>
    #include "scsicmds.h"
    
    const char *CVSid3="$Id: scsicmds.cpp,v 1.15 2002/11/21 16:49:44 knan Exp $" CVSID4;
    
    
    UINT8 logsense (int device, UINT8 pagenum, UINT8 *pBuf)
    {
      struct cdb10hdr *ioctlhdr;
      UINT8 tBuf[1024 + CDB_12_HDR_SIZE];
      UINT8 status;
    
      
      memset ( &tBuf, 0, 255);
        
      ioctlhdr = (struct cdb10hdr *) &tBuf;
      
      ioctlhdr->inbufsize = 0;
      ioctlhdr->outbufsize = 1024;
       
      ioctlhdr->cdb[0] = LOG_SENSE;
      ioctlhdr->cdb[1] = 0x00;
      ioctlhdr->cdb[2] = 0x40 | pagenum;
      ioctlhdr->cdb[3] = 0x00;
      ioctlhdr->cdb[4] = 0x00;
      ioctlhdr->cdb[5] = 0x00;
      ioctlhdr->cdb[6] = 0x00;
      ioctlhdr->cdb[7] = 0x04;
      ioctlhdr->cdb[8] = 0x00;
      ioctlhdr->cdb[9] = 0x00;
    
      status =  ioctl( device, 1 , &tBuf);
    
    	
      memcpy ( pBuf, &tBuf[8], 1024); 
    
      return status;