Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ scsi_disk(7) — Dell System V Release 4 Issue 2.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

disksetup(1M)

edvtoc(1M)

fdisk(1M)

fs(4)

mdevice(4)

mkpart(1M)

mount(1M)

prtvtoc(1M)

ioctl(2)



scsi_disk(7)              UNIX System V(SCSI Drivers)              scsi_disk(7)


NAME
      scsidisk - sd01 SCSI disk driver

DESCRIPTION
      The Small Computer System Interface (SCSI) disk driver sd01 determines
      the layout of the disk dynamically, as described below.  It provides
      block and character (raw) access to the individual partitions of the
      disk, as well as the entire physical disk.

      The minor numbers for a disk device determine the logical sections (or
      slices) on the drive.  The sd01 disk minor number layout supports 16
      partitions per disk and 16 disks per major number; [see mdevice(4).]
      Partition 0 represents the entire UNIX system partition (as defined by
      the fdisk(1M) table).  Other partitions are defined by information in the
      volume table of contents (VTOC).  When accessing partition 0, other
      partition boundaries are ignored.  Thus, the user must take care when
      using the disk in this way.

      The full fixed disk is partitioned at two levels: first, sections of the
      disk to be used by different operating systems are described by the
      fdisk(1M) table contained in the first block of the disk.  Second, the
      UNIX system sections of the disk are further partitioned according to
      information contained in the VTOC.  The VTOC is currently in the 30th
      sector of the UNIX system partition; [see disksetup(1M).]  The VTOC also
      contains information about the non-UNIX system partitions described in
      the fdisk table.  When the disk device is opened, the VTOC is read by the
      driver and is used to fill out its tables of logical disks, assigned by
      minor device number.

      Each partition in the fdisk table is specified as to its type (e.g., DOS,
      UNIX system, or other).  A partition (file system) is usable by the UNIX
      system only if its type is correct (e.g., a DOS partition is not usable
      by the UNIX system, except as a raw, non-file system device).

      On each drive, sector 0 contains the primary bootstrap and the fdisk
      table.  The first 29 sectors of the UNIX system partition contain the
      first-stage and second-stage bootstraps.  The 30th sector contains the
      pdinfo structure and VTOC table.

      The fdisk table indicates which of the partitions is the active, or
      bootable, partition.  When the machine is booted, the primary boot code
      looks in the fdisk table for the active partition and jumps to sector 0
      of that partition to find the first-stage bootstrap.  If the first-stage
      bootstrap is over one sector in length, it is the responsibility of the
      first-stage bootstrap to understand this.  Note that both the first
      cylinder (containing the fdisk table, first-stage bootstrap and VTOC) and
      the first track of the active partition (containing the first-stage
      bootstrap) can only be accessed using partition 0, since these tracks are
      normally not considered part of any other partition in the VTOC.





10/89                                                                    Page 1







