[1554] in linux-scsi channel archive
Re: Howto spindle down SCSI disk ?
daemon@ATHENA.MIT.EDU (Hein Roehrig)
Fri Mar 14 04:56:51 1997
To: submit-linux-dev-scsi@ratatosk.yggdrasil.com
From: Hein Roehrig <roehrig@mpi-sb.mpg.de>
Date: 14 Mar 1997 10:50:15 +0100
Philippe Strauss <philou@sicel-home-1-4.urbanet.ch> writes:
> I have some noisy and power hungry disks that I'd like to spindle down
> after unmounting them, but while the rest of the system is still running.
/* start/stop SCSI unit
* derived from scsiinfo by:
*
* Eric Youngdale - 11/1/93. Version 1.0.
*
* Version 1.1: Ability to change parameters on cache page, support for
* X front end.
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <getopt.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/hdreg.h>
FILE *infile;
unsigned char buffer[10*1024];
int do_unit(int startstop)
{
int status, i;
unsigned char *cmd;
unsigned char tmp;
for (i=0; i<10*1024; i++)
{
buffer[i] = 0;
}
*( (int *) buffer ) = 0; /* length of input data */
*( ((int *) buffer) + 1 ) = 0; /* length of output buffer */
cmd = (char *) ( ((int *) buffer) + 2 );
cmd[0] = 0x1b; /* START/STOP UNIT */
cmd[1] = 0x01; /* lun=0, immed=1 */
cmd[2] = 0x00; /* (reserved) */
cmd[3] = 0x00; /* (reserved) */
cmd[4] = startstop; /* start or stop */
cmd[5] = 0x00; /* control */
status = ioctl( fileno(infile), 1 /* SCSI_IOCTL_SEND_COMMAND */, buffer );
if(status) printf( "ioctl(SCSI_IOCTL_SEND_COMMAND) status\t= %d\n", status );
return status;
}
void usage(char * errtext){
int i;
fprintf(stderr,"Error: %s\n", errtext);
fprintf(stderr,"Usage: ./unit [start|stop] device\n");
exit(0);
}
int main( int argc, char *argv[])
{
int startstop;
if (argc != 3)
usage("number of parameters invalid");
if (!strcmp(argv[1],"start"))
startstop = 1;
else
if (!strcmp(argv[1],"stop"))
startstop = 0;
else
usage("must be start or stop");
infile = fopen( argv[2], "r" );
if(!infile) {
perror("unit(fopen)");
exit(0);
}
do_unit(startstop);
return 0;
}
--
Hein Roehrig
http://www.ikf.physik.uni-frankfurt.de/~roehrig
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s+:- a-- C++> UL+ P+ L++>++++ E+ W+ N++ o? K? w++$ O M V- PS PE
Y+ PGP>+ t 5 X? R- !tv b++ DI+ D+ G e++ h+ r- y?
------END GEEK CODE BLOCK------