debian/0000775000000000000000000000000012252531602007166 5ustar debian/compat0000664000000000000000000000000212233502660010365 0ustar 7 debian/copyright0000664000000000000000000000226112233502660011123 0ustar This is the Debian Linux prepackaged version of several SCSI tools. It was previously maintained by Christoph Lameter (as part of hwtools). It's currently maintained by Eric Delaunay . Original sources and copyrights: scsiinfo: Copyright (C) 1993 Eric Youngdale Copyright (C) 1994, 1997 Michael Weller (eowmob@exp-math.uni-essen.de) ftp://tsx-11.mit.edu/pub/linux/ALPHA/scsi/ sraw: Copyright (C) 1993 Eric Youngdale ftp://tsx-11.mit.edu/pub/linux/ALPHA/scsi/ scsidev: Copyright (C) 1994--1997 Eric Youngdale Copyright (C) 2000 Kurt Garloff http://www.garloff.de/kurt/linux/scsidev/ scsifmt: Copyright (C) 1996 Alex Butcher (Alex.Butcher@bris.ac.uk) based on the work of Grant R. Guenther (grant@torque.net) and Itai Nahshon. FORMAT_UNIT mechanism taken from FreeBSD's scsifmt.sh. ftp://metalab.unc.edu/pub/Linux/system/hardware/ scsi-spin: Debian native utility, Copyright (C) 1998 Rob Browning ftp://ftp.debian.org/debian/pool/main/s/scsitools/ All programs are licensed under the GNU GPL licence, full text of which can on Debian systems be found in /usr/share/common-licenses/GPL-2 file. debian/scsitools-pre.sh0000664000000000000000000000424012233502660012331 0ustar #!/bin/sh ### BEGIN INIT INFO # Provides: scsitools-pre # Required-Start: mountdevsubfs # Required-Stop: # X-Start-Before: checkroot # Default-Start: S # Default-Stop: # Short-Description: Create aliases for SCSI devices under /dev/scsi ### END INIT INFO # # This script is run early at boot time (before S10checkroot.sh), so / is not # yet writable. Therefore it is needed to set up a ramdisk for /dev/scsi. # The ramdisk will be removed later, after / has been remounted rw and swap # activated (see scsitools.sh). # # Written by Eric Delaunay based on sources found in # scsidev 2.10 from Kurt Garloff . # # Licensed under GPL. scsidevrw=0 # is /dev/scsi writable at boot time? needscsidev=0 # is scsidev needed at all? # if no mount points on /dev/scsi in /etc/fstab, scsidev might be not needed # NB: does not work with devfs if [ ! -e /dev/.devfsd ]; then if grep -q '^/dev/scsi' /etc/fstab; then needscsidev=1 fi fi # check for writable /dev/scsi if [ $needscsidev -eq 1 ]; then : 2> /dev/null > /dev/scsi/__try || true if [ -f /dev/scsi/__try ]; then scsidevrw=1 rm -f /dev/scsi/__try fi fi case "$1" in start) if [ -x /sbin/scsidev -a "$needscsidev" = 1 ]; then if [ "$scsidevrw" = 0 ]; then echo "Setting up SCSI devices (first part)..." # /dev is not writable, setup a small ramdisk (128kB) # (ignore all errors in case there is no ramdisk support compiled # in the kernel). dd if=/dev/zero of=/dev/ram3 bs=1024 count=128 > /dev/null 2>&1 mke2fs -q -F -i1024 -g4096 /dev/ram3 128 > /dev/null 2>&1 mount -n -t ext2 /dev/ram3 /dev/scsi > /dev/null 2>&1 if [ ! -d /dev/scsi/lost+found ]; then echo "Error creating ramdisk on /dev/scsi. Is ramdisk supported by the kernel?" fi else echo "Setting up SCSI devices..." fi /sbin/scsidev -r -q fi ;; reload | restart | force-reload | stop) echo "This script is not designed to work with <$0> argument." echo "Use /etc/init.d/scsitools.sh instead." exit 1 ;; *) echo "Usage: $0 {start|stop|restart|reload|force-reload}" exit 1 ;; esac unset needscsidev scsidevrw debian/postinst0000664000000000000000000000053412233502660010777 0ustar #!/bin/sh -e #DEBHELPER# if [ "$1" = "configure" ]; then test -d /dev/scsi || mkdir --mode=755 /dev/scsi # first part before activating swap & remounting / rw update-rc.d scsitools-pre.sh start 09 S . >/dev/null # second part after modutils was run but before mounting other devices update-rc.d scsitools.sh start 22 S . >/dev/null fi debian/watch0000664000000000000000000000027212233502660010221 0ustar version=3 # Monitor updates to scsidev > 2.37 opts="uversionmangle=s/1\..*/0.12/;s/2\.[0-2].*/0.12/;s/2\.3[0-7].*/0.12/" \ http://www.garloff.de/kurt/linux/scsidev/scsidev-(.*).tar.gz debian/kernel-source-2.2.14.espfix0000664000000000000000000000457312233502660013720 0ustar diff -ur kernel-source-2.2.14.orig/drivers/scsi/esp.c kernel-source-2.2.14/drivers/scsi/esp.c --- kernel-source-2.2.14.orig/drivers/scsi/esp.c Tue Jan 4 19:12:20 2000 +++ kernel-source-2.2.14/drivers/scsi/esp.c Sat Mar 25 13:46:04 2000 @@ -4313,3 +4313,11 @@ spin_unlock_irqrestore(&io_request_lock, flags); } #endif + +int esp_revoke(Scsi_Device* SDptr) +{ + struct Sparc_ESP *esp = (struct Sparc_ESP *) SDptr->host->hostdata; + esp->targets_present &= ~(1 << SDptr->id); + return 0; +} + diff -ur kernel-source-2.2.14.orig/drivers/scsi/esp.h kernel-source-2.2.14/drivers/scsi/esp.h --- kernel-source-2.2.14.orig/drivers/scsi/esp.h Sun Mar 28 20:04:13 1999 +++ kernel-source-2.2.14/drivers/scsi/esp.h Sat Mar 25 01:27:17 2000 @@ -413,6 +413,7 @@ extern int esp_reset(Scsi_Cmnd *, unsigned int); extern int esp_proc_info(char *buffer, char **start, off_t offset, int length, int hostno, int inout); +extern int esp_revoke(Scsi_Device* SDptr); extern struct proc_dir_entry proc_scsi_esp; @@ -421,6 +422,7 @@ proc_info: &esp_proc_info, \ name: "Sun ESP 100/100a/200", \ detect: esp_detect, \ + revoke: esp_revoke, \ info: esp_info, \ command: esp_command, \ queuecommand: esp_queue, \ diff -ur kernel-source-2.2.14.orig/drivers/scsi/hosts.h kernel-source-2.2.14/drivers/scsi/hosts.h --- kernel-source-2.2.14.orig/drivers/scsi/hosts.h Sun Mar 28 20:04:03 1999 +++ kernel-source-2.2.14/drivers/scsi/hosts.h Sat Mar 25 01:32:37 2000 @@ -95,6 +95,7 @@ * especially that scsi_malloc/scsi_free must not be called. */ int (* detect)(struct SHT *); + int (*revoke)(Scsi_Device *); /* Used with loadable modules to unload the host structures. Note: * there is a default action built into the modules code which may diff -ur kernel-source-2.2.14.orig/drivers/scsi/scsi.c kernel-source-2.2.14/drivers/scsi/scsi.c --- kernel-source-2.2.14.orig/drivers/scsi/scsi.c Tue Jan 4 19:12:21 2000 +++ kernel-source-2.2.14/drivers/scsi/scsi.c Sat Mar 25 01:25:47 2000 @@ -2492,6 +2492,8 @@ * Nobody is using this device any more. * Free all of the command structures. */ + if (HBA_ptr->hostt->revoke) + HBA_ptr->hostt->revoke(scd); for(SCpnt=scd->device_queue; SCpnt; SCpnt = scd->device_queue) { scd->device_queue = SCpnt->next; debian/scsi-spin.c0000664000000000000000000002715512233502660011255 0ustar /* File: scsi-spin.c A simple program to manually spin up and down a scsi device. Copyright 1998 Rob Browning Copyright 2001 Eric Delaunay This source is covered by the terms the GNU Public License. Some of the original code came from The Linux SCSI programming HOWTO Heiko Eifeldt heiko@colossus.escape.de v1.5, 7 May 1996 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define SCSI_DISK_MAJOR(M) ((M) == SCSI_DISK0_MAJOR || \ ((M) >= SCSI_DISK1_MAJOR && \ (M) <= SCSI_DISK7_MAJOR) || \ ((M) >= SCSI_DISK8_MAJOR && \ (M) <= SCSI_DISK15_MAJOR)) #define SCSI_BLK_MAJOR(M) \ (SCSI_DISK_MAJOR(M) || \ (M) == SCSI_CDROM_MAJOR) /* define USE_SG_IO to send commands using scsi generic interface */ #define USE_SG_IO #ifdef USE_SG_IO int opt_oldioctl = 0; int opt_verbose = 0; const char* SENSE_KEY_STR[16] = { "NO SENSE", "RECOVERED ERROR", "NOT READY", "MEDIUM ERROR", "HARDWARE ERROR", "ILLEGAL REQUEST", "UNIT ATTENTION", "DATA PROJECT", "BLANK CHECK", "VENDOR-SPECIFIC", "COPY ARBORTED", "ABORTED COMMAND", "EQUAL", "VOLUME OVERFLOW", "MISCOMPARED", "RESERVED" }; /* process a complete SCSI cmd. Use the generic SCSI interface. */ static int handle_SCSI_cmd(const int fd, const unsigned cmd_len, /* command length */ unsigned char *cmd, /* command buffer */ const unsigned in_size, /* input data size */ const unsigned out_size, /* output data size */ unsigned char *io_buff, /* i/o buffer */ unsigned sense_size, /* sense buf length */ unsigned char* sense_buff, /* sense buffer */ const unsigned timeout /* timeout in s */ ) { ssize_t status = 0; int k, err; sg_io_hdr_t sg_hdr; unsigned char sense[16]; /* safety checks */ if (!cmd_len) return -1; /* need a cmd_len != 0 */ if (in_size > 0 && io_buff == NULL) return -1; /* need an input buffer != NULL */ /* generic SCSI device header construction */ memset(&sg_hdr, 0, sizeof(sg_hdr)); sg_hdr.interface_id = 'S'; sg_hdr.dxfer_direction = SG_DXFER_NONE; sg_hdr.cmd_len = cmd_len; sg_hdr.cmdp = cmd; sg_hdr.dxfer_len = in_size; sg_hdr.dxferp = io_buff; sg_hdr.timeout = (timeout ? timeout : 2)*1000; /* timeout in ms */ if (sense_buff == NULL) { sense_buff = sense; sense_size = sizeof(sense); } sg_hdr.mx_sb_len = sense_size; sg_hdr.sbp = sense_buff; if (opt_verbose > 1) { fprintf( stderr, " cmd = " ); for( k = 0 ; k < cmd_len ; k++ ) fprintf( stderr, " %02x", cmd[k] ); fputc( '\n', stderr ); } /* send command */ status = ioctl( fd, SG_IO, &sg_hdr ); if (status < 0 || sg_hdr.masked_status == CHECK_CONDITION) { /* some error happened */ fprintf( stderr, "SG_IO: status = 0x%x cmd = 0x%x\n", sg_hdr.status, cmd[0] ); if (opt_verbose > 0) { fprintf( stderr, " sense = " ); for( k = 0 ; k < sg_hdr.sb_len_wr ; k++ ) fprintf( stderr, " %02x", sense_buff[k] ); fputc( '\n', stderr ); err = sense_buff[0] & 0x7f; if (err == 0x70 || err == 0x71) { fprintf( stderr, " (%s)\n", SENSE_KEY_STR[sense_buff[2] & 0xf] ); } } perror(""); } return status; /* 0 means no error */ } #endif static void scsi_spin(const int fd, const int desired_state, const int load_eject, const int wait) { #ifdef USE_SG_IO if (! opt_oldioctl) { unsigned char cmdblk [6] = { START_STOP, /* command */ (wait ? 0 : 1), /* lun(3 bits)/reserved(4 bits)/immed(1 bit) */ 0, /* reserved */ 0, /* reserved */ (load_eject ? 2 : 0) | (desired_state ? 1 : 0), /* reserved(6)/LoEj(1)/Start(1)*/ 0 };/* reserved/flag/link */ if (handle_SCSI_cmd(fd, sizeof(cmdblk), cmdblk, 0, 0, NULL, 0, NULL, wait)) { fprintf( stderr, "start/stop failed\n" ); exit(2); } return; } #endif int ret; if (desired_state != 0) ret = ioctl( fd, SCSI_IOCTL_START_UNIT ); else ret = ioctl( fd, SCSI_IOCTL_STOP_UNIT ); if (ret < 0) perror( "scsi_spin: ioctl" ); } static void scsi_lock(const int fd, const int door_lock) { #ifdef USE_SG_IO if (! opt_oldioctl) { unsigned char cmdblk [6] = { ALLOW_MEDIUM_REMOVAL, /* command */ 0, /* lun(3 bits)/reserved(5 bits) */ 0, /* reserved */ 0, /* reserved */ (door_lock ? 1 : 0), /* reserved(7)/Prevent(1)*/ 0 };/* control */ if (handle_SCSI_cmd(fd, sizeof(cmdblk), cmdblk, 0, 0, NULL, 0, NULL, 2)) { fprintf( stderr, "lock/unlock failed\n" ); exit(2); } return; } #endif int ret; if (door_lock != 0) ret = ioctl( fd, SCSI_IOCTL_DOORLOCK ); else ret = ioctl( fd, SCSI_IOCTL_DOORUNLOCK ); if (ret < 0) perror( "scsi_lock: ioctl" ); } /* -- [ED] -- * Check if the device has some of its partitions mounted. * The check is done by comparison between device major and minor numbers so it * even works when the device name of the mount point is not the same of the * one passed to scsi-spin (for example, scsidev creates device aliases under * /dev/scsi). */ static int is_mounted( const char* device, int use_proc, int devmaj, int devmin ) { struct mntent *mnt; struct stat devstat; int mounted = 0; struct { __uint32_t dev_id; __uint32_t host_unique_id; } scsi_dev_id, scsi_id; FILE *mtab; char *mtabfile = use_proc ? "/proc/mounts" : "/etc/mtab"; if (devmaj == SCSI_GENERIC_MAJOR) { /* scsi-spin device arg is /dev/sgN */ int fd = open( device, O_RDONLY ); if (fd >= 0) { int ret = ioctl( fd, SCSI_IOCTL_GET_IDLUN, &scsi_dev_id ); close( fd ); if (ret < 0) return -1; } } /*printf("devid=%x\n",scsi_dev_id.dev_id);*/ mtab = setmntent( mtabfile, "r" ); if (mtab == NULL) return -1; while ((mnt = getmntent( mtab )) != 0) { char * mdev = mnt->mnt_fsname; if (stat( mdev, &devstat ) == 0) { int maj = major(devstat.st_rdev); int min = minor(devstat.st_rdev); if (SCSI_DISK_MAJOR(maj) && SCSI_DISK_MAJOR(devmaj)) { if (maj == devmaj && (min & ~15) == (devmin & ~15)) { mounted = 1; break; } } else if (devmaj == SCSI_GENERIC_MAJOR && SCSI_BLK_MAJOR(maj)) { /* scsi-spin device arg is /dev/sgN */ int fd = open( mdev, O_RDONLY ); if (fd >= 0) { int ret = ioctl( fd, SCSI_IOCTL_GET_IDLUN, &scsi_id ); close( fd ); /*printf("id=%x\n",scsi_id.dev_id);*/ if (ret == 0 && scsi_id.dev_id == scsi_dev_id.dev_id) { /* same SCSI ID => same device */ mounted = 1; break; } } } else if (maj == SCSI_CDROM_MAJOR && maj == devmaj && min == devmin) { mounted = 1; break; } } } endmntent( mtab ); return mounted; } static void usage() { static char usage_string[] = "usage: scsi-spin {-u,-d} [-nfpe] device\n" " -u, --up spin up device.\n" " -d, --down spin down device.\n" " -v, --verbose[=n] verbose mode (1: normal, 2: debug).\n" #ifdef SG_IO " -e, --loej load (-u) or eject (-d) removable medium.\n" " -w, --wait=[n] wait the spin up/down operation to be completed\n" " (n is the number of seconds to timeout).\n" " -I, --oldioctl use legacy ioctl instead of SG I/O (-e,-w ignored).\n" #endif " -l, --lock prevent medium removal.\n" " -L, --unlock allow medium removal.\n" " -n, --noact do nothing but check if the device is in use.\n" " -f, --force force spinning up/down even if the device is in use.\n" " -p, --proc use /proc/mounts instead of /etc/mtab to do the check.\n" " device is one of /dev/sd[a-z], /dev/scd[0-9]* or /dev/sg[0-9]*.\n"; fputs(usage_string, stderr); } int main(int argc, char *argv[]) { int result = 0; int fd; int opt_up = 0; int opt_down = 0; int opt_loej = 0; int opt_wait = 0; int opt_force = 0; int opt_noact = 0; int opt_proc = 0; int opt_lock = 0; int opt_unlock = 0; struct option cmd_line_opts[] = { {"verbose", 2, NULL, 'v'}, {"up", 0, NULL, 'u'}, {"down", 0, NULL, 'd'}, #ifdef SG_IO {"loej", 0, NULL, 'e'}, {"wait", 2, NULL, 'w'}, {"oldioctl", 0, NULL, 'I'}, #endif {"lock", 0, NULL, 'l'}, {"unlock", 0, NULL, 'L'}, {"force", 0, NULL, 'f'}, {"noact", 0, NULL, 'n'}, {"proc", 0, NULL, 'p'}, {0, 0, 0, 0}, }; char* endptr = ""; char* device; struct stat devstat; char c; while((c = getopt_long(argc, argv, "vudewlLfnp", cmd_line_opts, NULL)) != EOF) { switch (c) { case 'v': opt_verbose = optarg ? strtol(optarg, &endptr, 10) : opt_verbose+1; if (*endptr) goto error; break; case 'u': opt_up = 1; break; case 'd': opt_down = 1; break; #ifdef SG_IO case 'e': opt_loej = 1; break; case 'w': opt_wait = optarg ? strtol(optarg, &endptr, 10) : opt_wait+1; if (*endptr) goto error; break; case 'I': opt_oldioctl = 1; break; #endif case 'f': opt_force = 1; break; case 'l': opt_lock = 1; break; case 'L': opt_unlock = 1; break; case 'n': opt_noact = 1; break; case 'p': opt_proc = 1; break; default: error: usage(); exit(1); } } if(opt_up && opt_down) { fputs("scsi-spin: specified both --up and --down. " "Is this some kind of test?\n", stderr); exit(1); } if(opt_lock && opt_unlock) { fputs("scsi-spin: specified both --lock and --unlock. " "Is this some kind of test?\n", stderr); exit(1); } if (opt_oldioctl && (opt_wait || opt_loej)) { fputs("scsi-spin: -e or -w not working in old ioctl mode.\n", stderr); exit(1); } if(!(opt_up || opt_down || opt_lock || opt_unlock)) { fputs("scsi-spin: must specify --up, --down, --lock or --unlock at least.\n", stderr); exit(1); } if(optind != (argc - 1)) { usage(); exit(1); } device = argv[optind]; if(stat(device, &devstat) == -1) { fprintf(stderr, "scsi-spin [stat]: %s: %s\n", device, strerror(errno)); result = 1; } if (is_mounted( device, opt_proc, major(devstat.st_rdev), minor(devstat.st_rdev) )) { if (! opt_force) { fprintf( stderr, "scsi-spin: device already in use (mounted partition)\n" ); exit(1); } else { fprintf( stderr, "scsi-spin [warning]: device is mounted but --force is passed\n" ); } } /* first try to open the device r/w */ fd = open(device, O_RDWR); if (fd < 0) { /* if it's fail, then try ro */ fd = open(device, O_RDONLY); if (fd < 0) { fprintf(stderr, "scsi-spin [open]: %s: %s\n", device, strerror(errno)); exit(1); } } if ((S_ISBLK(devstat.st_mode) && SCSI_BLK_MAJOR(major(devstat.st_rdev))) || (S_ISCHR(devstat.st_mode) && major(devstat.st_rdev) == SCSI_GENERIC_MAJOR)) { if (! opt_noact) { if (opt_lock || opt_unlock) scsi_lock(fd, opt_lock); if (opt_up || opt_down) scsi_spin(fd, opt_up, opt_loej, opt_wait); } } else { fprintf(stderr, "scsi-spin: %s is not a disk or generic SCSI device.\n", device); result = 1; } close(fd); return result; } debian/postrm0000664000000000000000000000023012233502660010431 0ustar #!/bin/sh -e if [ "$1" = "purge" ] ; then update-rc.d scsitools-pre.sh remove >/dev/null update-rc.d scsitools.sh remove >/dev/null fi #DEBHELPER# debian/changelog0000664000000000000000000003715112252531602011047 0ustar scsitools (0.12-2.2ubuntu1) trusty; urgency=low * Merge from Debian testing. Remaining changes: - debian/control, debian/rules: Split out tk_scsiformat into its own package so we dont pull in X server on the server. - add debian/patches/01_ubuntu-toolchain.diff, fix FTBFS caused by -D_FORTIFY_SOURCE=2 compiler flag enabled in Ubuntu. -- Mahyuddin Susanto Mon, 28 Oct 2013 15:41:36 +0000 scsitools (0.12-2.2) unstable; urgency=low * Non-maintainer upload. * Replaced tk8.4 by tk in dependencies to get rid of Tcl/Tk 8.4. (Closes: #725080) -- Sergei Golovan Mon, 28 Oct 2013 15:29:51 +0400 scsitools (0.12-2.1ubuntu1) precise; urgency=low * Merge from Debian testing. Remaining changes: - debian/control, debian/rules: Split out tk_scsiformat into its own package so we dont pull in X server on the server. (LP: #552622) - add debian/patches/01_ubuntu-toolchain.diff, fix FTBFS caused by -D_FORTIFY_SOURCE=2 compiler flag enabled in Ubuntu -- Mahyuddin Susanto Tue, 10 Jan 2012 18:11:38 +0700 scsitools (0.12-2.1) unstable; urgency=low * Non-maintainer upload. * Fix "rescan-scsi-bus call nonexistent usleep command": new patch rescan-scsi-bus_sleep.patch, based on suggestion from Ubuntu / Daniel T Chen: replace usleep with sleep. (Closes: #624441) -- gregor herrmann Wed, 07 Dec 2011 17:25:32 +0100 scsitools (0.12-2ubuntu1) oneiric; urgency=low * Merge from Debian unstable, remaining Ubuntu changes: - debian/control, debian/rules: Split out tk_scsiformat into its own package so we dont pull in X server on the server. (LP: #552622) - add debian/patches/01_ubuntu-toolchain.diff, fix FTBFS caused by -D_FORTIFY_SOURCE=2 compiler flag enabled in Ubuntu. * Refreshed debian/patches/01_ubuntu-toolchain.diff -- Adam Gandelman Fri, 20 May 2011 11:04:11 -0700 scsitools (0.12-2) unstable; urgency=low * Removed note displayed at install time (debconf abuse). Closes: #610233 * (packaging source files are now hosted on Alioth). -- Eric Delaunay Wed, 19 Jan 2011 22:26:20 +0100 scsitools (0.12-1) unstable; urgency=low * Switch to dpkg-source 3.0 (quilt) format. * Updated rescan-scsi-bus.sh to 1.48. Closes: #559147 * Removed .sh extension from rescan-scsi-bus. Closes: #601566 * Now handling nostrip build option (policy 10.1). Closes: #438008 * Get rid of some lintian warnings: - debian/templates description (malformed-title-in-templates). - scsitools.sh code cleanup (init.d-script-sourcing-without-test). -- Eric Delaunay Tue, 11 Jan 2011 23:09:16 +0100 scsitools (0.10-2.1ubuntu2) lucid; urgency=low * debian/control, debian/rules: Split out tk_scsiformat into its own package so we dont pull in X server on the server. (LP: #552622) -- Chuck Short Wed, 31 Mar 2010 12:12:25 -0400 scsitools (0.10-2.1ubuntu1) lucid; urgency=low * Merge from Debian testing, remaining Ubuntu changes: - add quilt support - add debian/patches/01_ubuntu-toolchain.diff, fix FTBFS caused by -D_FORTIFY_SOURCE=2 compiler flag enabled in Ubuntu. -- Devid Antonio Filoni Tue, 01 Dec 2009 21:59:24 +0100 scsitools (0.10-2.1) unstable; urgency=low * scsitools/scsiinfo: get rid of debugging message added by previous upload. Sorry. -- Eric Delaunay Sun, 01 Nov 2009 16:51:32 +0000 scsitools (0.10-2) unstable; urgency=low * rescan-scsi-bus.sh: fixed lots of errors when scanning host with no devices connected. Thanks to Andreas Beckmann for the patch. Closes: #502542 * scsitools: scsiinfo -l now shows drives beyond sdz. Closes: #551962 -- Eric Delaunay Sun, 01 Nov 2009 16:51:32 +0000 scsitools (0.10-1.2ubuntu1) jaunty; urgency=low * Add quilt support. * Add debian/patches/01_ubuntu-toolchain.diff, fix FTBFS caused by -D_FORTIFY_SOURCE=2 compiler flag enabled in Ubuntu. -- Devid Antonio Filoni Mon, 23 Feb 2009 11:27:17 +0100 scsitools (0.10-1.2) unstable; urgency=low * Non-maintainer upload to fix pending l10n issues. * Debconf translations: - Galician. Closes: #482134 - Basque. Closes: #495039 -- Christian Perrier Tue, 19 Aug 2008 09:58:32 +0200 scsitools (0.10-1.1) unstable; urgency=low * Non-maintainer upload to solve release goal issues. * Add LSB dependency header to init.d scripts (Closes: #458649) -- Petter Reinholdtsen Sat, 15 Mar 2008 10:53:29 +0100 scsitools (0.10-1) unstable; urgency=low * Updated scsidev to 2.37 which supports sysfs filenames from linux kernel 2.6.17+. * Updated rescan-scsi-bus.sh to 1.25 which better supports 2.6 kernels, and allows REPORT_LUNS scan and optional LIP reset. * Fixed syntax error in rescan-scsi-bus.sh due to change in command line syntax of sg_inq (from sg3-utils). Closes: #430200. * Added missing dependency against sg3-utils (required by rescan-scsi-bus.sh). -- Eric Delaunay Tue, 24 Jul 2007 17:30:57 +0200 scsitools (0.9-1.1) unstable; urgency=low * Non-maintainer upload, with maintainer's agreement, to fix pending l10n issues. * Debconf translations: - Portuguese. Closes: #381711 -- Christian Perrier Tue, 13 Feb 2007 07:22:11 +0100 scsitools (0.9-1) unstable; urgency=low * scsiformat, scsiinfo, sraw, scsi-spin: updated to use SG_IO to get rid of kernel warnings on latest 2.6.9+ kernels. Closes: #293964, #345779. * Put scsiinfo in /sbin instead of /usr/sbin as it can be useful at boot time. Improved it to detect more than 8 devices. Closes: #288052, #304777. * scsiformat: updated sanity checks before starting formating which does not work well with 2.6 kernels. Closes: #289154. * sraw: Added -v option. * scsi-spin: Added -vewIlL (verbose, load/eject, wait/immed, lock/unlock) options. * Removed references to scsistop in documentation as it is not provided for years and scsi-spin is doing better job. Closes: #288836. * Updated rescan-scsi-bus.sh to 1.18 (oct-2005). See manpage for new features. Closes: #290882, #316773. * Updated scsidev to 2.36. * Get rid of many gcc warnings about signedness of chars. * Fixed sentence in README.Debian. Closes: #316777. * Added translations for Vietnamese (courtesy of Clytie Siddall ). Closes: #317927. * Updated translations for German (courtesy of Daniel Knabl ), Swedish (courtesy of Daniel Nylander ). Closes: #333440, #338857. * Fixed typos in scsidev manpage. Closes: #357442. * Fixed typos in scsiformat manpage. Closes: #357443. * Fixed types in scsiinfo manpage. Closes: #357444. * Fixed spelling mistake in package's summary. Closes: #306651. -- Eric Delaunay Wed, 22 Mar 2006 13:28:27 +0100 scsitools (0.8-2) unstable; urgency=high * Don't unmount /proc if it is already mounted at the time scsitools-pre.sh is run, otherwise it lets a LVM system unbootable. Thanks to Jörg Sommer and Andrea Borgia who pointed out this problem. Closes: #285831. * Allow to use cdebconf as replacement to debconf. Closes: #332090. -- Eric Delaunay Mon, 17 Oct 2005 21:19:20 +0000 scsitools (0.8-1) unstable; urgency=low * Updated to scsidev 2.35. * Removed unneeded 'cat' statements from rescan-scsi-bus.sh script. Closes: #256390. * Added Czech template translations. Closes: #275505. * Fixed lintian reports (converted Debian changelog to UTF8, added real package dependency to virtual package "wish", added changelog file for scsidev). -- Eric Delaunay Sun, 21 Nov 2004 19:27:00 +0100 scsitools (0.7-2) unstable; urgency=low * Fixed scsiformat bug. Closes: #251426. Thanks to Erik Mouw for providing a patch. * Fixed not detected removable devices in scsiinfo. Closes: #255715. * Added italian template translations. Closes: #251740. * Renamed ca_ES.po to ca.po as there is no need in specifying a country part for the Catalan language. Closes: #255875. -- Eric Delaunay Fri, 25 Jun 2004 00:59:11 +0200 scsitools (0.7-1) unstable; urgency=low * Updated to scsidev 2.33. Closes: #239662. * Added catalan template translations. Closes: #236641. -- Eric Delaunay Sun, 4 Apr 2004 17:12:24 +0200 scsitools (0.6-1) unstable; urgency=low * Updated to scsidev 2.32. Closes: #233754. -- Eric Delaunay Sat, 21 Feb 2004 19:33:19 +0100 scsitools (0.5-4) unstable; urgency=low * Updated Build-depends on tk8.4, as tk8.2 is no longer available. Closes: #228740. -- Eric Delaunay Tue, 20 Jan 2004 21:03:21 +0100 scsitools (0.5-3) unstable; urgency=low * Fixed compiler errors due to kernel includes (thanks to Daniel Schepler for the patch). Closes: #224877. -- Eric Delaunay Thu, 15 Jan 2004 00:46:58 +0100 scsitools (0.5-2) unstable; urgency=low * Added Japanese template translation. Closes: #224186. -- Eric Delaunay Wed, 17 Dec 2003 00:48:38 +0100 scsitools (0.5-1) unstable; urgency=low * Updated to scsidev 2.31. Closes: #216416. - provides compatibility with 2.6 kernel: Use sysfs to gather some information. Unfortunately, only block devs provide what we need, so far. * Fixed man pages installation. Closes: #216415. * Marked init.d scripts as conffiles. * Added lintian overrides file to avoid Lintian reporting errors on TK script files disguised into shell scripts. -- Eric Delaunay Wed, 19 Nov 2003 00:11:46 +0100 scsitools (0.4-2) unstable; urgency=low * Fixed postinst (devfsd is still not supported). Closes: #205612. * Added dutch template. Closes: #205169. -- Eric Delaunay Sun, 17 Aug 2003 18:23:18 +0200 scsitools (0.4-1) unstable; urgency=low * Updated to scsidev 2.29. * Fixed detection of devfs mounted filesystem at boot time. * New maintainer address. * Switched to po-debconf (thanks to Christian Perrier for the patch). Closes: #202547. * Added russian & spanish templates. Closes: #136444, #136606. -- Eric Delaunay Fri, 1 Aug 2003 00:49:28 +0200 scsitools (0.3-2) unstable; urgency=low * Better way to detect devfs mounted filesystem (now works for me on potato running 2.4.18 kernel compiled with DEVFS enabled but not mounted). -- Eric Delaunay Sun, 21 Apr 2002 23:51:27 +0200 scsitools (0.3-1) unstable; urgency=low * Uncompressed the man pages of scsiinfo package in .orig.tar.gz so that dpkg-source can handle the change in scsiformat.8. * Fixed documentation bug in scsiformat man page (I finally discovered the right groff sequence to write). Closes: #31376. * Brazilian portuguese (pt_BR) debconf template translation. Closes: #108550. * Added Build-depends on debhelper. Closes: #105030. * many scsi-spin enhancements: - now send SCSI_IOCTL_{START,STOP}_UNIT therefore it supports sd, scd & sg device names. It is based on device major/minor number so it even works with scsidev or devfs device naming convention. - also supports short options (-u, -d, ...). - does not spin up/down when the device is in use (has mounted partitions) unless -f/--force is passed. - can use /proc/mounts instead of /etc/mtab to do the check of mounted partitions (-p/--proc option). - scanning for device in use is done on comparison of devices major/minor numbers and SCSI ID/LUN if the first method is not enoughly accurate. - compiled with GNU C compiler instead of C++ because it is really C code. - added man page. Closes: #102412. * Install sraw documentation. * Fixed rescan-scsi-bus.sh man page location. -- Eric Delaunay Thu, 6 Sep 2001 23:08:30 +0200 scsitools (0.2-2) unstable; urgency=low * depends on util-linux >= 2.11b-3 to make use of blockdev instead of unknown freeramdisk. Closes: #75217. -- Eric Delaunay Wed, 13 Jun 2001 23:27:19 +0200 scsitools (0.2-1) unstable; urgency=low * updated to scsidev 2.22. Closes: #79906. * run the init script before raid script at boot time. Closes: #75219. * scsitools.sh: don't run swapoff when there is no swap entry in /etc/fstab. Closes: #75218. * Recommends wish instead of suggesting it (I don't want to depend on it because the package is still useful without scsi-config and tk-scsiformat). scsi-config and tk-scsiformat now suggest the user to install a tk package if no /usr/bin/wish found. Closes: #74550. * fixed compiler warnings in scsiformat.c, tworands.c and scsi-spin.C. * added German translations. Thanks to Joerg Rieger . Closes: #83928. * added Swedish translations. Thanks to André Dahlqvist . Closes: #83684. * Build-depends on tk8.2 to compile cleanly. -- Eric Delaunay Mon, 12 Feb 2001 22:50:50 +0100 scsitools (0.1-3) unstable; urgency=low * fixed cosmetic bug in scsi-spin. Closes: #67181. -- Eric Delaunay Mon, 17 Jul 2000 23:02:46 +0200 scsitools (0.1-2) unstable; urgency=low * scsi-spin moved to /sbin to allowing its use in /etc/init.d/halt. Closes: #66328. * Added boot time support for scsidev. * Fixed a bug when parsing hexadecimal numbers (0xnnn) in scsidev. * Fixed tcl/tk problems in tk_scsiformat (surely due to language improvements). tk_scsiformat is hopefully running with tk8.2 but I can't try to go further and format my scsi disk ;-( Feel free to report any new bug. Closes: #23397. * Document how to create the hostid= parameter in /etc/scsi.alias in scsidev manpage. Closes: #48305. * Added manpage for rescan-scsi-bus.sh. * Closing most bug reports after the upgrade to scsidev 2.10. - temp file is written to /dev/scsi instead of possibly unavailable /tmp. Closes: #49509. - display error msg if /etc/scsi.alias does not exists. Closes: #30554, #46622, #47340, #48306. -- Eric Delaunay Sat, 8 Jul 2000 22:26:24 +0200 scsitools (0.1-1.1) unstable; urgency=low * Non-maintainer upload, to get it accepted it into the archive, sorry Eric :) * Fixed copyright file to include all authors and copyrights. * Worked around important problems on PowerPC due to signed chars by adding -fsigned-char to $CFLAGS. * Lowered debconf question priority to medium, and made it display the note only on new installs, not upgrades. * Updated rules file to match hwtools, removed some cruft. Added rcw's name to the short list of people who maintained hwtools on behalf of the quality assurance group. * Removed prerm, didn't contain anything useful. * Added rescan-scsi-bus.sh.1 to undocumented list. -- Josip Rodin Thu, 13 Apr 2000 19:35:06 +0200 scsitools (0.1-1) unstable; urgency=low * first release (fork of hwtools 0.5-0.2 that provides scsidev, scsifmt, scsiformat, scsiinfo, scsistop and sraw). * non-i386 aware. * updated to scsidev 2.10. Closes: #46622, #47340, #48306, #30554. * added rescan-scsi-bus.sh. * using debconf for displaying a note. -- Eric Delaunay Tue, 12 Apr 2000 21:07:00 +0200 debian/scsi-spin.80000664000000000000000000000543412233502660011176 0ustar .TH scsi-spin 8 "03 September 2001" .SH NAME scsi-spin \- spin up and down a SCSI device .SH SYNOPSIS .BI "scsi-spin [-" "options..." "] [" device ] .SH DESCRIPTION .B scsi-spin let the user to manually spin up and down a SCSI device. This command is particularly useful if you've got noisy (or hot) drives in a machine that you rarely need to access. This is .B not the same as the kernel patch that's floating around that will automatically spin down the drive after some time. .B scsi-spin is completely manual, and spinning down a drive that's in use, especially the one containing the scsi-spin binary, is probably a .B really bad idea. To avoid running in trouble with such cases, .B scsi-spin verifies that the device to work on is not currently in use by scanning the mounted file system description file for a partition living on it and issue an error if this the case. .SH OPTIONS .TP .B -u, --up spin up device. .TP .B -d, --down spin down device. .TP .B -e, --loej load or eject medium from drive (use along with .B -u or .B -d ) .TP .B -w, --wait=[n] wait up to .B n seconds for the spin up/down command to complete. Default is to return immediately after the command was sent to the device. Either repeat .B -w n times or set .B n to define the time to wait before to report a timeout. .TP .B -l, --lock prevent removal of medium from device. .TP .B -L, --unlock allow removal of medium from device. .TP .B -I, --oldioctl use legacy ioctl interface instead of SG_IO to dialog with device (could not be supported on all platforms). .B -e and .B -w are not allowed with this option. .TP .B -v, --verbose=[n] verbose mode. Either repeat .B -v or set .B n accordingly to increase verbosity. 1 is verbose, 2 is debug (dump SCSI commands and Sense buffer). .TP .B -f, --force force spinning up/down the device even if it is in use. .TP .B -n, --noact do nothing but check if the device is in use. .TP .TP .B -p, --proc use /proc/mounts instead of /etc/mtab to determine if the device is in use or not. .TP .B device the device is any name in the filesystem which points to a SCSI block device (sd, scd) or generic SCSI device (sg). See section below. .SH SCSI devices naming convention .SS Old kernel naming convention It is typically .I /dev/sd[a-z] , .I /dev/scd[0-9]* or .I /dev/sg[0-9]*. .SS scsidev naming convention It is typically .I /dev/scsi/s[rdg]h[0-9]*-e????c?i?l? or .I /dev/scsi/. .SS devfs naming convention It is typically /dev/scsi/host[0-9]/bus[0-9]/target[0-9]/lun[0-9]/disc (same for cd and generic devices) or short name /dev/sd/c[0-9]b[0-9]t[0-9]u[0-9] when .B devfsd "new compatibility entries" naming scheme is enabled. .SH SEE ALSO .BR scsiinfo (8), .BR sg_start (8), .BR sd (4), .BR proc (5), .SH AUTHORS Eric Delaunay , 2001 .br Rob Browning , 1998 debian/scsi-tools-gui/0000775000000000000000000000000012233502660012050 5ustar debian/scsi-tools-gui/usr/0000775000000000000000000000000012233502660012661 5ustar debian/scsi-tools-gui/usr/sbin/0000775000000000000000000000000012233502660013614 5ustar debian/scsi-tools-gui/usr/sbin/tk_scsiformat0000664000000000000000000012247511575477011016433 0ustar #!/bin/sh # the next lines restarts using wish or abort with a message \ type wish > /dev/null 2>&1 && exec wish -f "$0" "$@" || \ echo "no /usr/bin/wish found: please install a tk8.x package." && exit 1 #!/usr/bin/wish -f # Based in parts on scsi-config by: # Copyright 1993 Yggdrasil Computing, Incorporated # Copyright 1997 Michael Weller (eowmob@exp-math.uni-essen.de) # You may copy this file according to the terms and conditions of version 2 # of the GNU General Public License as published by the Free Software # Foundation. # This variable is set if WE issued a format command. Only when set, we will # issue an mkfs command if a format completes. set format_initiator 0 set textwidth 28 set winwidth 64 set butwidth 18 set butwidth2 25 set sdevice $argv set par_fov "-o" set par_inter "0" set par_query "" set par_estim 600 set par_initpat "" set par_initmode "none" set par_defform "-d" set par_erase "" set par_defects "" set par_partstyle "-fdos" set par_parttype "-y83" set par_partmin "99999" set par_geomdetect "" set par_heads "64" set par_sectors "32" set par_mkfs "mke2fs -m0 -q 1" set par_mkfsnames [list \ "None" \ "Ext2 (standard)" \ "Ext2 (no reserved blocks)" \ "DOS-FAT (1K clusters, up to 32MB)" \ "DOS-FAT (2K clusters, up to 64MB)" \ "DOS-FAT (4K clusters, up to 128MB)" \ "DOS-FAT (8K clusters), up to 256MB)" \ "DOS-FAT (16K clusters, up to 512MB)" \ ] # Value for None is not a valid command at all: set par_mkfscmds [list \ "1" \ "mke2fs -q 1" \ "mke2fs -m0 -q 1" \ "mkdosfs -s2 1" \ "mkdosfs -s4 1" \ "mkdosfs -s8 1" \ "mkdosfs -s16 1" \ "mkdosfs -s32 1" \ ] set vars2save [list par_fov par_inter par_query par_estim par_initpat par_initmode \ par_defform par_erase par_partstyle par_parttype par_partmin par_geomdetect par_heads \ par_sectors par_disprim par_nvram par_discert par_stop par_mkfs\ ] set whoami [exec whoami] proc save_var {fd var} { upvar #0 $var myval puts $fd "set $var \"$myval\"" } proc change_fov {} { global par_fov if { [string compare $par_fov -o] != 0 } then { if { [winfo exists .init_win] == 1 } then { destroy .init_win } .f_opt.col1.init configure -state disabled .f_opt.col1.disprim configure -state disabled .f_opt.col1.nvram configure -state disabled .f_opt.col2.discert configure -state disabled .f_opt.col2.stop configure -state disabled } else { .f_opt.col1.init configure -state normal .f_opt.col1.disprim configure -state normal .f_opt.col1.nvram configure -state normal .f_opt.col2.discert configure -state normal .f_opt.col2.stop configure -state normal } } proc simple {} { global par_inter par_fov par_erase par_defform par_defects par_query set par_inter "0" set par_fov "" set par_erase "" change_fov if { [winfo exists .defs_win] == 1 } { destroy .defs_win } set par_defform "-d" set par_defects "" set par_query "-b" block_change $par_query } proc change_partmin {} { global par_partmin if { [string compare $par_partmin ""] == 0} then { set par_partmin 0 } .f_def.part.menu entryconfigure 9 -label "Maximal Partition Size ${par_partmin}MB" } proc change_geom {geomdetect heads sectors} { if { [string compare $geomdetect "-G"] == 0} then { .f_def.part.menu entryconfigure 8 -label \ "Disk Geometry is ${heads} Heads and ${sectors} Sectors" } else { .f_def.part.menu entryconfigure 8 -label "Autodetect Disk Geometry" } } proc change_mkfs {} { global par_mkfscmds par_mkfs if { [lsearch -exact $par_mkfscmds "$par_mkfs"] >= 0 } then { set label "Other" } else { set label "Other ($par_mkfs)" } .f_def.part.menu.mkfs entryconfigure [expr [llength $par_mkfscmds] + 2] -label "$label" } proc bind_eedit {w} { bind $w { %W select clear %W delete insert insert } bind $w { %W select clear %W delete [expr [%W index insert] - 1] \ [expr [%W index insert] - 1] } bind $w { %W select clear %W icursor [expr [%W index insert] - 1] } bind $w { %W select clear %W icursor [expr [%W index insert] + 1] } bind $w { catch { %W insert insert [selection get] } } } proc bind_entry {w} { bind_eedit $w bind $w { if { [ string length [%W get] ] < 5 } { if { [ string first %A "0123456789" ] >= 0 } then { %W insert insert %A } } } bind $w {set x 1} bind $w {set x 1} bind $w {set x 1} bind $w {set x 1} bind $w {set x 1} bind $w {set x 1} bind $w { catch { set sel [selection get] regsub -all "\[^0-9\]" $sel "" sel2 %W insert insert $sel2 %W delete 5 end } } } proc bind_text {w} { bind $w {set x 1} bind $w {set x 1} bind $w {set x 1} bind $w {set x 1} bind $w {set x 1} bind $w {set x 1} bind $w { %W delete insert {insert + 1 chars} %W yview -pickplace insert } bind $w { %W delete {insert - 1 chars} insert %W yview -pickplace insert } bind $w { %W mark set insert {insert - 1 chars} %W yview -pickplace insert } bind $w { %W mark set insert {insert + 1 chars} %W yview -pickplace insert } bind $w { %W mark set insert {insert - 1 lines} %W yview -pickplace insert } bind $w { %W mark set insert {insert + 1 lines} %W yview -pickplace insert } } proc block_change { block } { if { [ string compare $block "-b" ] == 0 } then { .f_block.f_estim configure -foreground black .f_block.f_estim.t configure -state normal .f_block.f_estim.t configure -background white } else { .f_block.f_estim configure -foreground gray70 .f_block.f_estim.t configure -state disabled .f_block.f_estim.t configure -background bisque } } proc copyrights {} { global butwidth butwidth2 if { [winfo exists .version] == 1 } { raise .version return; } toplevel .version wm title .version "TkScsiformat Version Information" wm group . frame .version.header label .version.header.label -bitmap info -bg pink message .version.header.message -width 400 -bg pink -text \ "Version Information." pack .version.header.label .version.header.message -side left -padx 15 message .version.copy0 -width 400 -background yellow -justify center -text \ { This is version 1.0, 20th Aug 1997 of tk_scsiformat.} pack .version.header .version.copy0\ -side top -pady 10 -padx 15 message .version.copy1 -width 400 -background green -justify left -text\ {Copyright 1993 Yggdrasil Computing, Incorporated. Copyright 1997 Michael Weller (eowmob@exp-math.uni-essen.de).} message .version.copy2 -width 400 -justify center -text {This configuration\ script may be copied and modified according to the terms and conditions\ of version 2 of the GNU General Public License as published by the\ Free Software Foundation (Cambridge, Massachusetts),\ provided that this notice is not removed. This script was originally the control panel from the Yggdrasil\ distribution. Eric Youngdale thought it looked pretty keen, and it was easy\ to adapt, so he used it as the basis for the SCSI configuration manager.\ The configuration manager was extended by Michael Weller, and finally \ this utility was written and based on it. Well, honestly, not more than ten or twenty lines are copied from scsi-config. \ Thus repeating the copyrights above is probably not required. This is released \ under GPL nevertheless, though. } button .version.dismiss -text "Dismiss" -activebackground green \ -command {destroy .version} -width $butwidth2 pack .version.copy1 .version.copy2 .version.dismiss\ -side top -pady 10 -padx 15 tkwait window .version } proc enter_init {} { global butwidth2 par_initpat par_initmode textwidth winwidth global my_initmode set my_initmode ${par_initmode} if { [winfo exists .init_win] == 1 } { raise .init_win return; } toplevel .init_win wm title .init_win "Initialization of Logical Blocks" wm group . frame .init_win.header label .init_win.header.label -bitmap questhead -bg pink message .init_win.header.message -width 400 -bg pink -text \ "Initialization Pattern for the Logical Blocks." pack .init_win.header.label .init_win.header.message \ -side left -padx 15 pack .init_win.header -side top -pady 10 -padx 15 frame .init_win.row1 frame .init_win.row2 radiobutton .init_win.row1.log -text "of each logical block" \ -variable my_initmode -value "-L" -width $textwidth radiobutton .init_win.row1.phy -text "of each physical block" \ -variable my_initmode -value "-P" -width $textwidth radiobutton .init_win.row2.def -text "Don't write them anywhere" \ -variable my_initmode -value "none" -width $textwidth pack .init_win.row1.log .init_win.row1.phy \ -side left -pady 5 -padx 15 -ipadx 2 -pady 2 pack .init_win.row2.def \ -side left -pady 5 -padx 15 -ipadx 2 -pady 2 label .init_win.mess1 -width $winwidth -text \ "Write the corresponding logical block number in the first 4 bytes:" pack .init_win.mess1 -side top -pady 5 -padx 15 pack .init_win.row1 -side top -pady 5 -padx 15 pack .init_win.row2 -side top -pady 5 -padx 15 label .init_win.mess2 -width $winwidth -text \ "Enter an (optional) sequence of hexnumbers to fill the blocks with:" pack .init_win.mess2 -side top -pady 5 -padx 15 frame .init_win.frame scrollbar .init_win.frame.yscroll -relief sunken \ -command ".init_win.frame.page yview" text .init_win.frame.page -width $winwidth -background white -relief sunken \ -borderwidth 2 -height 8 -wrap char -exportselection 1 \ -yscrollcommand ".init_win.frame.yscroll set" .init_win.frame.page insert 1.0 $par_initpat pack .init_win.frame.yscroll -side right -fill y pack .init_win.frame.page -side top -expand 1 -fill both bind .init_win.frame.page { if { [ string first %A " 0123456789abcdefgABCDEF" ] >= 0 } then { .init_win.frame.page insert insert [string toupper %A] .init_win.frame.page yview -pickplace insert } if { [ string first %A " " ] >= 0 } then { .init_win.frame.page insert insert "\x0a" .init_win.frame.page yview -pickplace insert } } bind .init_win.frame.page { catch { set sel [string toupper [selection get]] regsub -all "\[^ 0123456789ABCDEF\x0a\]" $sel "" sel2 %W insert insert $sel2 } } bind_text .init_win.frame.page pack .init_win.frame -side top -pady 5 -padx 15 frame .init_win.f_bot button .init_win.f_bot.ok -text "Ok" \ -activebackground green -command { set par_initpat [ .init_win.frame.page get 1.0 end ] set par_initmode $my_initmode destroy .init_win } -width $butwidth2 button .init_win.f_bot.dismiss -text "Abort" \ -activebackground red -activeforeground white \ -command {destroy .init_win} -width $butwidth2 pack .init_win.f_bot.ok .init_win.f_bot.dismiss \ -side left -pady 15 -padx 15 -ipadx 2 -pady 2 pack .init_win.f_bot -side top -pady 10 -padx 15 tkwait window .init_win } proc set_msg { form } { switch -- $form { -D { .defs_win.mess3 configure -text \ {Enter defects in the format :: with three numbers \ for cylinder, head, physical sector. Specifying sector -1 marks the whole \ track as defect. You may preceed numbers with 0x or 0 for hexadecimal or \ octal representation } } -B { .defs_win.mess3 configure -text \ {Enter defects in the format :: with three numbers \ for cylinder, head, bytes from index. This marks that number of bytes from \ the index mark as bad. Specifying -1 marks the whole \ track as defect. You may preceed numbers with 0x or 0 for hexadecimal or \ octal representation } } -d { .defs_win.mess3 configure -text \ {Enter defects in the format where is the number of the \ defect logical block. You may preceed numbers with 0x or 0 for hexadecimal or \ octal representation } } } } proc enter_defs {} { global butwidth2 par_defform par_defects textwidth winwidth global my_defform set my_defform $par_defform if { [winfo exists .defs_win] == 1 } { raise .defs_win return; } toplevel .defs_win wm title .defs_win "Manual Defects Addition" wm group . frame .defs_win.header label .defs_win.header.label -bitmap questhead -bg pink message .defs_win.header.message -width 400 -bg pink -text \ "Defects to be added manually." pack .defs_win.header.label .defs_win.header.message \ -side left -padx 15 pack .defs_win.header -side top -pady 10 -padx 15 frame .defs_win.row1 frame .defs_win.row2 radiobutton .defs_win.row1.phy -text "By Physical Sectors" \ -variable my_defform -value "-D" -width $textwidth -command { set_msg $my_defform } radiobutton .defs_win.row1.byt -text "By Bytes from Index" \ -variable my_defform -value "-B" -width $textwidth -command { set_msg $my_defform } radiobutton .defs_win.row2.def -text "By Logical Block Numbers" \ -variable my_defform -value "-d" -width $textwidth -command { set_msg $my_defform } pack .defs_win.row1.phy .defs_win.row1.byt \ -side left -pady 5 -padx 15 -ipadx 2 -pady 2 pack .defs_win.row2.def \ -side left -pady 5 -padx 15 -ipadx 2 -pady 2 label .defs_win.mess1 -width $winwidth -text \ "Select the format in which you want to enter the defects:" pack .defs_win.mess1 -side top -pady 5 -padx 15 pack .defs_win.row1 -side top -pady 5 -padx 15 pack .defs_win.row2 -side top -pady 5 -padx 15 label .defs_win.mess2 -width $winwidth -text \ "Enter an (optional) sequence of of defects:" pack .defs_win.mess2 -side top -pady 5 -padx 15 frame .defs_win.frame scrollbar .defs_win.frame.yscroll -relief sunken \ -command ".defs_win.frame.page yview" text .defs_win.frame.page -width $winwidth -background white -relief sunken \ -borderwidth 2 -height 8 -wrap char -exportselection 1 \ -yscrollcommand ".defs_win.frame.yscroll set" .defs_win.frame.page insert 1.0 $par_defects pack .defs_win.frame.yscroll -side right -fill y pack .defs_win.frame.page -side top -expand 1 -fill both bind .defs_win.frame.page { if { [ string first %A " 0123456789abcdefgABCDEF:-" ] >= 0 } then { .defs_win.frame.page insert insert [string toupper %A] } if { [ string compare %A " " ] == 0 } then { .defs_win.frame.page insert insert "\x0a" } if { [ string first %A "xX" ] >= 0 } then { .defs_win.frame.page insert insert "x" } .defs_win.frame.page yview -pickplace insert } bind .defs_win.frame.page { catch { set sel [string toupper [selection get]] regsub -all "\[^ 0123456789ABCDEFX:\x0a-\]" $sel "" sel2 regsub -all "X" $sel2 "x" sel %W insert insert $sel } } bind_text .defs_win.frame.page pack .defs_win.frame -side top -pady 5 -padx 15 message .defs_win.mess3 -justify center -text "X" -background green \ -aspect 800 set_msg $my_defform pack .defs_win.mess3 -side top -pady 5 -padx 15 frame .defs_win.f_bot button .defs_win.f_bot.ok -text "Ok" \ -activebackground green -command { set par_defects [ .defs_win.frame.page get 1.0 end ] set par_defform $my_defform destroy .defs_win } -width $butwidth2 button .defs_win.f_bot.dismiss -text "Abort" \ -activebackground red -activeforeground white \ -command {destroy .defs_win} -width $butwidth2 pack .defs_win.f_bot.ok .defs_win.f_bot.dismiss \ -side left -pady 15 -padx 15 -ipadx 2 -pady 2 pack .defs_win.f_bot -side top -pady 10 -padx 15 tkwait window .defs_win } proc handle_trans {w ontop} { wm transient $w $ontop wm withdraw $w update idletasks set x [expr [winfo screenwidth $w]/2 - [winfo reqwidth $w]/2 \ - [winfo vrootx [winfo parent $w]]] set y [expr [winfo screenheight $w]/2 - [winfo reqheight $w]/2 \ - [winfo vrooty [winfo parent $w]]] wm geom $w +$x+$y wm deiconify $w set oldFocus [focus] grab $w focus $w tkwait window $w if { [string compare $ontop "."] != 0 } then { grab $ontop } focus $oldFocus } proc post_partsize {} { global butwidth2 par_partmin toplevel .partsize frame .partsize.f_bot wm title .partsize "Maximal partition size" wm group . frame .partsize.header label .partsize.header.label -bitmap questhead -bg pink message .partsize.header.message -width 400 -bg pink -text \ "Maximal partition size." pack .partsize.header.label .partsize.header.message \ -side left -padx 15 pack .partsize.header -side top -pady 10 -padx 15 message .partsize.expl -bg green -width 400 -text \ "Enter the maximal partition size in Megabyte. If it is zero, \ no partition is created and the partition table is left empty. \ Otherwise a partition of this size is created as primary \ partition 1. If the size does not fit the partition is made as \ large as possible." pack .partsize.expl -side top -pady 10 -padx 15 label .partsize.f_inter -text "Maximal partition size in MB: " entry .partsize.f_inter.t -width 5 -background white -relief sunken -borderwidth 2 \ -exportselection 1 .partsize.f_inter.t insert 0 $par_partmin bind_entry .partsize.f_inter.t place .partsize.f_inter.t -in .partsize.f_inter -anchor e -relx 1.0 -rely 0.5 pack .partsize.f_inter -side top -pady 20 -padx 15 button .partsize.f_bot.ok -text "Ok" \ -activebackground green -command { set par_partmin [ .partsize.f_inter.t get ] change_partmin destroy .partsize } -width $butwidth2 button .partsize.f_bot.dismiss -text "Abort" \ -activebackground red -activeforeground white \ -command {destroy .partsize} -width $butwidth2 pack .partsize.f_bot.ok .partsize.f_bot.dismiss \ -side left -pady 15 -padx 15 -ipadx 2 -pady 2 pack .partsize.f_bot -side top -pady 10 -padx 15 handle_trans .partsize . } proc change_geodet { geodet } { if { [ string compare $geodet "-G" ] == 0 } then { .geom.hese.heads configure -foreground black .geom.hese.heads.t configure -state normal .geom.hese.heads.t configure -background white .geom.hese.sectors configure -foreground black .geom.hese.sectors.t configure -state normal .geom.hese.sectors.t configure -background white } else { .geom.hese.heads configure -foreground gray70 .geom.hese.heads.t configure -state disabled .geom.hese.heads.t configure -background bisque .geom.hese.sectors configure -foreground gray70 .geom.hese.sectors.t configure -state disabled .geom.hese.sectors.t configure -background bisque } } proc post_geom {} { global winwidth butwidth2 par_geomdetect par_heads par_sectors textwidth global my_geomdetect set my_geomdetect $par_geomdetect toplevel .geom frame .geom.f_bot wm title .geom "Disk Drive Geometry" wm group . frame .geom.header label .geom.header.label -bitmap questhead -bg pink message .geom.header.message -width 400 -bg pink -text \ "Disk Drive Geometry." pack .geom.header.label .geom.header.message \ -side left -padx 15 pack .geom.header -side top -pady 10 -padx 15 message .geom.expl -bg green -width 400 -text \ "Enter the geometry of the disk. Not the real one, but the one \ DOS will see, s.t. the partition table can be build in a way that \ DOS and other OS's will be able to handle it. Generally, linux \ device drivers report the setting back which the corresponding adapters \ use under DOS. If this fails, 64 heads and 32 are usually used. " pack .geom.expl -side top -pady 10 -padx 15 checkbutton .geom.auto -variable my_geomdetect -onvalue "" -offvalue "-G" \ -text " Query Geometry from Scsidriver " -command {change_geodet $my_geomdetect} pack .geom.auto -side top -pady 20 -padx 15 frame .geom.hese label .geom.hese.heads -text "Heads: " entry .geom.hese.heads.t -width 5 -background white -relief sunken -borderwidth 2 \ -exportselection 1 .geom.hese.heads.t insert 0 $par_heads bind_entry .geom.hese.heads.t place .geom.hese.heads.t -in .geom.hese.heads -anchor e -relx 1.0 -rely 0.5 label .geom.hese.sectors -text "Sectors: " entry .geom.hese.sectors.t -width 5 -background white -relief sunken -borderwidth 2 \ -exportselection 1 .geom.hese.sectors.t insert 0 $par_sectors bind_entry .geom.hese.sectors.t place .geom.hese.sectors.t -in .geom.hese.sectors -anchor e -relx 1.0 -rely 0.5 pack .geom.hese.heads .geom.hese.sectors -side left -pady 15 -padx 15 pack .geom.hese -side top change_geodet $my_geomdetect button .geom.f_bot.ok -text "Ok" \ -activebackground green -command { set par_heads [ .geom.hese.heads.t get ] set par_sectors [ .geom.hese.sectors.t get ] set par_geomdetect $my_geomdetect change_geom $par_geomdetect $par_heads $par_sectors destroy .geom } -width $butwidth2 button .geom.f_bot.dismiss -text "Abort" \ -activebackground red -activeforeground white \ -command {destroy .geom} -width $butwidth2 pack .geom.f_bot.ok .geom.f_bot.dismiss \ -side left -pady 15 -padx 15 -ipadx 2 -pady 2 pack .geom.f_bot -side top -pady 10 -padx 15 handle_trans .geom . } proc post_mkfs {} { global butwidth2 par_mkfs toplevel .mkfs frame .mkfs.f_bot wm title .mkfs "Make FileSystem Command" wm group . frame .mkfs.header label .mkfs.header.label -bitmap questhead -bg pink message .mkfs.header.message -width 400 -bg pink -text \ "Make FileSystem Command." pack .mkfs.header.label .mkfs.header.message \ -side left -padx 15 pack .mkfs.header -side top -pady 10 -padx 15 message .mkfs.expl -bg green -width 400 -text \ "Enter a command to execute to make a filesystem on the freshly created partition.\ The string in the string will be replaced by the name of disk device\ being formatted. Generally you'll have to use 1 to refer to the first\ partition." pack .mkfs.expl -side top -pady 10 -padx 15 frame .mkfs.f_inter scrollbar .mkfs.f_inter.s -relief sunken -orient horiz -command \ ".mkfs.f_inter.t xview" entry .mkfs.f_inter.t -background white -relief sunken -borderwidth 2 \ -exportselection 1 -xscrollcommand ".mkfs.f_inter.s set" .mkfs.f_inter.t insert 0 $par_mkfs bind_eedit .mkfs.f_inter.t bind .mkfs.f_inter.t { .mkfs.f_bot.ok invoke } bind .mkfs.f_inter.t { .mkfs.f_bot.ok invoke } pack .mkfs.f_inter.t .mkfs.f_inter.s -side top -fill both -expand yes pack .mkfs.f_inter -side top -pady 20 -padx 15 -fill both -expand yes button .mkfs.f_bot.ok -text "Ok" \ -activebackground green -command { set par_mkfs [ .mkfs.f_inter.t get ] change_mkfs destroy .mkfs } -width $butwidth2 button .mkfs.f_bot.dismiss -text "Abort" \ -activebackground red -activeforeground white \ -command {destroy .mkfs} -width $butwidth2 pack .mkfs.f_bot.ok .mkfs.f_bot.dismiss \ -side left -pady 15 -padx 15 -ipadx 2 -pady 2 pack .mkfs.f_bot -side top -pady 10 -padx 15 handle_trans .mkfs . } proc set_rands {} { set tworands [exec /usr/lib/scsi/tworands] .conf.equa.sol delete 0 end .conf.equa.a configure -state normal .conf.equa.b configure -state normal .conf.equa.a delete 0 end .conf.equa.b delete 0 end .conf.equa.a insert 0 [lindex $tworands 0] .conf.equa.b insert 0 [lindex $tworands 1] .conf.equa.a configure -state disabled .conf.equa.b configure -state disabled } proc query_format {} { global winwidth butwidth2 textwidth format_cmd sdevice par_fov par_inter par_query \ par_estim par_initpat par_initmode par_defform par_defects par_erase par_partstyle \ par_parttype par_partmin par_geomdetect par_heads par_sectors par_disprim par_nvram \ par_discert par_stop toplevel .conf frame .conf.f_bot wm title .conf "Format Confirmation Request" wm group . frame .conf.header label .conf.header.label -bitmap warning -bg pink message .conf.header.message -width 400 -bg pink -text \ "Format Confirmation Request." pack .conf.header.label .conf.header.message \ -side left -padx 15 pack .conf.header -side top -pady 10 -padx 15 message .conf.expl -bg red -fg white -width 400 -justify center -text \ "Formatting will erase all data on $sdevice, regardless on which \ partition, and there will be NO way to recover your data. Therefore, please check now if you really want to format this device. \ To ensure that your are really with me and know what you do, please \ answer the simple question below." pack .conf.expl -side top -pady 10 -padx 15 frame .conf.equa entry .conf.equa.a -width 3 -relief sunken -borderwidth 2 -state disabled label .conf.equa.times -text "*" entry .conf.equa.b -width 3 -relief sunken -borderwidth 2 -state disabled label .conf.equa.equa -text "=" entry .conf.equa.sol -width 5 -background white -relief sunken -borderwidth 2 \ -exportselection 1 bind_entry .conf.equa.sol set_rands pack .conf.equa.a .conf.equa.times .conf.equa.b .conf.equa.equa .conf.equa.sol \ -side left -pady 10 -padx 3 pack .conf.equa -side top message .conf.result -bg red -fg white -aspect 900 -text "Wrong! Please retry or bail out!" frame .conf.space pack .conf.space -side top -pady 8 button .conf.f_bot.ok -text "Confirm" \ -activebackground yellow -command { if { [expr [.conf.equa.a get] * [.conf.equa.b get]] == [.conf.equa.sol get] } then { destroy .conf do_format $format_cmd } else { set_rands pack .conf.result -after .conf.equa -side top -pady 2 -padx 15 } } -width $butwidth2 button .conf.f_bot.show -text "Show ScsiFormat Command" \ -activebackground green -command { show_format "$format_cmd $sdevice" } -width $butwidth2 pack .conf.f_bot.ok .conf.f_bot.show -side left -pady 15 -padx 15 -ipadx 2 -pady 2 button .conf.dismiss -text "Bail Out" \ -activebackground red -activeforeground white \ -command {destroy .conf} -width $butwidth2 pack .conf.f_bot -side top -padx 15 pack .conf.dismiss -side top -pady 10 set format_cmd "/usr/sbin/scsiformat $par_erase -i$par_inter" regsub -all "\x0a" [string trim $par_defects] " " tmpstr regsub -all " +" $tmpstr "," tmpstr if { [string length $tmpstr] > 0 } then { append format_cmd " $par_defform$tmpstr" } if { [string compare $par_partstyle "none"] != 0 } then { append format_cmd " $par_partstyle $par_parttype -M$par_partmin" } if { [string compare $par_geomdetect "-G"] == 0 } then { append format_cmd " $par_geomdetect${par_heads}x$par_sectors" } if { [string compare $par_fov "-o"] == 0} then { append format_cmd " $par_fov" if { [string compare $par_initmode "none"] != 0 } then { append format_cmd " $par_initmode" } regsub -all "\[ \x0a\]" [string trim $par_initpat] "" tmpstr if { [string length $tmpstr] > 0 } then { append format_cmd " -I$tmpstr" } append format_cmd " $par_discert $par_disprim $par_stop $par_nvram" } if { [string compare $par_query "-b"] == 0 } then { append format_cmd " -b$par_estim" } #trim unneccessary spaces: regsub -all " +" [string trim $format_cmd] " " format_cmd handle_trans .conf . } proc show_format {cmd} { global winwidth butwidth2 textwidth toplevel .showcmd frame .showcmd.f_bot wm title .showcmd "Show ScsiFormat Command" wm group . frame .showcmd.header label .showcmd.header.label -bitmap info -bg pink message .showcmd.header.message -width 400 -bg pink -text \ "Show ScsiFormat Command." pack .showcmd.header.label .showcmd.header.message \ -side left -padx 15 pack .showcmd.header -side top -pady 10 -padx 15 message .showcmd.expl -width 400 -text \ "This is the command which will perform the scsi low level format you requested:" pack .showcmd.expl -side top -pady 10 -padx 15 message .showcmd.cmd -width 400 -text $cmd -relief sunken pack .showcmd.cmd -side top -pady 10 -padx 15 button .showcmd.dismiss -text "Dismiss" \ -activebackground red -activeforeground white \ -command {destroy .showcmd} -width $butwidth2 pack .showcmd.dismiss -side top -pady 10 handle_trans .showcmd .conf } proc do_format {fcmd} { global par_query par_estim sdevice global winwidth butwidth2 textwidth global check_cmd format_initiator set security "-F'Ene Mene Meck, und Du bist weg!'" append fcmd " $security -t0 -X $sdevice" if { [catch {exec sh -c "$fcmd" >& /var/run/scsiformat.[pid] } err] != 0 } then { set fd [open /var/run/scsiformat.[pid] r] set err "$err\x0a[read $fd]" close $fd exec rm /var/run/scsiformat.[pid] show_err scsiformat $err return; } exec rm /var/run/scsiformat.[pid] set format_initiator 1 show_busy } proc show_err {cmd msg} { global winwidth butwidth2 textwidth if { [winfo exists .error] == 1 } { .error.msg configure -text $msg raise .error tkwait window .error return; } toplevel .error frame .error.f_bot wm title .error "ScsiFormat Error" wm group . frame .error.header label .error.header.label -bitmap error -bg pink message .error.header.message -width 400 -bg pink -text \ "Show $cmd Error Message." pack .error.header.label .error.header.message \ -side left -padx 15 pack .error.header -side top -pady 10 -padx 15 message .error.expl -width 600 -text \ "$cmd returned the following error message:" pack .error.expl -side top -pady 10 -padx 15 message .error.msg -width 600 -text $msg -relief sunken pack .error.msg -side top -pady 10 -padx 15 button .error.dismiss -text "Dismiss" \ -activebackground red -activeforeground white \ -command {destroy .error} -width $butwidth2 pack .error.dismiss -side top -pady 10 tkwait window .error } proc query_prog {} { global sdevice errorCode wasbusy format_initiator par_mkfs set check_cmd "/usr/sbin/scsiformat -T -t1 -X $sdevice" if { [winfo exists .showprog] != 1 } { return; } set errorCode [list CHILDSTATUS 0 0] catch {exec sh -c "$check_cmd"} err if { ([string compare [lindex $errorCode 0] CHILDSTATUS] != 0) || ([lindex $errorCode 2] > 1) } then { show_err scsiformat $err } elseif { [lindex $errorCode 2] == 1 } then { if {[catch { .showprog.row2.start configure -text [lindex $err 0] .showprog.row2.end configure -text [lindex $err 3] set percent [lindex $err 1] if { [string compare $percent "-"] != 0} then { .showprog.expl configure -text [format "%.10g%% in %s" [expr 100 * $percent] \ [lindex $err 2] ] if { $percent >= 1.0 } then { set percent 1.0 } } else { .showprog.expl configure -text [lindex $err 2] set percent 0 } place .showprog.slider.inner -in .showprog.slider -relwidth $percent -relheight 1.0 \ -anchor nw -x 0 -y 0 set wasbusy 1 after 5000 query_prog}] != 0} then { #Something weird went on. Like illegal device name, read-only device, etc.. destroy .showprog } } else { destroy .showprog if { $format_initiator == 1} then { set format_initiator 0 if { [string compare $par_mkfs "1"] != 0} then { regsub "" $par_mkfs "${sdevice}" cmd # #it seems that we have to wait even more... # #a mayor reason is that the format might have completed, but scsiformat is #still creating the partion which will also include some sleep()'s # exec sync exec sh -c "sleep 10" set errorCode [list NONE 0 0] catch {exec sh -c "$cmd"} err if { ([string compare [lindex $errorCode 0] CHILDSTATUS] == 0) } then { show_err "Filesystem maker"\ "'$cmd' exited with errorcode - [lindex $errorCode 2]\x0a$err" } } } if { $wasbusy == 1 } then { puts -nonewline stderr "\x0a" flush stderr } } } proc show_busy {} { global textwidth wasbusy toplevel .showprog frame .showprog.f_bot wm title .showprog "Show ScsiFormat Progress" wm group . frame .showprog.header label .showprog.header.label -bitmap hourglass -bg pink message .showprog.header.message -width 400 -bg pink -text \ "Formatting in Progress." pack .showprog.header.label .showprog.header.message \ -side left -padx 15 pack .showprog.header -side top -pady 10 -padx 15 frame .showprog.space pack .showprog.space -side top -pady 5 frame .showprog.row1 frame .showprog.row2 pack .showprog.row1 .showprog.row2 -side top -expand yes -fill both -padx 4 label .showprog.row1.start -text "Started" -borderwidth -1 pack .showprog.row1.start -side left frame .showprog.row1.space pack .showprog.row1.space -after .showprog.row1.start -side left -expand yes -fill both label .showprog.row1.end -text "Estimated End" -borderwidth -1 pack .showprog.row1.end -side right label .showprog.row2.start -borderwidth -1 pack .showprog.row2.start -side left frame .showprog.row2.space pack .showprog.row2.space -after .showprog.row2.start -side left -expand yes -fill both label .showprog.row2.end -borderwidth -1 pack .showprog.row2.end -side right frame .showprog.slider -borderwidth 2 -height 20 -relief sunken pack .showprog.slider -side top -expand yes -fill both -pady 4 -padx 4 frame .showprog.slider.inner -borderwidth 2 -relief raised -bg SlateGray1 message .showprog.expl -width 400 -text "X" -borderwidth -1 pack .showprog.expl -side top frame .showprog.space2 pack .showprog.space2 -side top -pady 2 set wasbusy 0 query_prog if { [winfo exists .showprog] != 1 } { return; } handle_trans .showprog . } wm title . "TkScsiformat Version 1.0" if { [string compare $whoami root] != 0} then { frame .warn frame .warn.h label .warn.h.l -bitmap info -background pink message .warn.h.m -aspect 200 -background pink -justify center -text \ {You need to be root in order to format a SCSI device!} pack .warn.h.l .warn.h.m -side left -padx 10 button .warn.quit -text "Quit" -command exit \ -activeforeground white -activebackground red pack .warn.h .warn.quit -side top -pady 10 pack .warn tkwait window .warn } if { [llength $argv] > 1 } then { puts stderr "Usage: tk_scsiformat \[device\]" exit } while { [string compare [lindex $sdevice 0] ""] == 0 } { frame .select frame .select.h label .select.h.l -bitmap questhead -background pink message .select.h.m -justify center -aspect 500 -background pink -text \ {Select a SCSI device to low level format.} frame .select.f button .select.f.quit -text " Quit " -command exit \ -activeforeground white -activebackground red button .select.f.continue -text " Continue " -activebackground green \ -command {destroy .select} pack .select.f.continue .select.f.quit -side left -padx 10 pack .select.h.l .select.h.m -side left -padx 10 pack .select.h -pady 10 pack .select set line [exec /sbin/scsiinfo -l] set n 0 foreach x $line { if {[string first "/dev/sd" "$x"] != 0} continue; radiobutton .select.$n -text "$x" -width 10 \ -variable sdevice -value $x -anchor w pack .select.$n -padx 3 set n [expr $n+1] } if { $n == 0 } then { .select.f.continue configure -state disabled } else { .select.0 select } pack .select.f -pady 10 tkwait window .select } set save_file "/usr/lib/scsi/scsiformat.defs.[file tail $sdevice]" catch {source $save_file} frame .header label .header.label -bitmap question -bg pink message .header.message -width 400 -bg pink -text \ "Scsi Low Level Format - $sdevice." pack .header.label .header.message -side left -padx 15 frame .f_bot1 button .f_bot1.copyrights -activebackground green -text "Version Info" \ -command { copyrights } -width $butwidth button .f_bot1.filesave -activebackground green -text "Save Defaults" \ -width $butwidth -command { global vars2save save_file set fd [open $save_file w] foreach var $vars2save { save_var $fd $var } close $fd } button .f_bot1.simple -activebackground green -text "Simple Format Cmd" \ -command "simple" -width $butwidth pack .f_bot1.copyrights .f_bot1.filesave .f_bot1.simple \ -side left -padx 12 -ipadx 2 -ipady 2 -pady 5 frame .f_bot2 button .f_bot2.format -text "Format" -command { query_format } \ -activebackground yellow -activeforeground black -width $butwidth2 button .f_bot2.quit -text "Quit" -command { exit } \ -activebackground red -activeforeground white -width $butwidth2 pack .f_bot2.format .f_bot2.quit -side left -padx 12 -ipadx 2 -ipady 2 -pady 5 frame .f_mand -width $winwidth checkbutton .f_mand.erase -offvalue "" -onvalue "-e" -variable par_erase -text \ "Erase Grown Defect List" -width [expr $textwidth - 1] label .f_mand.f_inter -text "Interleave (0 for default): " -width $textwidth entry .f_mand.f_inter.t -width 5 -background white -relief sunken -borderwidth 2 \ -exportselection 1 -textvariable par_inter bind_entry .f_mand.f_inter.t place .f_mand.f_inter.t -in .f_mand.f_inter -anchor e -relx 1.0 -rely 0.5 pack .f_mand.erase .f_mand.f_inter -side left -padx 12 -ipadx 2 -ipady 2 frame .f_def button .f_def.defects -text "Add Defects Manually" -activebackground yellow -command enter_defs \ -width [expr $textwidth] menubutton .f_def.part -text "Simple Partioning" \ -width [expr $textwidth] -relief raised -menu .f_def.part.menu \ -activebackground SlateGray1 menu .f_def.part.menu -background SlateGray1 -activebackground SlateGray2 .f_def.part.menu add radiobutton -label "Don't touch Partion Sector" \ -variable par_partstyle -value "none" .f_def.part.menu add radiobutton -label "DOS Style Partion" \ -variable par_partstyle -value "-fdos" .f_def.part.menu add radiobutton -label "Tight Style Partion (not on Cylinder Boundary)" \ -variable par_partstyle -value "-ftight" .f_def.part.menu add separator .f_def.part.menu add cascade -menu .f_def.part.menu.types -label "Partition type" .f_def.part.menu add cascade -menu .f_def.part.menu.mkfs -label "Filesystem type" .f_def.part.menu add separator .f_def.part.menu add command -command post_geom .f_def.part.menu add command -command post_partsize menu .f_def.part.menu.types -background SlateGray1 -activebackground SlateGray2 .f_def.part.menu.types add radiobutton -variable par_parttype \ -label "Linux/Minix" -value "-y81" .f_def.part.menu.types add radiobutton -variable par_parttype \ -label "Linux swap" -value "-y82" .f_def.part.menu.types add radiobutton -variable par_parttype \ -label "Linux native" -value "-y83" .f_def.part.menu.types add radiobutton -variable par_parttype \ -label "DOS 12-bit FAT" -value "-y01" .f_def.part.menu.types add radiobutton -variable par_parttype \ -label "DOS 16-bit FAT <32M" -value "-y52" .f_def.part.menu.types add radiobutton -variable par_parttype \ -label "DOS 16-bit FAT >=32M" -value "-y64" menu .f_def.part.menu.mkfs -background SlateGray1 -activebackground SlateGray2 for {set i 0} {$i < [llength $par_mkfsnames]} {incr i} { .f_def.part.menu.mkfs add radiobutton -variable par_mkfs -command change_mkfs \ -label "[lindex $par_mkfsnames $i]" -value "[lindex $par_mkfscmds $i]" } .f_def.part.menu.mkfs add separator .f_def.part.menu.mkfs add command -command post_mkfs change_mkfs change_partmin change_geom $par_geomdetect $par_heads $par_sectors pack .f_def.defects .f_def.part -side left -padx 12 -ipadx 2 -ipady 2 frame .f_opt -width $winwidth -relief raised -borderwidth 2 checkbutton .f_opt.fov -offvalue "" -onvalue "-o" -variable par_fov -text \ " Use Custom Format Parameters" -command change_fov -activebackground yellow \ -width [expr $winwidth - 2] pack .f_opt.fov -side top -padx 12 -ipadx 2 -ipady 2 -pady 5 frame .f_opt.col1 frame .f_opt.col2 button .f_opt.col1.init -text "Enter initialization pattern" -activebackground yellow \ -command enter_init -width [expr $textwidth + 2] checkbutton .f_opt.col1.disprim -offvalue "" -onvalue "-p" -variable par_disprim -text \ "Ignore Primary Defects" -width $textwidth checkbutton .f_opt.col1.nvram -offvalue "" -onvalue "-S" -variable par_nvram -text \ "Erase MODE SELECT Nvram" -width $textwidth pack .f_opt.col1.init .f_opt.col1.disprim .f_opt.col1.nvram \ -side top -padx 12 -ipadx 2 -ipady 2 -pady 5 checkbutton .f_opt.col2.discert -offvalue "" -onvalue "-c" -variable par_discert -text \ "Disable Media Certification" -width $textwidth checkbutton .f_opt.col2.stop -offvalue "" -onvalue "-s" -variable par_stop -text \ "Stop On Missing Defectlist" -width $textwidth label .f_opt.col2.dummy pack .f_opt.col2.discert .f_opt.col2.stop .f_opt.col2.dummy \ -side top -padx 12 -ipadx 2 -ipady 2 -pady 5 pack .f_opt.col1 .f_opt.col2 -side left frame .f_block checkbutton .f_block.par_block -offvalue "-b" -onvalue "" -variable par_query -text \ "Query progress from target" -width $textwidth -command { block_change $par_query } label .f_block.f_estim -text "Estimated run time in sec: " -width $textwidth entry .f_block.f_estim.t -width 5 -background white -relief sunken -borderwidth 2 \ -exportselection 1 -textvariable par_estim bind_entry .f_block.f_estim.t place .f_block.f_estim.t -in .f_block.f_estim -anchor e -relx 1.0 -rely 0.5 pack .f_block.par_block .f_block.f_estim -side left -padx 12 -ipadx 2 -ipady 2 block_change $par_query change_fov pack .header -padx 10 -pady 10 pack .f_mand .f_def -pady 4 pack .f_opt -padx 10 -pady 10 pack .f_block -padx 10 -pady 4 pack .f_bot1 .f_bot2 -padx 10 -pady 4 show_busy debian/lintian-overrides0000664000000000000000000000020612233502660012546 0ustar scsitools: shell-script-fails-syntax-check ./usr/sbin/scsi-config scsitools: shell-script-fails-syntax-check ./usr/sbin/tk_scsiformat debian/upstream.changelog0000664000000000000000000000020312233502660012673 0ustar Please refer to CHANGES.scsiinfo to get history of scsiinfo subpackage and CHANGES.scsidev to get history of scsidev subpackage. debian/README.source0000664000000000000000000000036212233502660011347 0ustar This package uses quilt to manage all modifications to the upstream source. Changes are stored in the source package as diffs in debian/patches and applied during the build. See /usr/share/doc/quilt/README.source for a detailed explanation. debian/scsitools.sh0000664000000000000000000000531112233502660011545 0ustar #!/bin/sh ### BEGIN INIT INFO # Provides: scsitools # Required-Start: checkroot scsitools-pre # Required-Stop: # X-Start-Before: checkfs # Default-Start: S # Default-Stop: # Short-Description: Create aliases for SCSI devices under /dev/scsi ### END INIT INFO # # This is the second part of populating /dev/scsi. Now / is writable, so # remove the ramdisk and recreate the tree. # When used with restart/force-reload argument, also rescan the SCSI bus to be # sure the contents of /dev/scsi is in sync with accessible hardware. # # Written by Eric Delaunay based on sources found in # scsidev 2.10 from Kurt Garloff . # # Licensed under GPL. scsidevrw=0 # is /dev/scsi writable at boot time? needscsidev=0 # is scsidev needed at all? swapdev=0 # is there swap device on /dev/scsi/... ? # set needscsidev to 1 if /dev/scsi is referenced in /etc/fstab and set # scsidevrw to 1 if /dev/scsi is a ramdisk (mounted from scsitools-pre.sh) if [ ! -e /dev/.devfsd ]; then if grep -q '^/dev/scsi' /etc/fstab; then needscsidev=1 if [ ! -d /dev/scsi/lost+found ]; then scsidevrw=1 fi fi fi case "$1" in start) # if running from rcS, needscsidev & scsidevrw are already set by # scsitools-pre.sh to either 0 or 1. if [ -x /sbin/scsidev -a "$needscsidev" = 1 -a "$scsidevrw" = 0 ]; then # no need to rerun scsidev if previously done on a writable fs by # scsitools-pre.sh, otherwise... echo "Setting up SCSI devices (second part)..." # disable swap in case it is using a device under /dev/scsi # (/dev/scsi/swapdev used to be living on a ramdisk that have to be # destroyed) if grep -q '^/dev/scsi/' /proc/swaps; then swapoff -a swapdev=1 fi # if using a ramdisk, free it first # (test is always true except when no support for ramdisk in kernel) if grep -q "/dev/ram3 .*/dev/scsi" /proc/mounts; then umount -n /dev/scsi blockdev --flushbufs /dev/ram3 fi /sbin/scsidev -r -q # execute swapon again, in case we want to swap to another device # residing out of the boot disk. if [ $swapdev = 1 ]; then swapon -a fi fi ;; restart | force-reload) if [ -x /sbin/scsidev -a "$needscsidev" = 1 ]; then echo "Setting up SCSI devices..." # rescan the SCSI bus first /sbin/rescan-scsi-bus -r -w # then fills /dev/scsi again according to detected devices /sbin/scsidev -r -q fi ;; reload) if [ -x /sbin/scsidev -a "$needscsidev" = 1 ]; then echo "Setting up SCSI devices..." # only sets up /dev/scsi contents again /sbin/scsidev -r -q fi ;; stop) # nothing to stop here. ;; *) echo "Usage: $0 {start|stop|restart|reload|force-reload}" exit 1 ;; esac unset needscsidev scsidevrw debian/patches/0000775000000000000000000000000012233502660010616 5ustar debian/patches/sraw.patch0000664000000000000000000002300612233502660012614 0ustar Description: updated code to work on modern Linux systems: - Removed GCC warnings - send SCSI commands using SG_IO - Debian FHS compliant. Forwarded: no Author: Eric Delaunay --- a/sraw/srawread.c +++ n/sraw/srawread.c @@ -79,19 +79,25 @@ * */ -#define USE_READ_10 -#undef SET_FUA /* "force unit access" for READ(10): don't read from cache but from media */ -#define LESS_VERBOSE_OUTPUT #define USE_GETTIMEOFDAY /* please, always! gettimeofday(2) is much more accurate */ +#define USE_SG_IO #include +#include #include +#include +#include #include #include +#include +#include +#ifdef USE_SG_IO +# include +#endif -FILE *infile, *ptable; -unsigned char buffer[2*64*1024]; +FILE *infile = NULL; +unsigned char buffer[2*64*1024+8]; int read_size=32768; @@ -121,54 +127,99 @@ int main( int argc, char *argv[] ) { int b,bstart=0,bstep=1; + int c=1,verbose=0; int status, i; unsigned char *cmd; - int capacity, sectorsize; + unsigned int capacity, sectorsize; int this_count, block; int rate; double starttime, endtime; - - if (argc==1) { - printf("usage: srawread scsi-device [ bstart [ bstop ] ]\n"); - exit(0); + int read_len = 10; /* length of read command */ + int fua = 0; /* "force unit access" for READ(10): don't read from cache but from media */ +#ifdef USE_SG_IO + sg_io_hdr_t sgbuf; + int legacy_ioctl=0; +#endif + + while (argc>c && argv[c][0] == '-') { + for(i=1; i < strlen(argv[c]); i++) + switch (argv[c][i]) { + case 'v': verbose = 1; break; +#ifdef USE_SG_IO + case 'i': legacy_ioctl = 1; break; +#endif + case 'f': fua = 1; break; + case '6': read_len = 6; break; + default: goto error; + } + c++; + } + if (argc>c) { + infile = fopen( argv[c], "r" ); + if (!infile) { + perror(argv[c]); + return 2; + } } + if (argc>c+1) bstart = atoi(argv[c+1]); + if (argc>c+2) bstep = atoi(argv[c+2]); - infile = fopen( argv[1], "r" ); - if(!infile) exit(0); + if (infile == NULL || argc==1 || argc>c+3) { +error: + printf("usage: sraw [-v]%s scsi-device [ bstart [ bstep ] ]\n", +#ifdef USE_SG_IO + "[-i]" +#else + "" +#endif + ); + return 1; + } - if (argc>2) bstart = atoi(argv[2]); - if (argc>3) bstep = atoi(argv[2]); + memset(buffer, 0, sizeof(buffer)); - for (i=0; i<10*1024; i++) - { - buffer[i] = 0; - } - *( (int *) buffer ) = 0; /* length of input data */ *( ((int *) buffer) + 1 ) = read_size; /* length of output buffer */ - cmd = (char *) ( ((int *) buffer) + 2 ); + cmd = (unsigned char *) ( ((int *) buffer) + 2 ); - cmd[0] = 0x25; /* INQUIRY */ - cmd[1] = 0x00; /* lun=0, evpd=0 */ - cmd[2] = 0x00; /* page code = 0 */ - cmd[3] = 0x00; /* (reserved) */ - cmd[4] = 0x00; /* allocation length */ - cmd[5] = 0x00; /* control */ - + cmd[0] = 0x25; /* READ CAPICTY (10 bytes)*/ + cmd[1] = 0x00; /* b7-5: lun=0, b4-1: reserved, b0: reladdr=0 */ + /* cmd[2..5] = 0x00; logical block address = 0 */ + /* cmd[6..8] = 0x00; (reserved), cmd[8].b0=PMI(0) */ + /* cmd[9] = 0x00; control */ + +#ifdef USE_SG_IO + if (! legacy_ioctl) { + memset(&sgbuf, 0, sizeof(sgbuf)); + sgbuf.interface_id = 'S'; /* SCSI Generic Interface */ + sgbuf.dxfer_direction = SG_DXFER_FROM_DEV; + sgbuf.cmd_len = 10; + sgbuf.cmdp = cmd; + sgbuf.dxfer_len = 8; /* send back 8 bytes of data (capacity, sectorsize) */ + sgbuf.dxferp = cmd; + sgbuf.timeout = 2000; + status = ioctl( fileno(infile), SG_IO, &sgbuf ); + } + else +#endif status = ioctl( fileno(infile), 1 /* SCSI_IOCTL_SEND_COMMAND */, buffer ); - + if (status < 0) { + perror("ioctl"); + return 3; + } capacity = (buffer[8] << 24) | (buffer[9] << 16) | (buffer[10] << 8) | buffer[11]; sectorsize = (buffer[12] << 24) | (buffer[13] << 16) | (buffer[14] << 8) | buffer[15]; - printf("Size %d sectorsize %d\n", capacity * (sectorsize >> 9), sectorsize); - + if (verbose) + printf("Size %llu bytes, sectorsize %u\n", ((uint64_t)capacity) * sectorsize, sectorsize); do{ +/* for (i=0; i<10*1024; i++) { buffer[i] = 0; } - +*/ block = 0; this_count = read_size / sectorsize; starttime = time_so_far(); @@ -176,45 +227,62 @@ *( (int *) buffer ) = 0; /* length of input data */ *( ((int *) buffer) + 1 ) = read_size; /* length of output buffer */ - cmd = (char *) ( ((int *) buffer) + 2 ); + cmd = (unsigned char *) ( ((int *) buffer) + 2 ); b = bstart + bstep * block; -#ifdef USE_READ_10 - cmd[0] = 0x28; /* read_10 */ - cmd[1] = 0x00; -#ifdef SET_FUA - cmd[1] |= 0x08; -#endif /* SET_FUA */ - cmd[2] = (b >> 24) & 0xff; - cmd[3] = (b >> 16) & 0xff; - cmd[4] = (b >> 8) & 0xff; - cmd[5] = b & 0xff; - cmd[6] = 0; - cmd[7] = (this_count >> 8) & 0xff; /* transfer length */ - cmd[8] = this_count & 0xff; - cmd[9] = 0x00; /* control */ -#else /* USE_READ_10 */ - cmd[0] = 0x08; /* read_6 */ - cmd[1] = (b >> 16) & 0x1f; - cmd[2] = (b >> 8) & 0xff; - cmd[3] = b & 0xff; - cmd[4] = this_count; - cmd[5] = 0x00; -#endif /* USE_READ_10 */ - + if (read_len == 10) { + cmd[0] = 0x28; /* read_10 */ + cmd[1] = 0x00; + if (fua) + cmd[1] |= 0x08; + cmd[2] = (b >> 24) & 0xff; + cmd[3] = (b >> 16) & 0xff; + cmd[4] = (b >> 8) & 0xff; + cmd[5] = b & 0xff; + cmd[6] = 0; + cmd[7] = (this_count >> 8) & 0xff; /* transfer length */ + cmd[8] = this_count & 0xff; + cmd[9] = 0x00; /* control */ + } + else { + cmd[0] = 0x08; /* read_6 */ + cmd[1] = (b >> 16) & 0x1f; + cmd[2] = (b >> 8) & 0xff; + cmd[3] = b & 0xff; + cmd[4] = this_count; + cmd[5] = 0x00; + } +#ifdef USE_SG_IO + if (! legacy_ioctl) { + memset(&sgbuf, 0, sizeof(sgbuf)); + sgbuf.interface_id = 'S'; /* SCSI Generic Interface */ + sgbuf.dxfer_direction = SG_DXFER_FROM_DEV; + sgbuf.cmd_len = read_len; + sgbuf.cmdp = cmd; + sgbuf.dxfer_len = read_size; + sgbuf.dxferp = cmd; + sgbuf.timeout = 2000; + status = ioctl( fileno(infile), SG_IO, &sgbuf ); + } + else +#endif status = ioctl( fileno(infile), 3 /* SCSI_IOCTL_BENCHMARK_COMMAND */, buffer ); - if(status) fprintf(stderr,"%x ", status); + if (status < 0) { + if (verbose) + printf("ioctl: %s\n", strerror(errno)); + else + printf("(%d) ", status); + } block += this_count; } while(block < (10000 / (sectorsize >> 9))); endtime = time_so_far() - starttime; rate = (block * sectorsize) / endtime; -#ifdef LESS_VERBOSE_OUTPUT - printf("%6d %10.4f %6d %8d \n", + if (!verbose) + printf("%6d %10.4f %6d %8d \n", read_size, endtime, block, rate); -#else /* LESS_VERBOSE_OUTPUT */ - printf("Blocksize %d, time elapsed %1.4f seconds, %d blocks. Throughput = %d bytes/sec\n", + else + printf("Blocksize %d, time elapsed %1.4f seconds, %d blocks. Throughput = %d bytes/sec\n", read_size, endtime, block, rate); -#endif /* LESS_VERBOSE_OUTPUT */ read_size += 4096; } while(read_size <= 2*64*1024); --- a/sraw/sraw.8 +++ b/sraw/sraw.8 @@ -0,0 +1,82 @@ +.\" -*- nroff -*- +.TH SRAW 8 "Nov 1993" +.SH NAME +sraw \- benchmark raw scsi I/O performance under linux +.SH SYNOPSIS +.B sraw +[ +.B -fiv6 +] +.B scsi-device +[ +.B bstart +[ +.B bstep +] ] +.SH DESCRIPTION +This program basically reads the specified scsi device and measures the +throughput. Note that the filesystem *AND* the buffer cache are +bypassed by this code, this program was designed to benchmark the naked +scsi drivers by themselves without the need to account for the overhead +of any other portion of the kernel. It also could be used to benchmark +disk read throughput. +.P +This program does a series of reads of the disk, of consecutive +areas on the disk. The device is first queried to determine the +sector size for the device, and then the series of reads is begun. +About 5.0 Mb is read from the device, and then the performance numbers +are reported. Note that since the buffer cache is completely bypassed, +there is no need to be concerned about cache hits or anything. +.P +Output of +.B sraw +is a set of lines, 4 numbers per line: +.I blocksize, elapsed time, nblocks +and +.I throughput +(in bytes per second). +.P +.B scsi-device +is either a block device (e.g. /dev/sda, /dev/scd0) or a generic SCSI +device (e.g. /dev/sg0). +.SH OPTIONS +.TP +.I -f +set FUA (Force Unit Access) bit during read. Data is then read from +media instead of internal drive cache. +.TP +.I -i +use legacy ioctl instead of new SG I/O layer (will not work on 2.6 +kernel and block devices). +.TP +.I -v +more verbose output. +.TP +.I -6 +use 6-bytes instead of 10-bytes read command. In this case, only the +first GB of data could be read from media. +.TP +.I bstart +starting block to check different zones on ZBR discs +.TP +.I bstep +factor for sequential stepping, default 1. +Use 0 for reading always the same blocks (from cache) +.SH ERRORS +.B sraw +could issue input/output errors when reading too many blocks at the +same time from a block device like /dev/sda. To get rid of them, use +/dev/sgN instead. +.SH AUTHOR +.B sraw +was first written by Eric Youngdale. +Extensions (-v, -f, -6, SG IO, man page) were written by Eric Delaunay. +.SH SEE ALSO +.B sg_dd(8) +from sg3-utils package. +.SH AVAILABILITY +.B sraw +is available at +.nf +.B ftp://tsx-11.mit.edu/pub/linux/ALPHA/scsi/ +.fi debian/patches/scsiinfo.patch0000664000000000000000000010566412233502660013470 0ustar Description: updated code to work on modern Linux systems: - TK-8.x compliant - Removed GCC warnings - send SCSI commands using SG_IO - Debian FHS compliant. Forwarded: no Author: Eric Delaunay --- a/scsiinfo/tworands.c +++ b/scsiinfo/tworands.c @@ -6,7 +6,7 @@ #include #include -int main(int argc) { +int main(int argc, char **argv) { struct timeval tv; if (argc != 1) { --- a/scsiinfo/Makefile +++ b/scsiinfo/Makefile @@ -1,11 +1,11 @@ -CFLAGS=-O2 -fomit-frame-pointer -Wall -fno-strength-reduce +CFLAGS=${KERNEL_INCLUDES} -g -O2 -Wall -fomit-frame-pointer -fno-strength-reduce -D_GNU_SOURCE #CFLAGS=-g -Wall -fno-strength-reduce LDFLAGS=-s #do not modify this without changing the tcl/tk scripts -BINDIR=/usr/lib/scsi -MANDIR=/usr/man +BINDIR=$(DESTDIR)/usr/lib/scsi +MANDIR=$(DESTDIR)/usr/share/man WISHEXECS=tk/cache tk/control tk/disconnect tk/error tk/format\ tk/inquiry tk/notch tk/peripheral tk/rigid tk/save-changes tk/verify\ tk/save-file tk/overview @@ -16,13 +16,18 @@ all: $(TARGETS) install: $(TARGETS) $(WISHEXECS) scsi-config tk_scsiformat - cp scsiinfo scsiformat /usr/bin - if [ ! -d $(BINDIR) ]; then mkdir -p $(BINDIR); fi + test -d $(DESTDIR)/sbin || mkdir -p $(DESTDIR)/sbin + test -d $(DESTDIR)/usr/sbin || mkdir -p $(DESTDIR)/usr/sbin + test -d $(BINDIR) || mkdir -p $(BINDIR) + cp scsiinfo $(DESTDIR)/sbin + cp scsiformat $(DESTDIR)/usr/sbin cp tworands $(BINDIR) - install-wish $(BINDIR) $(WISHEXECS) - install-wish /usr/bin scsi-config tk_scsiformat + ./install-wish $(BINDIR) $(WISHEXECS) + #./install-wish $(DESTDIR)/usr/sbin scsi-config tk_scsiformat + cp scsi-config tk_scsiformat $(DESTDIR)/usr/sbin cp tk/generic $(BINDIR) - cp man8/* $(MANDIR)/man8 + # manuals are installed by dh_installmanpages in debian/rules + #cp man8/* $(MANDIR)/man8 clean: rm -f core *~ *.o $(TARGETS) --- a/scsiinfo/scsi-config +++ b/scsiinfo/scsi-config @@ -1,3 +1,7 @@ +#!/bin/sh +# the next lines restarts using wish or abort with a message \ +type wish > /dev/null 2>&1 && exec wish -f "$0" "$@" || \ +echo "no /usr/bin/wish found: please install the tk package." && exit 1 #!/usr/bin/wish -f # Copyright 1993 Yggdrasil Computing, Incorporated # You may copy this file according to the terms and conditions of version 2 @@ -42,11 +46,11 @@ pack .select.h.l .select.h.m -side left -padx 10 pack .select.h .select.f -pady 10 pack .select - exec /usr/bin/scsiinfo -l > /tmp/devices - if {[catch {set file [open /tmp/devices r]}] == 1} return; + exec /sbin/scsiinfo -l > /var/run/devices + if {[catch {set file [open /var/run/devices r]}] == 1} return; gets $file line close $file - exec rm /tmp/devices + exec rm /var/run/devices set n 0 foreach x $line { radiobutton .select.$n -text "$x" -width 10 -variable sdevice -value $x -anchor w @@ -102,7 +106,7 @@ .defects.f.msg delete 1.0 end raise .defects } - catch {exec /usr/bin/scsiinfo -d $flag $sdevice} results + catch {exec /sbin/scsiinfo -d $flag $sdevice} results .defects.f.msg insert end "$results" tkwait window .defects } @@ -117,14 +121,14 @@ frame .f_top set line {} -exec /usr/bin/scsiinfo -X -L $sdevice > /tmp/cachepage -if {[catch {set file [open /tmp/cachepage r]}] == 1} return; +exec /sbin/scsiinfo -X -L $sdevice > /var/run/cachepage +if {[catch {set file [open /var/run/cachepage r]}] == 1} return; gets $file line set pages_sup [lindex $line 0] set pages_notch [lindex $line 1] set curr_not [lindex $line 2] close $file -exec rm /tmp/cachepage +exec rm /var/run/cachepage button .f_top.info -text "Device Info" -command "exec /usr/lib/scsi/inquiry $sdevice" \ -activebackground green @@ -202,12 +206,12 @@ exec /usr/lib/scsi/notch $sdevice set line {} - exec /usr/bin/scsiinfo -X -L $sdevice > /tmp/cachepage - if {[catch {set file [open /tmp/cachepage r]}] == 1} return; + exec /sbin/scsiinfo -X -L $sdevice > /var/run/cachepage + if {[catch {set file [open /var/run/cachepage r]}] == 1} return; gets $file line set curr_not [lindex $line 2] close $file - exec rm /tmp/cachepage + exec rm /var/run/cachepage .notchinfo.notchnum configure -text $curr_not } --- a/scsiinfo/scsiinfo.c +++ b/scsiinfo/scsiinfo.c @@ -60,18 +60,26 @@ * 08/23/97 fix problems with defect lists * */ +#define USE_SGIO #include +#include #include #include #include +#include #include #include +#ifdef USE_SGIO +# include +int use_sgio = 1; +#endif -FILE *infile; +int infile; char *device_name; unsigned char buffer[64 * 1024 + 100]; unsigned char buffer1[10 * 1024 + 100]; +char verbose = 0; char cache = 0; char defect = 0; char geometry = 0; @@ -279,7 +287,7 @@ printf("%-35s%d\n", text, !((*pageaddr >> shift) & mask)); } -void intfield(char *pageaddr, int nbytes, char *text) +void intfield(unsigned char *pageaddr, int nbytes, char *text) { if (x_interface && replace) { check_parm_type(0); @@ -290,7 +298,7 @@ printf("%-35s%d\n", text, getnbyte(pageaddr, nbytes)); } -void hexfield(char *pageaddr, int nbytes, char *text) +void hexfield(unsigned char *pageaddr, int nbytes, char *text) { if (x_interface && replace) { check_parm_type(0); @@ -335,7 +343,7 @@ if (nbytes) { illegal: fputs("scsiinfo: incorrect number of bytes in @hexdatafield.\n", stderr); - exit(2); + exit(3); } } else if (x_interface) { putchar('@'); @@ -350,6 +358,46 @@ } } +int send_scsi_cmd(int fileno, int cmd_len, unsigned char* buffer) +{ + int status; +#ifdef USE_SGIO + if (use_sgio) { + sg_io_hdr_t sgh; + unsigned char sense_buffer[16]; + int dir = SG_DXFER_NONE; + int in_len = *((int*)buffer); + int out_len = *(((int*)buffer)+1); + if (in_len != 0) + dir = SG_DXFER_TO_DEV; + else if (out_len != 0) + dir = SG_DXFER_FROM_DEV; + memset(&sgh, 0, sizeof(sgh)); + sgh.interface_id = 'S'; + sgh.dxfer_direction = dir; + sgh.dxferp = buffer+(dir == SG_DXFER_TO_DEV ? cmd_len : 0)+8; + sgh.dxfer_len = dir == SG_DXFER_TO_DEV ? in_len : out_len; + sgh.cmd_len = cmd_len; + sgh.cmdp = buffer+8; + sgh.sbp = sense_buffer; + sgh.mx_sb_len = sizeof(sense_buffer); + sgh.timeout = 1000; /* 2s */ + status = ioctl(fileno, SG_IO, &sgh); + if (status >= 0) { + /* return a status similar to the one returned by legacy ioctl */ + status = sgh.driver_status << 24 | sgh.host_status << 16 | sgh.msg_status << 8 || sgh.masked_status; + } + if (status) { + /* scsi error: dump sense buffer into output area */ + memcpy(buffer+8, sense_buffer, sgh.sb_len_wr); + } + } + else +#endif + status = ioctl(fileno, 1 /* SCSI_IOCTL_SEND_COMMAND */, buffer); + return status; +} + int get_mode_page(int page, int page_code) { int status, quiet; @@ -363,7 +411,7 @@ *((int *) buffer) = 0; /* length of input data */ *(((int *) buffer) + 1) = 0xff; /* length of output buffer */ - cmd = (char *) (((int *) buffer) + 2); + cmd = (unsigned char *) (((int *) buffer) + 2); cmd[0] = MODE_SENSE; /* MODE SENSE (6) */ cmd[1] = 0x00; /* lun = 0, inhibitting BD makes this fail for me */ @@ -372,9 +420,14 @@ cmd[4] = 0xff; /* allocation length */ cmd[5] = 0x00; /* control */ - status = ioctl(fileno(infile), 1 /* SCSI_IOCTL_SEND_COMMAND */ , buffer); - if (status && (!quiet)) + status = send_scsi_cmd(infile, 6, buffer); + if (status && (!quiet)) { fprintf(stderr, "Unable to read %s Page %02xh\n", get_page_name(page), page); + if (verbose > 1) { + printf("sense buffer: "); + dump(buffer+8, 16); + } + } return status; } @@ -392,7 +445,7 @@ *((int *) buffer) = 0; /* length of input data */ *(((int *) buffer) + 1) = 0xffff; /* length of output buffer */ - cmd = (char *) (((int *) buffer) + 2); + cmd = (unsigned char *) (((int *) buffer) + 2); cmd[0] = MODE_SENSE_10; /* MODE SENSE (10) */ cmd[1] = 0x00; /* lun = 0, inhibitting BD makes this fail for me */ @@ -405,10 +458,15 @@ cmd[8] = 0xff; /* allocation length lo */ cmd[9] = 0x00; /* control */ - status = ioctl(fileno(infile), 1 /* SCSI_IOCTL_SEND_COMMAND */ , buffer); - if (status && (!quiet)) + status = send_scsi_cmd(infile, 10, buffer); + if (status && (!quiet)) { fprintf(stderr, "Unable to read %s Page %02xh with MODESENSE(10)\n", get_page_name(page), page); + if (verbose > 1) { + printf("sense buffer: "); + dump(buffer+8, 16); + } + } return status; } @@ -426,7 +484,7 @@ *((int *) buffer) = 0; /* length of input data */ *(((int *) buffer) + 1) = 0xff; /* length of output buffer */ - cmd = (char *) (((int *) buffer) + 2); + cmd = (unsigned char *) (((int *) buffer) + 2); cmd[0] = LOG_SENSE; /* LOG SENSE */ cmd[1] = 0x00 | (save_values & 1); /* lun = 0, Parameter pointer control 0 for full page */ @@ -440,7 +498,7 @@ cmd[9] = 0x00; /* control */ dump(buffer, 200); - status = ioctl(fileno(infile), 1 /* SCSI_IOCTL_SEND_COMMAND */ , buffer); + status = send_scsi_cmd(infile, 10, buffer); if (status && (!quiet)) fprintf(stderr, "Unable to read %sLog Page %02xh\n", get_log_name(page), page); dump(buffer, 400); @@ -452,7 +510,7 @@ in a prior read operation. This way we do not have to work out the format of the beast */ -int put_mode_page(int page, char *contents, int page_code) +int put_mode_page(int page, unsigned char *contents, int page_code) { int status; int pagelen, pagelen1; @@ -466,7 +524,7 @@ *((int *) buffer1) = pagelen1; /* length of input data */ *(((int *) buffer1) + 1) = pagelen1; /* length of output buffer */ - cmd = (char *) (((int *) buffer1) + 2); + cmd = (unsigned char *) (((int *) buffer1) + 2); cmd[0] = MODE_SELECT; cmd[1] = 0x10 | (page_code ? 1 : 0); @@ -482,7 +540,7 @@ cmd[6 + pagelen] &= 0x3f; /* Mask off this reserved field in page code */ /* dump (buffer1, 48); */ - status = ioctl(fileno(infile), 1 /* SCSI_IOCTL_SEND_COMMAND */ , buffer1); + status = send_scsi_cmd(infile, 6, buffer1); if (status) { fprintf(stderr, "Unable to store %s Page %02xh\n", get_page_name(page), page); @@ -500,7 +558,7 @@ unsigned char *pagestart; if (save_mode) - printf("/usr/bin/scsiinfo -gXR %s ", device_name); + printf("scsiinfo -gXR %s ", device_name); SETUP_MODE_PAGE(4, 9); @@ -532,7 +590,7 @@ unsigned char *pagestart; if (save_mode) - printf("/usr/bin/scsiinfo -DXR %s ", device_name); + printf("scsiinfo -DXR %s ", device_name); SETUP_MODE_PAGE(2, 7); @@ -562,7 +620,7 @@ unsigned char *pagestart; if (save_mode) - printf("/usr/bin/scsiinfo -CXR %s ", device_name); + printf("scsiinfo -CXR %s ", device_name); SETUP_MODE_PAGE(10, 9); @@ -594,7 +652,7 @@ unsigned char *pagestart; if (save_mode) - printf("/usr/bin/scsiinfo -eXR %s ", device_name); + printf("scsiinfo -eXR %s ", device_name); SETUP_MODE_PAGE(1, 14); if (!x_interface && !replace) { @@ -629,7 +687,7 @@ unsigned char *pagestart; if (save_mode) - printf("/usr/bin/scsiinfo -nXR %s ", device_name); + printf("scsiinfo -nXR %s ", device_name); SETUP_MODE_PAGE(0xc, 7); @@ -692,7 +750,7 @@ *((int *) buffer) = 0; /* length of input data */ *(((int *) buffer) + 1) = len; /* length of output buffer */ - cmd = (char *) (((int *) buffer) + 2); + cmd = (unsigned char *) (((int *) buffer) + 2); cmd[0] = 0x37; /* READ DEFECT DATA */ cmd[1] = 0x00; /* lun=0 */ @@ -705,7 +763,7 @@ cmd[8] = (len & 0xff); /* Alloc len */ cmd[9] = 0x00; /* control */ - i = ioctl(fileno(infile), 1 /* SCSI_IOCTL_SEND_COMMAND */ , buffer); + i = send_scsi_cmd(infile, 10, buffer); if ((i & 0xF000000) == 0x8000000) { /* sense is available: */ if (((buffer[8] & ~1) == 0x70) && ((buffer[10] & 0x0f) == 0x1)) @@ -714,6 +772,10 @@ if (i) { fprintf(stderr, "Unable to read %s defect data.\n", (table ? "grown" : "manufacturer")); + if (verbose > 1) { + printf("sense buffer: "); + dump(buffer+8, 16); + } status |= i; } else { len = (buffer[10] << 8) | buffer[11]; @@ -731,7 +793,7 @@ i = 0; if (len) { while (len) { - sprintf(buffer, "%u:%u:%d", getnbyte(df, 3), df[3], getnbyte(df + 4, 4)); + sprintf((char *) buffer, "%u:%u:%d", getnbyte(df, 3), df[3], getnbyte(df + 4, 4)); printf(" %15s", buffer); len -= 8; df += 8; @@ -770,7 +832,7 @@ unsigned char *pagestart; if (save_mode) - printf("/usr/bin/scsiinfo -cXR %s ", device_name); + printf("scsiinfo -cXR %s ", device_name); SETUP_MODE_PAGE(8, 9); @@ -801,7 +863,7 @@ unsigned char *pagestart; if (save_mode) - printf("/usr/bin/scsiinfo -fXR %s ", device_name); + printf("scsiinfo -fXR %s ", device_name); SETUP_MODE_PAGE(3, 13); @@ -837,7 +899,7 @@ unsigned char *pagestart; if (save_mode) - printf("/usr/bin/scsiinfo -VXR %s ", device_name); + printf("scsiinfo -VXR %s ", device_name); SETUP_MODE_PAGE(7, 7); @@ -877,7 +939,7 @@ char *name; if (save_mode) - printf("/usr/bin/scsiinfo -pXR %s ", device_name); + printf("scsiinfo -pXR %s ", device_name); SETUP_MODE_PAGE(9, 2); @@ -935,7 +997,7 @@ *((int *) buffer) = 0; /* length of input data */ *(((int *) buffer) + 1) = 1024; /* length of output buffer */ - cmd = (char *) (((int *) buffer) + 2); + cmd = (unsigned char *) (((int *) buffer) + 2); cmd[0] = 0x12; /* INQUIRY */ cmd[1] = 0x00; /* lun=0, evpd=0 */ @@ -944,9 +1006,9 @@ cmd[4] = 0xff; /* allocation length */ cmd[5] = 0x00; /* control */ - status = ioctl(fileno(infile), 1 /* SCSI_IOCTL_SEND_COMMAND */ , buffer); + status = send_scsi_cmd(infile, 6, buffer); if (status) - printf("ioctl(SCSI_IOCTL_SEND_COMMAND) status\t= %d\n", status); + printf("INQUIRY command status\t= %d\n", status); if (status) return status; @@ -1009,7 +1071,7 @@ *((int *) buffer) = 0; /* length of input data */ *(((int *) buffer) + 1) = 1024; /* length of output buffer */ - cmd = (char *) (((int *) buffer) + 2); + cmd = (unsigned char *) (((int *) buffer) + 2); cmd[0] = 0x12; /* INQUIRY */ cmd[1] = 0x01; /* lun=0, evpd=1 */ @@ -1018,9 +1080,9 @@ cmd[4] = 0xff; /* allocation length */ cmd[5] = 0x00; /* control */ - status = ioctl(fileno(infile), 1 /* SCSI_IOCTL_SEND_COMMAND */ , buffer); + status = send_scsi_cmd(infile, 6, buffer); if (status) - printf("ioctl(SCSI_IOCTL_SEND_COMMAND) status\t= %d\n", status); + printf("INQUIRY command status\t= %d\n", status); if (status) return status; @@ -1036,20 +1098,44 @@ } -char *devices[] = -{"/dev/sda", "/dev/sdb", "/dev/sdc", "/dev/sdd", "/dev/sde", "/dev/sdf", "/dev/sdg", - "/dev/sdh", "/dev/scd0", "/dev/scd1", "/dev/nst0", "/dev/nst1"}; /* Print out a list of the known devices on the system */ void show_devices() { int i; - FILE *test; - for (i = 0; i < sizeof(devices) / sizeof(char *); i++) { - test = fopen(devices[i], "r"); - if (!test) + int test; + char devname[16]; + char* sep = ""; + /* test for scsi disks */ + for (i = 0; i < 26*8; i++) { + char c1 = i < 26 ? 'a' + i : 'a' + (i/26-1); + char c2 = i < 26 ? '\0' : 'a' + (i%26); + snprintf(devname, sizeof(devname), "/dev/sd%c%c", c1, c2); + test = open(devname, O_NDELAY | O_RDONLY, 0); + if (test < 0) /* ENOENT? ENODEV? */ continue; - printf("%s ", devices[i]); - fclose(test); + printf("%s%s", sep, devname); + close(test); + sep = " "; + }; + /* test for scsi cdroms */ + for (i = 0; i < 26; i++) { + snprintf(devname, sizeof(devname), "/dev/scd%d", i); + test = open(devname, O_NDELAY | O_RDONLY, 0); + if (test < 0) /* ENOENT? ENODEV? */ + continue; + printf("%s%s", sep, devname); + close(test); + sep = " "; + }; + /* test for scsi tapes */ + for (i = 0; i < 26; i++) { + snprintf(devname, sizeof(devname), "/dev/nst%d", i); + test = open(devname, O_NDELAY | O_RDONLY, 0); + if (test < 0) /* ENOENT? ENODEV? */ + continue; + printf("%s%s", sep, devname); + close(test); + sep = " "; }; printf("\n"); } @@ -1064,8 +1150,8 @@ unsigned char *pagestart; if (save_mode) { - printf("set -- `/usr/bin/scsiinfo -nX %s`\n", device_name); - printf("/usr/bin/scsiinfo -nXR %s $1 $2 $3 %d $5 $6 $7\n", device_name, notch); + printf("set -- `scsiinfo -nX %s`\n", device_name); + printf("scsiinfo -nXR %s $1 $2 $3 %d $5 $6 $7\n", device_name, notch); } SETUP_MODE_PAGE(0xc, 0); putnbyte(pagestart + 6, notch, 2); @@ -1293,8 +1379,13 @@ if (argc < 2) usage("too few arguments"); - while ((c = getopt(argc, argv, "agdcfisDeCXmMSRvlnLpVF:")) != EOF) { + while ((c = getopt(argc, argv, "agdcfisDeCXmMSRvlnLpVIF:")) != EOF) { switch (c) { +#ifdef USE_SGIO + case 'I': + use_sgio = 0; + break; +#endif case 'F': if (!strcasecmp(optarg, "logical")) defectformat = 0x0; @@ -1378,7 +1469,8 @@ notch = 1; /* fall through */ case 'v': - fprintf(stderr, " Scsiinfo version 1.7(eowmob)\n"); + if (verbose++ == 0) + fprintf(stderr, " Scsiinfo version 1.7(eowmob)\n"); break; default: fprintf(stderr, "Unknown option '-%c' (ascii %02xh)\n", c, c); @@ -1434,15 +1526,15 @@ } if (optind >= argc) usage("no device name given"); - infile = fopen(device_name = argv[optind], "r"); - if (!infile) { - perror("scsiinfo(fopen)"); + infile = open(device_name = argv[optind], O_NDELAY | O_RDONLY, 0); + if (infile < 0) { + perror("scsiinfo(open)"); exit(1); } /* Save the current parameters in NOVRAM on the device */ if (saved && replace && !list_pages) { replace_parameters(); - fclose(infile); + close(infile); exit(0); }; --- a/scsiinfo/scsiformat.c +++ b/scsiinfo/scsiformat.c @@ -45,10 +45,22 @@ #include #include #include -#include -#include +#include +#include #include -#include + +struct partition { + unsigned char boot_ind; /* 0x80 - active */ + unsigned char head; /* starting head */ + unsigned char sector; /* starting sector */ + unsigned char cyl; /* starting cylinder */ + unsigned char sys_ind; /* What partition type */ + unsigned char end_head; /* end head */ + unsigned char end_sector; /* end sector */ + unsigned char end_cyl; /* end cylinder */ + unsigned int start_sect; /* starting sector counting from 0 */ + unsigned int nr_sects; /* nr of sectors in partition */ +} __attribute__((packed)); #define TEST_UNIT_READY (0x00) #define FORMAT_UNIT (0x04) @@ -67,7 +79,7 @@ pid_t child = -1; time_t start; -char tmpfname[] = "/tmp/scsiformat.XX:XX:XX:XX:XXXXXXXX"; +char tmpfname[] = "/var/run/scsiformat.XX:XX:XX:XX:XXXXXXXX"; char *devicename, *linebuf, *givendevice; long scsiunid[2]; @@ -97,7 +109,7 @@ unsigned par_defectlen = 0; unsigned par_interleave = 0; unsigned char par_initpattern[65536 + 5]; -unsigned long par_defects[65536 / sizeof(unsigned long) + 3]; +unsigned int par_defects[65536 / sizeof(unsigned long) + 3]; struct winsize wins; @@ -143,6 +155,48 @@ fprintf(stderr, ": %s\n", strerror(locerr)); } +int send_scsi_cmd(int fileno, int cmd_len, unsigned char* buffer) +{ + int status; +#ifdef SG_IO + if (use_sgio) { + sg_io_hdr_t sgh; + char sense_buffer[16]; + int dir = SG_DXFER_NONE; + int in_len = *((int*)buffer); + int out_len = *(((int*)buffer)+1); + if (in_len != 0) + dir = SG_DXFER_FROM_DEV; + else if (out_len != 0) + dir = SG_DXFER_TO_DEV; + memset(&sgh, 0, sizeof(sgh)); + sgh.interface = 'S'; + sgh.dxfer_direction = dir; + sgh.dxferp = buffer+(dir == SG_DXFER_TO_DEV ? cmd_len : 0)+8; + sgh.dxfer_len = dir == SG_DXFER_TO_DEV ? in_len : out_len; + sgh.cmd_len = cmd_len; + sgh.cmdp = buffer+8; + sgh.sbp = sense_buffer; + sgh.m_sb_len = sizeof(sense_buffer); + sgh.timeout = 2000; /* 2s */ + status = ioctl(fileno, SG_IO, &sgh); + if (status < 0) { + /* scsi error: dump sense buffer into output area */ + memcpy(buffer+8, sense_buffer, sgh.sb_len_wr); + /* return a status similar to the one returned by legacy ioctl */ + status = sgh.driver_status << 24 | sgh.host_status << 16 | sgh.msg_status << 8 || sgh.masked_status; + } + else { + status = 0; + } + } + else +#else + status = ioctl(fileno, 1 /* SCSI_IOCTL_SEND_COMMAND */, buffer); +#endif + return status; +} + /* return -1 for ready, -2 for no progress indication available) and progress indicator else. */ /* BUG/MISFEATURE: The linux device driver stores the sense data into another @@ -161,7 +215,7 @@ *((int *) buffer) = 6; /* length of input data */ *(((int *) buffer) + 1) = 18; /* length of output buffer */ - cmd = (char *) (((int *) buffer) + 2); + cmd = (unsigned char *) (((int *) buffer) + 2); cmd[0] = TEST_UNIT_READY; cmd[1] = 0x00; /* LUN / (reserved) */ @@ -174,7 +228,7 @@ printf("Sending TEST_UNIT_READY command:\n"); dump(stdout, ((int *) buffer) + 2, *((int *) buffer)); } - status = ioctl(fd, 1 /* SCSI_IOCTL_SEND_COMMAND */ , buffer); + status = send_scsi_cmd(fd, 6, buffer); if ((status == EAGAIN) || (status == EBUSY)) return -2; if (status < 0) { @@ -424,7 +478,7 @@ *(((int *) buffer) + 1) = 255; /* length of output buffer */ - cmd = (char *) (((int *) buffer) + 2); + cmd = (unsigned char *) (((int *) buffer) + 2); cmd[0] = FORMAT_UNIT; cmd[1] = 0x00; /* LUN / FmtData / CmpList / Defectformat */ @@ -445,25 +499,25 @@ if (par_erasedefs) cmd[1] |= 0x08; if (par_initpattern[0] | par_initpattern[1]) { - data[0] |= 0x08; + data[1] |= 0x08; par_fov = 1; memcpy(end, par_initpattern, par_patternlen); end += par_patternlen; } if (par_fov) { hasdata = 1; - data[0] |= 0x80; + data[1] |= 0x80; if (par_disprim) - data[0] |= 0x40; + data[1] |= 0x40; if (par_discert) - data[0] |= 0x20; + data[1] |= 0x20; if (par_stop) - data[0] |= 0x10; + data[1] |= 0x10; if (par_dissav) - data[0] |= 0x04; + data[1] |= 0x04; } if (!par_blockmode) { - data[0] |= 2; + data[1] |= 2; hasdata = 1; } if (par_defectlen) { @@ -490,7 +544,7 @@ exit(2); } #ifndef DONT_FORMAT - status = ioctl(fd, 1 /* SCSI_IOCTL_SEND_COMMAND */ , buffer); + status = send_scsi_cmd(fd, 6, buffer); if (status < 0) { argperr("scsiformat (sending FORMAT_UNIT to %s)", devicename); exit(1); @@ -527,7 +581,7 @@ " will need about n seconds and provides some progress indication\n" " according to that. -b0 does not print any process indication.\n" " -T just test for a running format command and output statistics.\n" - " A file /tmp/scsiformat.* is used to hold the starting time of\n" + " A file /var/run/scsiformat.* is used to hold the starting time of\n" " the format operation. If formatting completes, this file is\n" " removed by scsiformat. The exit state is true as long as\n" " the format operation is still in progress.\n" @@ -736,7 +790,7 @@ if (!par_deflistform) { fprintf(fh, "\nUser supplied defect logical blocks:\n"); for (i = off = 0; off < par_defectlen; i++, off += 4) { - fprintf(fh, " %9lu", ntohl(par_defects[i])); + fprintf(fh, " %9u", ntohl(par_defects[i])); if ((i & 7) == 7) { fprintf(fh, "\n"); flag = 1; @@ -747,8 +801,8 @@ fprintf(fh, "\nUser supplied defects in Cylinder:Head:%s format:\n", par_deflistform == 5 ? "PhysicalSector" : "BytesFromIndex"); for (i = off = 0; off < par_defectlen; i += 2, off += 8) { - sprintf(buffer, " %lu:%lu:%ld", ntohl(par_defects[i]) >> 8, - ntohl(par_defects[i]) & 255, (long) ntohl(par_defects[i + 1])); + sprintf(buffer, " %u:%u:%d", ntohl(par_defects[i]) >> 8, + ntohl(par_defects[i]) & 255, (int) ntohl(par_defects[i + 1])); fprintf(fh, "%20s", buffer); if ((i & 3) == 3) { fprintf(fh, "\n"); @@ -905,7 +959,11 @@ unsigned char sig2catch[] = {SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGPIPE, SIGALRM, SIGTERM, SIGUSR1, SIGUSR2, SIGTRAP, - SIGIOT, SIGBUS, SIGSTKFLT, SIGIO, SIGXCPU, SIGXFSZ, SIGVTALRM, + SIGIOT, SIGBUS, +#ifdef SIGSTKFLT + SIGSTKFLT, +#endif + SIGIO, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, SIGPWR}; siga.sa_handler = term_handler; @@ -1102,7 +1160,7 @@ void parse_pattern() { - unsigned char *ptr = optarg; + char *ptr = optarg; int len; len = strlen(ptr); @@ -1162,7 +1220,7 @@ sprintf(partdev + o, "%d", i); if (!swapoff(partdev)) { fprintf(stderr, "Warning, turned swap off on %s!\n", partdev); - } else if ((errno != ENOENT) && (errno != EINVAL)) { + } else if ((errno != ENOENT) && (errno != EINVAL) && (errno != ENXIO)) { fprintf(stderr, "Warning, unable to turn swap off on %s!\n", partdev); flag = 1; } @@ -1172,7 +1230,7 @@ for (partdev[o] = 'a'; partdev[o] <= 'z'; partdev[o]++) { if (!swapoff(partdev)) { fprintf(stderr, "Warning, turned swap off on %s!\n", partdev); - } else if ((errno != ENOENT) && (errno != EINVAL)) { + } else if ((errno != ENOENT) && (errno != EINVAL) && (errno != ENXIO)) { fprintf(stderr, "Warning, unable to turn swap off on %s!\n", partdev); flag = 1; } --- a/scsiinfo/tk_scsiformat +++ b/scsiinfo/tk_scsiformat @@ -1,3 +1,7 @@ +#!/bin/sh +# the next lines restarts using wish or abort with a message \ +type wish > /dev/null 2>&1 && exec wish -f "$0" "$@" || \ +echo "no /usr/bin/wish found: please install the tk package." && exit 1 #!/usr/bin/wish -f # Based in parts on scsi-config by: # Copyright 1993 Yggdrasil Computing, Incorporated @@ -108,15 +112,15 @@ if { [string compare $par_partmin ""] == 0} then { set par_partmin 0 } - .f_def.part.menu entryconfigure 8 -label "Maximal Partion Size ${par_partmin}MB" + .f_def.part.menu entryconfigure 9 -label "Maximal Partition Size ${par_partmin}MB" } proc change_geom {geomdetect heads sectors} { if { [string compare $geomdetect "-G"] == 0} then { - .f_def.part.menu entryconfigure 7 -label \ + .f_def.part.menu entryconfigure 8 -label \ "Disk Geometry is ${heads} Heads and ${sectors} Sectors" } else { - .f_def.part.menu entryconfigure 7 -label "Autodetect Disk Geometry" + .f_def.part.menu entryconfigure 8 -label "Autodetect Disk Geometry" } } @@ -128,7 +132,7 @@ } else { set label "Other ($par_mkfs)" } - .f_def.part.menu.mkfs entryconfigure [expr [llength $par_mkfscmds] + 1] -label "$label" + .f_def.part.menu.mkfs entryconfigure [expr [llength $par_mkfscmds] + 2] -label "$label" } proc bind_eedit {w} { @@ -686,9 +690,9 @@ frame .mkfs.f_inter scrollbar .mkfs.f_inter.s -relief sunken -orient horiz -command \ - ".mkfs.f_inter.t view" + ".mkfs.f_inter.t xview" entry .mkfs.f_inter.t -background white -relief sunken -borderwidth 2 \ - -exportselection 1 -scroll ".mkfs.f_inter.s set" + -exportselection 1 -xscrollcommand ".mkfs.f_inter.s set" .mkfs.f_inter.t insert 0 $par_mkfs bind_eedit .mkfs.f_inter.t @@ -802,7 +806,7 @@ pack .conf.f_bot -side top -padx 15 pack .conf.dismiss -side top -pady 10 - set format_cmd "/usr/bin/scsiformat $par_erase -i$par_inter" + set format_cmd "/usr/sbin/scsiformat $par_erase -i$par_inter" regsub -all "\x0a" [string trim $par_defects] " " tmpstr regsub -all " +" $tmpstr "," tmpstr @@ -874,15 +878,15 @@ set security "-F'Ene Mene Meck, und Du bist weg!'" append fcmd " $security -t0 -X $sdevice" - if { [catch {exec sh -c "$fcmd" >& /tmp/scsiformat.[pid] } err] != 0 } then { - set fd [open /tmp/scsiformat.[pid] r] + if { [catch {exec sh -c "$fcmd" >& /var/run/scsiformat.[pid] } err] != 0 } then { + set fd [open /var/run/scsiformat.[pid] r] set err "$err\x0a[read $fd]" close $fd - exec rm /tmp/scsiformat.[pid] + exec rm /var/run/scsiformat.[pid] show_err scsiformat $err return; } - exec rm /tmp/scsiformat.[pid] + exec rm /var/run/scsiformat.[pid] set format_initiator 1 show_busy } @@ -928,7 +932,7 @@ proc query_prog {} { global sdevice errorCode wasbusy format_initiator par_mkfs - set check_cmd "/usr/bin/scsiformat -T -t1 -X $sdevice" + set check_cmd "/usr/sbin/scsiformat -T -t1 -X $sdevice" if { [winfo exists .showprog] != 1 } { return; @@ -1075,7 +1079,7 @@ pack .select.h.l .select.h.m -side left -padx 10 pack .select.h -pady 10 pack .select - set line [exec /usr/bin/scsiinfo -l] + set line [exec /sbin/scsiinfo -l] set n 0 foreach x $line { if {[string first "/dev/sd" "$x"] != 0} continue; --- a/scsiinfo/man8/scsiinfo.8 +++ b/scsiinfo/man8/scsiinfo.8 @@ -153,13 +153,16 @@ .B -m displays modifiable fields instead of current values (All bits set in modifiable fields). -.SS Miscanellous +.SS Miscellaneous .TP .B -v Show .B scsiinfo version. .TP +.B -vv +Dump sense buffer in case of error. +.TP .B -a All of the above (expect listing defects). .TP --- a/scsiinfo/man8/scsiformat.8 +++ b/scsiinfo/man8/scsiformat.8 @@ -223,7 +223,7 @@ made. Defaults to .BR 99999 . -.SS e) Miscanellous +.SS e) Miscellaneous .TP .B -H print some command line help to stdout. @@ -236,7 +236,7 @@ forced operation, do not ask prior to format. .I arg must be -.B Ene Mene Meck, und Du bist weg! +.B 'Ene\ Mene\ Meck,\ und\ Du\ bist\ weg!' with proper spaces and capitalisation. (this is a German child rhyme kissing someone goodbye...) @@ -262,7 +262,7 @@ or one of these flags some factory default is used. Specifying .B -o -explictly will allow you to not use any of these options which might not be +explicitly will allow you to not use any of these options which might not be the default chosen by the target device otherwise. .SH RETURN CODES @@ -279,8 +279,8 @@ .B -T option. However, they are removed after 48 hours. -I were unable to get hold of a disk supporting querying the progress status (and which I could -stand to loose all data on). Therefore I commented out the support for this from the +I was unable to get hold of a disk supporting querying the progress status (and which I could +stand to lose all data on). Therefore I commented out the support for this from the source code using a .BR BLOCKING_ONLY #define. You are welcome to try and make this work. --- a/scsiinfo/tk/generic +++ b/scsiinfo/tk/generic @@ -48,11 +48,11 @@ global text_list global switch set line {} - exec /usr/bin/scsiinfo -X $switch $option $device > /tmp/cachepage 2> /dev/null - if {[catch {set file [open /tmp/cachepage r]}] == 1} return; + exec /sbin/scsiinfo -X $switch $option $device > /var/run/cachepage 2> /dev/null + if {[catch {set file [open /var/run/cachepage r]}] == 1} return; gets $file line close $file - exec rm /tmp/cachepage + exec rm /var/run/cachepage set first [lindex $line 0] set second [lindex $line 1] set lineno 0 @@ -73,11 +73,11 @@ global text_list global switch set line {} - exec /usr/bin/scsiinfo -X -m $switch $device > /tmp/cachepage - if {[catch {set file [open /tmp/cachepage r]}] == 1} return; + exec /sbin/scsiinfo -X -m $switch $device > /var/run/cachepage + if {[catch {set file [open /var/run/cachepage r]}] == 1} return; gets $file line close $file - exec rm /tmp/cachepage + exec rm /var/run/cachepage set lineno 0 foreach x $button_list { if { [ string compare [lindex $line $lineno] "0" ] == 0} then { .$x configure -state disabled } @@ -109,10 +109,10 @@ set r3 [concat $r3 [.$x.text get 1.0 end]] set lineno [expr $lineno+1] } - set file [open /tmp/wrscsi w] - puts $file "/usr/bin/scsiinfo $r3" + set file [open /var/run/wrscsi w] + puts $file "/sbin/scsiinfo $r3" close $file - exec sh < /tmp/wrscsi - exec rm /tmp/wrscsi + exec sh < /var/run/wrscsi + exec rm /var/run/wrscsi } --- a/scsiinfo/tk/peripheral +++ b/scsiinfo/tk/peripheral @@ -29,12 +29,12 @@ global text_list global switch set line {} - exec /usr/bin/scsiinfo -X $switch $option $device > /tmp/cachepage 2> /dev/null - if {[catch {set file [open /tmp/cachepage r]}] == 1} return; + exec /sbin/scsiinfo -X $switch $option $device > /var/run/cachepage 2> /dev/null + if {[catch {set file [open /var/run/cachepage r]}] == 1} return; gets $file line gets $file asciidesc close $file - exec rm /tmp/cachepage + exec rm /var/run/cachepage .ident.text delete 1.0 end .ident.text insert end [lindex $line 0] @@ -51,11 +51,11 @@ global text_list global switch set line {} - exec /usr/bin/scsiinfo -X -m $switch $device > /tmp/cachepage - if {[catch {set file [open /tmp/cachepage r]}] == 1} return; + exec /sbin/scsiinfo -X -m $switch $device > /var/run/cachepage + if {[catch {set file [open /var/run/cachepage r]}] == 1} return; gets $file line close $file - exec rm /tmp/cachepage + exec rm /var/run/cachepage if { [ string compare [lindex $line 0] "0" ] == 0} \ then { .ident.text configure -state disabled } \ @@ -82,11 +82,11 @@ set r3 [concat $r3 @[.vendor.text get 1.0 end]] - set file [open /tmp/wrscsi w] - puts $file "/usr/bin/scsiinfo $r3" + set file [open /var/run/wrscsi w] + puts $file "/sbin/scsiinfo $r3" close $file - exec sh < /tmp/wrscsi - exec rm /tmp/wrscsi + exec sh < /var/run/wrscsi + exec rm /var/run/wrscsi } --- a/scsiinfo/tk/save-file +++ b/scsiinfo/tk/save-file @@ -23,7 +23,7 @@ set base [exec basename $sdevice] .win.fname.text delete 1.0 end -.win.fname.text insert end "/tmp/scsi-config.$base" +.win.fname.text insert end "/var/run/scsi-config.$base" frame .win.f radiobutton .win.cur -text "Current values" -width 20 -variable flag -value "-LXR" -anchor w @@ -36,7 +36,7 @@ -activebackground red -activeforeground white button .win.f.continue -width 10 -text "Save" \ -activebackground green \ - -command {global fname; set fname [.win.fname.text get 1.0 end]; destroy .win} + -command {global fname; set fname [.win.fname.text get 1.0 "end -1 chars"]; destroy .win} pack .win.f.continue .win.f.quit -side left -padx 30 -ipadx 2 -ipady 2 pack .win.f -pady 10 pack .win --- a/scsiinfo/tk/inquiry +++ b/scsiinfo/tk/inquiry @@ -154,8 +154,8 @@ global text_list global switch set line {} - exec /usr/bin/scsiinfo -X $switch $option $device > /tmp/cachepage - if {[catch {set file [open /tmp/cachepage r]}] == 1} return; + exec /sbin/scsiinfo -X $switch $option $device > /var/run/cachepage + if {[catch {set file [open /var/run/cachepage r]}] == 1} return; gets $file line set first [lindex $line 0] set second [lindex $line 1] @@ -185,7 +185,7 @@ .revision.text insert end $line .revision.text configure -state disabled close $file - exec rm /tmp/cachepage + exec rm /var/run/cachepage } read_page $argv "-X" --- a/scsiinfo/tk/save-changes +++ b/scsiinfo/tk/save-changes @@ -21,6 +21,6 @@ # This should do it. Do not come and complain to me if this # does not work -exec /usr/bin/scsiinfo -R -S -X $argv +exec /sbin/scsiinfo -R -S -X $argv exit debian/patches/rescan-scsi-bus.patch0000664000000000000000000000417712233502660014651 0ustar Description: added manpage. Forwarded: no Author: Eric Delaunay --- a/rescan-scsi-bus/rescan-scsi-bus.8 +++ b/rescan-scsi-bus/rescan-scsi-bus.8 @@ -0,0 +1,85 @@ +.\" -*- nroff -*- +.TH RESCAN\-SCSI\-BUS.SH 8 "March 1998" +.SH NAME +rescan-scsi-bus.sh \- rescan the SCSI bus. +.SH SYNOPSIS +.B rescan-scsi-bus.sh +[ +.B \-l +] +[ +.B \-w +] +[ +.B \-c +] +[ +.B \-r +] +[ +.B host... +] +.SH DESCRIPTION +.B rescan-scsi-bus.sh +is a program that is used to rescan the SCSI bus using the SCSI +add-single-device feature of the Linux SCSI layer. +.SH OPTIONS +.TP +\fB\-l\fR +Activates scanning for LUNs 0 .. 7 (default: 0). +.TP +\fB\-L\fR \fINUM\fR +Activates scanning for LUNs 0 .. LUN (default: 0). +.TP +\fB\-\-luns\fR=\fILIST\fR +Scan only LUNs in \fILIST\fR. +.TP +\fB\-w\fR +Enables scanning for device IDs 0 .. 15 (default: 0 .. 7). +.TP +\fB\-\-ids\fR=\fILIST\fR +Scan only device IDs in \fILIST\fR. +.TP +\fB\-i\fR, \fB--issue-lip\fR +Issue a FibreChannel LIP reset (default: disabled). +.TP +\fB\-r\fR, \fB--remove\fR +Enables removing of devices (default: disabled). +.TP +\fB--forceremove\fR +Remove and readd every device (dangerous). +.TP +\fB\-c\fR +Enables scanning of channels 0 1 (default: 0). +.TP +\fB\-\-channels\fR=\fILIST\fR +Scan only channels in \fILIST\fR. +.TP +\fBhost\fR, \fB--hosts\fR=\fILIST\fR +If host adapters are given, only these are scanned (default: all). +.TP +\fB--nooptscan\fR +Don't stop looking for LUNs if 0 is not found. +.TP +\fB--color\fR +Use coloured prefixes OLD/NEW/DEL. +.P +\fILIST\fR is a comma separated list of single values and ranges (no spaces +allowed), e.g. 0,2-3,8,10-15. +.SH AUTHOR +.B rescan-scsi-bus.sh +was written by Kurt Garloff . +.SH COPYRIGHT +This program is free software. You can use it under the terms of the +.B GNU GPL +(General Public License) Version 2 (or any later version, at your option). +Note, that the GNU GPL implies, that there is +.B NO WARRANTY +at all. +Full text of the GPL can be found in /usr/share/common-licenses/GPL file. +.SH AVAILABILITY +.B rescan-scsi-bus.sh +is available from +.nf +.B http://www.garloff.de/kurt/linux/scsidev/ +.fi debian/patches/series0000664000000000000000000000016312233502660012033 0ustar scsiinfo.patch sraw.patch rescan-scsi-bus.patch scsidev.patch 01_ubuntu-toolchain.diff rescan-scsi-bus_sleep.patch debian/patches/01_ubuntu-toolchain.diff0000664000000000000000000000042511575477011015262 0ustar --- a/scsidev/scsidev.c +++ b/scsidev/scsidev.c @@ -747,7 +747,7 @@ return; if (status) { - int fd = open (shadow, O_RDWR | O_CREAT | O_EXCL); + int fd = open (shadow, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); close (fd); } apply_perm (shadow, stbuf, 0); debian/patches/scsidev.patch0000664000000000000000000001046512233502660013305 0ustar Description: Select SG_IO or SCSI_IOCTL_SEND_COMMAND at runtime instead of compile time (allow to deal with sg devices as well as sd/sr/...). Forwarded: no Author: Eric Delaunay --- a/scsidev/scsidev.8 +++ b/scsidev/scsidev.8 @@ -61,7 +61,7 @@ is a utility that is used to guarantee that the same device node can be used for the same scsi device, no matter what other scsi devices are added or removed from the scsi chain. The need for this tool arose because device -numbers are assigned dynamicly at boot time, and if a new disk were added +numbers are assigned dynamically at boot time, and if a new disk were added to the system (or if some disk didn't spin up), then fixed device nodes would cause the wrong filesystems to be mounted, checked, etc. This can also result in security holes, as some device nodes may have permissions that allow @@ -112,7 +112,8 @@ an Adaptec 1542. The "-334" is a means of identifying which 1542 the device is attached to (since linux supports more than one 1542 in the system at the same time) and (in this case) corresponds to the IO -Port number (hex) of the controller. The "c0" represents the channel +Port number (hex) of the controller (this is the host adapter id number). +The "c0" represents the channel number (since some host adapters can drive multiple scsi busses). The "i0l0" indicates that this device is scsi ID 0, with lun 0. Finally the "p1" indicated partition number 1. @@ -183,7 +184,7 @@ Instructs .B scsidev to use devfs like names, i.e. using the cbtu (controller, bus, target -unit) chraracters instead of hcil (host, channel, scsi Id, scsi Lun) to +unit) characters instead of hcil (host, channel, scsi Id, scsi Lun) to build the device name. .TP .I \-o @@ -280,7 +281,8 @@ the alias will match all partitions on the disk. .TP .I hostid= -Specifies the host adapter id number. +Specifies the host adapter id number (0x334 part of sdh4-334c0i0l0p1 for +example). .TP .I hostnum= Specifies the unique number that each host adpater driver returns. @@ -320,9 +322,8 @@ (General Public License) Version 2 (or any later version, at your option). Note, that the GNU GPL implies, that there is .B NO WARRANTY -at all. See file -.B COPYING -for details. +at all. +Full text of the GPL can be found in /usr/share/common-licenses/GPL file. .SH AVAILABILITY .B scsidev is available from --- a/scsidev/scsidev.c +++ b/scsidev/scsidev.c @@ -1792,7 +1792,7 @@ unsigned int find_ioport (const char* nm) { - unsigned char lnbuf[128]; + char lnbuf[128]; char nm2[64]; char *nmptr; char * buf; FILE * iop = fopen ("/proc/ioports", "r"); @@ -2945,7 +2945,7 @@ } -char* getstr (char* page, int start, int stop) +char* getstr (unsigned char* page, int start, int stop) { int ln; char* str; @@ -3060,7 +3060,7 @@ return no_wwid; } -#ifndef SG_IO +//#ifndef SG_IO void my_memmove(unsigned char* dst, unsigned char* src, unsigned int ln) { if (src > dst) { @@ -3072,7 +3072,7 @@ *(--dst) = *(--src); } } -#endif +//#endif int scsi_cmd(int file, int rlen, unsigned char* cmd, int cmdlen, @@ -3098,21 +3098,27 @@ memset(buf, 0, buflen); ret = ioctl(file, SG_IO, &sghdr); + if (ret >= 0) { + if (verbose >= 2) + printf("SG_IO %02x %02x %02x: ret=%i, status=%i (host %i, drv %i), read=%i/%i\n", + cmd[0], cmd[1], cmd[2], + ret, sghdr.status, sghdr.host_status, sghdr.driver_status, + rlen-sghdr.resid, rlen); + return ret + sghdr.status; + } if (verbose >= 2) - printf("SG_IO %02x %02x %02x: ret=%i, status=%i (host %i, drv %i), read=%i/%i\n", - cmd[0], cmd[1], cmd[2], - ret, sghdr.status, sghdr.host_status, sghdr.driver_status, - rlen-sghdr.resid, rlen); - return ret + sghdr.status; -#else + printf("SG_IO error: %i, fallback to old SCSI_IOCTL_SEND_COMMAND\n", errno); +#endif memset(buf, 0, buflen); *( (int *) buf) = 0; /* Length of input data */ - *( ((int *) buf+1) ) = rlen; /* Length of output data */ + *( ((int *) buf+1) ) = rlen-8; /* Length of output data */ memcpy(buf+8, cmd, cmdlen); ret = ioctl(file, SCSI_IOCTL_SEND_COMMAND, buf); + if (ret < 0 && verbose >= 2) + printf("SCSI_IOCTL_SEND_COMMAND %02x %02x %02x: ret=%i, errno=%i\n", + cmd[0], cmd[1], cmd[2], ret, errno); my_memmove(buf, buf+8, buflen-8); return ret; -#endif } #define INQBUFSZ 512 debian/patches/rescan-scsi-bus_sleep.patch0000664000000000000000000000156012233502660016032 0ustar Description: s/usleep/sleep/g there is no usleep in Debian Forwarded: no Author: Daniel T Chen Bug-Debian: http://bugs.debian.org/624441 --- a/rescan-scsi-bus/rescan-scsi-bus.sh +++ b/rescan-scsi-bus/rescan-scsi-bus.sh @@ -229,7 +229,7 @@ fi while test $RC = 2 -o $RC = 6 && test $ctr -le 8; do if test $RC = 2 -a "$RMB" != "1"; then echo -n "."; let $LN+=1; sleep 1 - else usleep 20000; fi + else sleep 0.02; fi let ctr+=1 sg_turs /dev/$SGDEV >/dev/null 2>&1 RC=$? @@ -352,7 +352,7 @@ /sbin/udevadm settle white_out else - usleep 20000 + sleep 0.02 fi } @@ -388,7 +388,7 @@ fi # FIXME: Can we skip udevadm settle for removal? #udevadm_settle - usleep 20000 + sleep 0.02 else echo "scsi remove-single-device $devnr" > /proc/scsi/scsi if test $RC -eq 1 -o $lun -eq 0 ; then debian/rules0000775000000000000000000000666212233502660010261 0ustar #!/usr/bin/make -f # Derived from debhelper/dh_make example, and Cristoph Lameter's file. -joy #export DH_VERBOSE=1 CFLAGS = -g -O2 -Wall -fsigned-char #architecture := $(shell dpkg-architecture -qDEB_HOST_ARCH) p = scsitools gui = scsitools-gui include /usr/share/quilt/quilt.make %: dh $@ --with quilt getsrcfromsvn: # get sources from Alioth svn export svn+ssh://delaunay@svn.debian.org/svn/collab-maint/deb-maint/scsitools/branches/upstream/current/ . build: build-stamp build-stamp: $(QUILT_STAMPFN) dh_testdir cd scsiinfo && $(MAKE) KERNEL_INCLUDES="-fsigned-char" LDFLAGS= cd scsidev && CFLAGS="$(CFLAGS)" ./configure --prefix=/usr \ --mandir='${prefix}'/share/man && $(MAKE) cd sraw && gcc $(CFLAGS) -o sraw srawread.c gcc $(CFLAGS) -o scsi-spin debian/scsi-spin.c touch build-stamp clean: unpatch dh_testdir dh_testroot for i in scsiinfo scsidev ; do $(MAKE) -C $$i clean || true ; done dh_clean build-stamp scsi-spin scsidev/Makefile sraw/sraw install: build-stamp dh_testdir dh_testroot dh_prep dh_installdirs sbin lib usr/sbin usr/lib/scsitools usr/lib/scsi usr/share/doc/scsitools etc/init.d usr/share/lintian/overrides install -m 755 -p debian/scsitools-pre.sh debian/$(p)/etc/init.d/ install -m 755 -p debian/scsitools.sh debian/$(p)/etc/init.d/ cd scsiinfo && $(MAKE) install DESTDIR=../debian/$(p) install -m 755 scsidev/scsidev debian/$(p)/sbin #install -m 755 scsidev/scsidevfs.so debian/$(p)/lib #install -m 644 scsidev/devfsd.conf debian/$(p)/etc/devfs/conf.d/scsitools install -m 755 sraw/sraw debian/$(p)/usr/sbin install -m 755 scsi-spin debian/$(p)/sbin install -m 755 rescan-scsi-bus/rescan-scsi-bus.sh debian/$(p)/sbin/rescan-scsi-bus install -m 644 debian/lintian-overrides debian/$(p)/usr/share/lintian/overrides/scsitools # Documentation cp -a scsiinfo/0-TODO debian/$(p)/usr/share/doc/scsitools/TODO.scsiinfo cp -a scsiinfo/0-CHANGES debian/$(p)/usr/share/doc/scsitools/CHANGES.scsiinfo cp -a scsiinfo/0-README.first debian/$(p)/usr/share/doc/scsitools/README.scsiinfo cp -a scsidev/README debian/$(p)/usr/share/doc/scsitools/README.scsidev awk '/#include/ {exit};{print}' scsidev/scsidev.c > debian/$(p)/usr/share/doc/scsitools/CHANGES.scsidev ln -s CHANGES.scsidev debian/$(p)/usr/share/doc/scsitools/changelog cp -a sraw/README debian/$(p)/usr/share/doc/scsitools/README.sraw cp -a sraw/kpatch debian/$(p)/usr/share/doc/scsitools/kpatch.sraw cp -a debian/README.scsi-spin debian/$(p)/usr/share/doc/scsitools/README.scsi-spin cp -a debian/kernel-source-2.2.14.espfix debian/$(p)/usr/share/doc/scsitools/ # gui mkdir -p debian/$(gui)/usr/sbin mv debian/$(p)/usr/sbin/tk* debian/${gui}/usr/sbin mkdir -p debian/${gui}/usr/share/man/man8 cp scsiinfo/man8/tk_scsiformat.8 debian/${gui}/usr/share/man/man8 binary-indep: # There are no architecture-independent files to be uploaded # generated by this package. If there were any they would be # made here. binary-arch: build install dh_testdir dh_testroot dh_installdebconf dh_installdocs scsidev/scsi.alias dh_installman scsiinfo/man8/scsiinfo.8 scsiinfo/man8/scsiformat.8 \ scsiinfo/man8/scsi-config.8 \ scsidev/scsidev.8 \ rescan-scsi-bus/rescan-scsi-bus.8 \ sraw/sraw.8 debian/scsi-spin.8 # dh_installchangelogs #debian/upstream.changelog dh_strip dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary debian/README.scsi-spin0000664000000000000000000000302012233502660011751 0ustar To: submit@bugs.debian.org Subject: hwtools: scsi-spin -- an additional program for hwtools... From: Rob Browning Date: 04 Apr 1998 17:15:14 -0600 Package: hwtools Version: 0.3-4 Severity: wishlist Here's a small program I wrote called scsi-spin that lets you spin up and down scsi drives. I thought you might consider it for inclusion in the debian hwtools package, and perhaps from there into the upstream source somewhere. Thanks... This command is particularly useful if you've got noisy (or hot) drives in a machine that you rarely need to access. This is *not* the same as the kernel patch that's floating around that will automatically spin down the drive after some time. scsi-spin is completely manual, and spinning down a drive that's in use, especially the one containing the scsi-spin binary, it probably a *really* bad idea. You can build it with GNU make, and this command: make CC=g++ CFLAGS="-g -Wall -O2 -I/usr/src/linux/include" scsi-spin It doesn't really need g++, but I just wanted the extra type checking... -- Rob Browning PGP fingerprint = E8 0E 0D 04 F5 21 A0 94 53 2B 97 F5 D6 4E 39 30 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Date: Thu, 6 Sep 2001 23:46:56 +0200 Many enhancements for scsi-spin were written by Eric Delaunay . See man page for more informations. -- Eric Delaunay | Le travail est trop sérieux pour le confier delaunay@debian.org | à ceux qui veulent se tuer avec. Jissey. debian/README.Debian0000664000000000000000000000614412233502660011235 0ustar SCSI Tools for Debian notes --------------------------- scsiinfo: --------- Comes both with text interface and advanced X interface. Textmode usage with "scsiinfo". X-Startup with "scsi-config", but you must have wish installed to make it work. -- Christoph Lameter scsitools is a fork of hwtools previously maintained by Christoph Lameter (in 1996-1997) & Josip Rodin and Robert Woodcock acting on behalf of the Debian QA Team (in 1999). It was needed to open the SCSI tools provided by hwtools to other Debian architectures than i386 (in effect, hwtools is a collection of tools mainly designed for i386). scsidev & /dev/scsi: -------------------- /dev/scsi directory is now supported on 2.2 kernels through a set of init scripts. Even the root partition could use /dev/scsi notation but the kernel should support ramdisk compiled in in this case. Populating /dev/scsi is done in 2 steps: 1. in S09scsitools-pre.sh, before remounting / rw, a ramdisk is set up, mounted on /dev/scsi and filled in according to /etc/scsi.alias. This way, further references to /dev/scsi could be made, even for root and swap partitions. 2. in S20scsitools.sh, the ramdisk is freed and the real /dev/scsi refilled accordingly. If you switch on a SCSI device after the boot up sequence, you can run /etc/init.d/scsitools.sh restart to rescan the SCSI chain. It uses the rescan-scsi-bus script which is based on add-single-device feature of the Linux SCSI driver. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * CAUTION: This is not for hotplugging your peripherals. As SCSI was not designed for this you could damage your hardware! However perhaps it is legal to switch on an already connected device. It is perhaps not guaranteed this device doesn't corrupt an ongoing data transfer. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Furthermore, this feature does not work very well with all SCSI host adapters. Some Linux SCSI drivers do not acknowledge the removal of a peripheral when using the remove-single-device feature. In such kind of driver, the low level directly maintains a cache of available peripherals but there is no communication with the mid level when removing a peripheral, so the low level still think the device is alive and, at the time rescan-scsi-bus check for its removal, the kernel is displaying indefinitely a message like this one: esp0: Warning, live target 4 not responding to selection. This bug was discovered during the test of scsitools in the ESP100 driver (sparc) on 2.2 kernels. I wrote a fix for it and reported it upstream (to the linux-sparc mailing list). It is provided here in kernel-source-2.2.14.espfix file. The way it works is generic by adding a revoke function call to the mid level driver to tell the low level that the peripheral was removed, but this revoke function have to be written for all problematic low level drivers. Note that this bug could also exist for NCR5380 and NCR53C9x drivers at least, since they are based on the same design than the Sparc ESP one. -- Eric Delaunay debian/control0000664000000000000000000000353612252530700010576 0ustar Source: scsitools Section: utils Priority: optional Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Eric Delaunay Standards-Version: 3.9.1 Build-Depends: tk, debhelper (>= 7), quilt (>= 0.46-7~) Package: scsitools Architecture: any Depends: ${shlibs:Depends}, util-linux (>= 2.11b-3), sg3-utils (>= 1.24), ${misc:Depends} Conflicts: hwtools (<< 0.6) Description: Collection of tools for SCSI hardware management This package is a collection of tools for manipulating SCSI hardware: . scsiinfo: displays SCSI drive low-level information and modifies SCSI drive settings, scsidev: makes permanent SCSI LUN -> devicename connections, scsifmt: low-level SCSI formatter, sraw: benchmarks raw SCSI I/O rates bypassing the buffer cache, scsi-spin: program to manually spin up and down a SCSI device. . Beware that, to be used properly, these tools require some knowledge of what they're doing as they can cause damage to your system. Package: scsitools-gui Architecture: any Depends: ${shlibs:Depends}, util-linux (>= 2.11b-3), sg3-utils (>= 1.24), ${misc:Depends}, scsitools Conflicts: hwtools (<< 0.6) Recommends: tk | wish Description: Collection of tools for SCSI hardware management This package is a collection of tools for manipulating SCSI hardware: . scsiinfo: displays SCSI drive low-level information and modifies SCSI drive settings, scsidev: makes permanent SCSI LUN -> devicename connections, scsifmt: low-level SCSI formatter, sraw: benchmarks raw SCSI I/O rates bypassing the buffer cache, scsi-spin: program to manually spin up and down a SCSI device. . Beware that, to be used properly, these tools require some knowledge of what they're doing as they can cause damage to your system. . This package contains the graphical front-end for scsitools debian/source/0000775000000000000000000000000012233502660010467 5ustar debian/source/format0000664000000000000000000000001412233502660011675 0ustar 3.0 (quilt)