scsi_disk(7)              UNIX System V(SCSI Drivers)              scsi_disk(7)


      Mapping of bad blocks is done dynamically and automatically by the sd01
      disk driver without user intervention and without retaining a bad block
      log on the disk.  The SCSI direct-access controllers reassign the
      defective blocks to an area on the disk reserved for this purpose.  The
      sd01 disk driver can map both marginal bad blocks (i.e., readable with
      some difficulty) and actual bad blocks (i.e., unreadable).  The sd01 disk
      driver provides the sd01log_marg variable in
      /etc/conf/pack.d/sd01/space.c.  This variable has been assigned a default
      value of zero (0).  In this mode, only marginal bad blocks found in the
      sacred area of the disk (the first 30 sectors of the UNIX system
      partition) are reported.  Setting this variable to one (1) allows all
      marginal blocks to be reported.  In addition, setting this variable to
      two (2) allows for reporting and mapping of marginal blocks (except
      sacred area).

      The driver provides the variable sd01diskinfo in the file
      /etc/conf/pack.d/sd01/space.c.  This variable has been assigned the
      default value of 0x2040. With that setting, the driver reports the disk
      parameters to be 32 sectors per track and 64 heads for any disk. Setting
      this variable to zero (0) allows the driver to report the actual geometry
      of disks as reported by the drives themselves.

      The sd01 disk driver reports problems with driver error messages.  The
      error numbers in the error messages differentiate the type of error.  For
      SCSI sense codes, extended sense codes, and command codes, see the file
      /usr/include/sys/scsi.h.  For SDI return codes, see the file
      /usr/include/sys/sdi.h.

      The sd01 driver does not map or report a bad block that resides in a
      non-UNIX (i.e., MS-DOS) partition of the disk.  Even with dynamic bad
      block handling, it is possible for damage to occur that cannot be mapped
      automatically.  This means that the user may have to restore the file
      system from the last full backup, depending on where the bad block
      occurred.

      The sd01 driver receives command requests from the kernel via the
      Input/Output (I/O) Control Call ioctl [see ioctl(2) in the Programmer's
      Reference Manual].  The sd01 driver generates the requested commands and
      passes them to the host adapter driver.  When command execution is
      complete, the host adapter driver notifies the sd01 driver through
      interrupt.  After this notification, the sd01 driver performs any
      required error recovery and indicates to the kernel that the I/O request
      is complete.  The sd01 driver operates independently of the hardware used
      to talk to the SCSI bus.

      The SCSI subsystem consists of a SCSI bus with a host adapter card, at
      least one target controller and logical unit, and the associated driver
      software.  The SCSI special device file names associated with the sd01
      disk driver have the form:





Page 2                                                                    10/89







scsi_disk(7)              UNIX System V(SCSI Drivers)              scsi_disk(7)


            /dev/[r]dsk/c#t#d#s#

      The files in the /dev/dsk directory access the disk via the system's
      normal buffering mechanism and may be read and written without regard to
      physical disk records.

      There is also a [r] raw interface that provides for direct transmission
      between the disk and the user's read or write buffer.  A single read or
      write call results in exactly one I/O operation. Therefore, raw I/O is
      considerably more efficient when many words are transmitted.  The names
      of the raw disk files contain /dev/rdsk and have the same form as the
      /dev/dsk files.

      In raw I/O the buffer must begin on a 512-byte boundary, and transfer
      counts must be integral multiples of 512 bytes.

      The naming convention for the SCSI disk special device file name
      components is listed below:

        [r]   where the optional r in /[r]dsk means a raw (i.e., character)
              device.  Whereas /dsk, without the optional r, means a block
              device.

        c#    where # is the occurrence of the host adapter board in the
              system.  The host adapter ranges are from 0-2 (machine
              dependent).

        t#    where # is the target controller number.  The target controller
              number ranges are from 0-f hexadecimal.

        d#    where # is the logical unit number of the disk device.  The
              logical unit number ranges are from 0-3 since each target
              controller currently supports up to four disks.

        s#    where # is the disk slice number or VTOC partition number.  The
              slice or partition number ranges are from 0-f hexadecimal.

   ioctl Calls
      The ioctl commands that are used by the sd01 driver to control the
      reading and writing of data to disk appear below.

      VCONFIG

            This call is used by mkpart to reconfigure the drive, so that the
            drive configuration matches the parameters specified in the
            /etc/partitions file.  The mkpart command tells the driver the true
            disk parameters (as defined by the /etc/partitions file) by using
            the VCONFIG ioctl.  The argument to the ioctl is the address of
            one of the following structures, defined in <sys/vtoc.h>,
            containing the new configuration parameters:




10/89                                                                    Page 3







