/usr/share/doc/noflushd/contrib/scsi-startstop.c is in noflushd 2.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | /* scsi-startstop.c
* $Id: scsi-startstop.c,v 1.3 2000/01/15 18:37:55 belbo Exp $
*
* tool to spin down SCSI disks
* ('nuff said)
*
* 19990826 Daniel Kobras <kobras@linux.de>
*/
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <linux/major.h>
#define SCSI_IOCTL_START_UNIT 5
#define SCSI_IOCTL_STOP_UNIT 6
void usage(char *name)
{
fprintf(stderr, "Usage: %s <device> {start|stop}\n"
" spin up/down SCSI disk on <device>.\n",
name);
}
int main(int argc, char *argv[])
{
int res = 1, fd, ioc;
struct stat statbuf;
if (argc != 3) {
usage(argv[0]);
exit(1);
}
if (!strcmp("start", argv[2]))
ioc = SCSI_IOCTL_START_UNIT;
else if (!strcmp("stop", argv[2]))
ioc = SCSI_IOCTL_STOP_UNIT;
else {
usage(argv[0]);
exit(1);
}
if ((fd = open(argv[1], O_RDWR)) < 0)
perror(argv[0]), exit(1);
if (fstat(fd, &statbuf) < 0)
goto _err_out;
if (!S_ISBLK(statbuf.st_mode) ||
(statbuf.st_rdev >> 8) & 255 != SCSI_DISK_MAJOR) {
fprintf(stderr, "%s is not a SCSI block device\n", argv[1]);
goto _out;
}
if (ioctl(fd, SCSI_IOCTL_STOP_UNIT, NULL) < 0)
goto _err_out;
res = 0;
_out:
close(fd);
exit(res);
_err_out:
perror(argv[1]);
goto _out;
}
|