scsi_disk(7)              UNIX System V(SCSI Drivers)              scsi_disk(7)


            union ioarg {
               struct {
                  ushort   ncyl;    /* number of cylinders */
                  unchar   nhead;   /* heads/cylinder */
                  unchar   nsec;    /* sectors/track */
                  ushort   secsiz;  /* bytes/sector */
               } iacd;
            }

            Note that it is not possible to change the sector size on the hard
            disk with this ioctl, and that an attempt to do so results in the
            ioctl failing,  with errno set to EINVAL.
            Note that this call is provided for backward compatibility with the
            mkpart command.  This call should no longer be used and may be
            removed in the future.

      VREMOUNT

            This call is used to force the driver to re-read the VTOC on the
            next open of the drive.  It fails if any partition other than
            partition 0 is currently open, since changing the partition table
            information is potentially disastrous for a process using the
            partition.  This is used by disksetup when it changes the VTOC, so
            that the driver updates its internal tables.

      VGETPARMS

            This call is used to get information about the current drive
            configuration.  The argument to the ioctl is the address of one of
            the following structures, defined in <sys/vtoc.h>, which are filled
            in by the ioctl:

            struct diskparms {
             char   dptype;    /* Disk type (see below) */
             unchar dpheads;   /* No. of heads */
             ushort dpcyls;    /* No. of cylinders */
             unchar dpsectors; /* No. of sectors/track */
             ushort dpsecsiz;    /* No. of bytes/sector */
             ushort dpptag;    /* currently not used */
             ushort dppflag;   /* currently not used */
             daddrt  dppstartsec; /* Starting abs. sector no. */
             daddrt  dppnumsec; /* currently not used */
            }

            /* Disk types */
            #define DPTNOTDISK 0 /* Not a disk device */
            #define DPTWINI    1 /* Winchester disk */
            #define DPTFLOPPY  2   /* Floppy */
            #define DPTOTHER   3 /* Other type of disk */
            #define DPTSCSIHD 4 /* SCSI hard disk */
            #define DPTSCSIOD 5 /* SCSI optical disk */



Page 4                                                                    10/89







scsi_disk(7)              UNIX System V(SCSI Drivers)              scsi_disk(7)


            /* Partition tag */
            #define VBOOT    1 /* bootable partition */
            #define VROOT    2 /* root filesystem */
            #define VSWAP    3 /* swap filesystem */
            #define VUSR   4 /* usr filesystem */
            #define VBACKUP  5 /* entire disk */
            #define VALTS    6 /* alternate sectors */
            #define VOTHER 7   /* non-UNIX system partition */

            /* Partition flag */
            #define VUNMNT 0x001   /* unmountable partition */
            #define VRONLY 0x010   /* read only partition */
            #define VOPEN    0x100 /* partition open */
            #define VVALID 0x200   /* partition valid to use */

            For the SCSI disk driver, the disk type is always DPTSCSIHD.
            Since the structure returned by VGETPARMS is the same for
            diskette, hard disk and optical disk drivers, programs may be
            written to understand any one.

      VPDLOC

            This call returns the logical sector address of the pdinfo
            structure.  The value is returned in pdloc.


            unsigned    long    pdloc;


      VRDABS/VWRABS

            This call is used as a method of reading/writing any sector on the
            hard disk.  Only users with root privilege can freely access any
            sector.  Users who do not have root privilege can access the
            partition table (sector 0) or the boot slice (to allow access to
            the VTOC).  The absolute sector address to be written to is placed
            in abssec.  The data for the sector is read into or written from
            absbuf.  The size of absbuf should be disk_parms.dp_secsize for
            the current drive.  The absio structure is defined in <sys/vtoc.h>.


            struct absio {
             daddrt  abssec;    /* Absolute sector no. (from 0) */
             char   *absbuf;   /* Sector buffer */
            };


      VPREAD/VPWRITE

            These calls are used to read/write any size data block on the disk
            regardless of the physical sector size.  Only users with root
            privilege can make use of the call.  The starting logical sector


10/89                                                                    Page 5







scsi_disk(7)              UNIX System V(SCSI Drivers)              scsi_disk(7)


            address to be written to is placed in sectst.  The number of bytes
            to be transferred is placed in datasz.  The data to be transferred
            is placed in memaddr.  The phyio structure is defined in
            <sys/vtoc.h>.


            struct phyio {
              int     retval; /* Return value */
              unsigned  long sectst;/* Sector address */
              unsigned  long memaddr;/* Buffer address */
              unsigned  long datasz;/* Transfer size in bytes */
            };


      VPDREAD/VPDWRITE

            These calls are used to read/write the Physical Description sector
            on the disk regardless of this sectors location.  Only users with
            root privilege can make use of these calls.  The starting logical
            sector address to be written is assigned by the sd01 driver.  The
            physical sector size of the disk must be placed in datasz.  The
            data to be transferred is placed in memaddr.  The phyio structure
            is defined in <sys/vtoc.h>.

      SDPDLOC

            This call returns the physical sector address of the pdinfo
            structure.  The value is returned in pdloc.


            unsigned  long  pdloc;/* PDinfo structure address */


      SDELEV

            This call is used to control the elevator algorithm for sorting the
            I/O request queues.  If arg is 0, the elevator algorithm is used.
            If arg is 1, the elevator algorithm is not used, and the I/O
            requests are queued on a first-in, first-out basis.

      The following group of ioctl commands are used by the sd01 driver to
      limit access of a SCSI drive to a specified processor.

      SDIRESERVE    Used to reserve a SCSI disk for a processor.

      SDIRELEASE    Used to release a SCSI disk from a processor.

      SDIRESTAT     Used to return device reservation status.

      The following ioctl commands are used to identify a target driver and get
      pass-through major and minor numbers for a target device [see, for
      example, scsiadaptec(7)].


Page 6                                                                    10/89







scsi_disk(7)              UNIX System V(SCSI Drivers)              scsi_disk(7)


      BGETTYPE

            Used to get the bus name (e.g., scsi) and device driver name (e.g.,
            sd01) of a specific device.

      BGETDEV

            Used to get the pass-through major and minor numbers to the calling
            utility to allow creation of a pass-through special device file.

   Partitions
      The fdisk table allows partitions to be assigned at cylinder boundaries;
      however, the VTOC allows partitions to start on track boundaries.  This
      is used in the bootable UNIX system partition to make the first track
      (containing the bootstrap code) not be an actual part of the partition.
      The fdisk table allows at most four partitions on a fixed disk, but the
      VTOC allows the UNIX system portion to be divided into at most 16
      partitions.  Each partition is identified by a minor device number; the
      mapping from partition to minor device number is made at the time the
      disk is first partitioned via the disksetup command.  This mapping
      remains the same until the disksetup or edvtoc [see edvtoc(1M)] command
      is rerun.

      Attempts to open file systems for which there are no partitions fail
      (non-existent device).  Likewise, attempts to mount [see mount(1M)]
      partitions that do not contain UNIX file systems fail.

FILES
      /dev/dsk/*
      /dev/rdsk/*
      /usr/include/sys/scsi.h
      /usr/include/sys/sdi.h
      /usr/include/sys/sdiedt.h
      /usr/include/sys/vtoc.h

SEE ALSO
      disksetup(1M), edvtoc(1M), fdisk(1M), fs(4), mdevice(4), mkpart(1M),
      mount(1M), prtvtoc(1M), scsiadaptec(7), scsicdrom(7), scsidpt(7),
      scsitape(7), scsiwd7000(7), scsiworm(7)

      ioctl(2) in the Programmer's Reference Manual].

NOTES
      The driver retries failed transfers up to two times depending on the
      error type.  Certain errors are not retried.  The driver displays an
      appropriate message upon encountering an error during the transfer.

      The VTOC and second-stage bootstrap requires that no bad sectors occur in
      the first 30 sectors of the UNIX partition on the disk.  When a marginal
      bad block occurs the driver's warning indicates that the controller's
      error-correction algorithm successfully recovered from an error.  This
      may be a symptom of a sector going bad.


10/89                                                                    Page 7





Typewritten Software • bear@typewritten.org • Edmonds, WA 98026