Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sd01(7) — UnixWare 2.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

adsc(7)

disksetup(1M)

dpt(7)

edvtoc(1M)

fdisk(1M)

intro(7)

ioctl(2)

mcis(7)

mount(1M)

prtvtoc(1M)

sc01(7)

st01(7)

sw01(7)

wd7000(7)






       sd01(7)                                                      sd01(7)


       NAME
             sd01 - Portable Device Interface (PDI) disk target driver

       DESCRIPTION
             The sd01 disk target driver is the device-level driver for
             Small Computer System Interface (SCSI) hard disks, SCSI
             optical disks, and ESDI/ST506/IDE/MFM integral disks.  It
             provides block and character (raw) access to the disk, and I/O
             controls (ioctl) to the disk.  sd01 sets up two levels of
             organization to the disk, to allow the disk to be shared with
             other operating systems, and provide efficient sized portions
             within the UNIX system.

             The first level of organization of the disk by sd01 is the
             partition table.  The partition table divides the disk into
             pieces (called partitions) which serve as logical disks.
             There are a maximum of four partitions for each disk.  A
             partition has four characteristics: a start sector, a length,
             an operating system type (for example, UNIX, DOS, Extended
             DOS, and so on), and an active flag (which indicates the
             current bootable partition).  A valid partition has at least
             the first three fields defined.  A bootable valid partition
             has all four fields defined/on.

             The partition table is maintained by the fdisk(1M) command.
             The sd01 target driver searches the partition table for UNIX
             partitions.  The active flag is used not only to indicate that
             a partition on the boot disk is bootable, but also indicates
             whether it is accessible (for example, a UNIX partition on the
             second disk which isn't active cannot be accessed).  The sd01
             target driver also allows access to non-UNIX partitions on a
             disk, even if there is no UNIX partition, and thus no Virtual
             Table of Contents (VTOC).  This method uses the information on
             the fdisk table.

             Within a UNIX partition is the second level of organization of
             the disk.  The UNIX partition is broken into contiguous
             sections called slices.  The slices of a UNIX partition are
             defined by the VTOC.  The VTOC provides the means to break up
             the UNIX partition in smaller pieces to better manage the
             space, to differentiate slices for special purposes, and to
             allow protection of some of the slices.  The VTOC allows for a
             maximum of 16 UNIX slices per UNIX disk partition.  A slice
             also has four characteristics: a start sector, a length, a
             slice type (for example, root, user, swap, stand, and so on),
             and permissions (valid and mountable/unmountable).  A slice


                           Copyright 1994 Novell, Inc.               Page 1













      sd01(7)                                                      sd01(7)


            can contain a file system (for example, VXFS, S5, BFS, and so
            on), can be used as swap space for paging, or left to be
            organized by an application such as a database.

            Several of the slices have required definitions as follows:

            Slice 0   The whole UNIX partition; that is, it has the same
                      start and length as the UNIX partition.

            Slice 7   The boot slice which contains UNIX boot code (if it
                      is the boot disk), the VTOC information, and the
                      PDINFO (described later).  This slice occupies
                      sector 1 through 34 of UNIX partition.

            Slice 8   The alternates slice, containing the table of
                      remapped sectors, sectors which have been remapped,
                      sectors which have read-errors but which have not
                      yet been remapped, and spare sectors available for
                      remapping.

            Slice 9   Used in SVR4.0 and earlier UNIX releases
                      additionally as the alternate track area.  The
                      alternates mechanism was consolidated beginning with
                      SVR4.2 to use one slice.

            On the boot disk, there are several other slices which also
            have required definitions:

            Slice 1   The root file system

            Slice 2   The swap slice

            Slice 10  The boot slice which contains the BFS file system

            Finally, on a boot disk, the optional file systems are
            organized as follows:

            Slice 3   The /usr file system

            Slice 4   The /home file system

            Slice 5   Currently unused

            Slice 6   The dump slice (holds memory dumps)




                          Copyright 1994 Novell, Inc.               Page 2













       sd01(7)                                                      sd01(7)


             Slice 11  The /var file system

             Slice 12  The /home2 file system

             Slice 13  The /tmp file system

             Slice 14  The Volume Management public slice

             Slice 15  The Volume Management private slice

             The slices of a disk are represented by device nodes, which
             have the major number for sd01 (the system has one fixed,
             unchangeable, major number for sd01), and a minor number
             pointing to one of slices.  There are 16 UNIX slices and five
             special partitions (one for each entry in the fdisk partition
             table).  The system supports 512 minors per disk, 0-15 are for
             VTOC UNIX slices, 16 is a special whole disk partition, 17-20
             for special fdisk table partitions, and 21-511 are reserved.
             The minor numbers 0 to 511 are handled specially.  They are
             used as a clone device for the boot disk.  Therefore the boot
             disk has two sets of minor numbers: the ones from 0 to 511 as
             well as the range it would normally have.  When the disk
             device is opened, the partition table and the VTOC are read by
             sd01 to fill out its tables of partitions and UNIX slices.

             Mapping of bad blocks is performed dynamically and
             automatically by the sd01 disk driver, without user
             intervention and without retaining a fixed 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 (that is, readable with some difficulty) and actual bad
             blocks (that is, unreadable).  It also keeps track of blocks
             which are currently unreadable, but which have not yet been
             remapped.  The sd01 driver does not map or report a bad block
             residing in a non-UNIX System (for example, MS-DOS) partition
             of the disk.  In addition, even with dynamic bad block
             handling, it is possible for damage to occur that cannot be
             mapped automatically.  This means that you may have to restore
             the file system from the last full backup, if the bad block
             occurs in a critical area of the disk which cannot tolerate
             bad sectors.

             The sd01 disk driver reports problems with driver error
             messages.  The error numbers in the error messages identify
             the type of error.  For SCSI sense codes, extended sense


                           Copyright 1994 Novell, Inc.               Page 3













      sd01(7)                                                      sd01(7)


            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 receives command requests from the kernel
            through the Input/Output (I/O) control call ioctl(2).  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 an 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 files in the /dev/dsk directory access the disk through
            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 special device file names associated with the sd01 disk
            driver have either of the two following forms:

                        /dev/[r]dsk/cCbBtTdDsS

            or

                        /dev/[r]dsk/cCbBtTdDpP

            The naming convention for the sd01 disk  special  device  file
            name components is as follows:

            [r]   The optional r  in  /[r]dsk  denotes  a  raw  (that  is,
                  character) device; /dsk without the optional r indicates
                  a block device





                          Copyright 1994 Novell, Inc.               Page 4













       sd01(7)                                                      sd01(7)


             cC    C is the occurrence of the host  adapter  board  in  the
                   system   (that  is,  card  number),  ranging  from  0-31
                   (machine dependent)

             bB    B  is  the  bus  number,  ranging  from   0-7   (machine
                   dependent)

             tT    T is the target controller number, ranging from 0-31.

             dD    D is the logical unit number of the disk device, ranging
                   from   0-31,  since  each  target  controller  currently
                   supports up to four disks

             sS    S is the disk slice number, ranging from 0-15.

             pP    P is the fdisk partition number.  P can range from 0  to
                   4,  to  specify  an  entry in the fdisk partition table.
                   The p0 node corresponds to the whole  disk,  the  p[0-4]
                   nodes  correspond to partitions as they are displayed by
                   the fdisk command.

                   Note  that  access  to  the  active  UNIX  partition  is
                   prohibited if you specify the slice in the form pP.  Nor
                   does the sd01 driver map or report a bad block  residing
                   in  a non-UNIX System (for example, MS-DOS) partition of
                   the disk.

                   If the disk does not contain  a  UNIX  partition,  there
                   will  be  no  VTOC  or  PDINFO  on  the disk.  You will,
                   however, be able to access other partitions through  the
                   special  p[1-4] nodes, and the whole disk through the p0
                   node.

             The disk parameters-number of cylinders,  heads,  and  sectors
             per  track-are  obtained at driver initialization (init) time.
             If the disk is an  ESDI/ST506/IDE  drive,  the  CMOS  contains
             parameters  for  the  first two disks.  For SCSI disks, a read
             capacity command  is  issued,  and  the  disk  parameters  are
             calculated  based  on  a disk geometry of 32 sectors per track
             and 64 heads.  This geometry  is  for  drives  with  512  byte
             sectors.   It  is  adjusted  if the number of bytes per sector
             changes.   The  disk  parameters  are   stored   in   Physical
             Descriptor  Information  (PDINFO) structure which is stored in
             the boot slice of the disk.  The PDINFO is kept  as  a  sanity
             check against those found at driver init time.



                           Copyright 1994 Novell, Inc.               Page 5













      sd01(7)                                                      sd01(7)


            When the machine is booted, the primary boot code (BIOS) 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.   The  boot  code  will  read in the VTOC to
            locate the BFS filesystem.  It will then load the  kernel  and
            begin executing the kernel.

         ioctl Calls
            The ioctl calls used by the sd01 driver to control the reading
            and writing of data to disk are as follows:

            V_CONFIG
                  Used to modify the parameters (cylinders and heads) of a
                  disk device.  Its usage is not recommended and it is no
                  longer used in any of the system commands.  The argument
                  to the ioctl is the address of one of the following
                  structures, defined in sys/vtoc.h, containing the new
                  configuration parameters:
                  union io_arg {
                    struct {
                         ushort  ncyl;  /* Number of cylinders */
                         unchar  nhead; /* Heads/cylinder */
                         unchar  nsec;  /* Sectors/track */
                         ushort  secsiz;/* Bytes/sector */
                    } ia_cd;
                  }

                  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.  This call is provided for backward
                  compatibility with any commands which use it.  Note that
                  this call will not work with a disk that does not have a
                  UNIX partition.  This call should no longer be used and
                  will be removed in the future.

            V_REMOUNT
                  Forces sd01 to re-read the VTOC on the next open
                  operation of the drive.  It fails if any slice other
                  than slice 0 is currently open, since the VTOC
                  information cannot be updated while a process is using a
                  slice.  This is used by disksetup when it changes the
                  VTOC to signal sd01 to update its internal tables.  Note
                  that this call will not work with a disk that does not


                          Copyright 1994 Novell, Inc.               Page 6













       sd01(7)                                                      sd01(7)


                   have a UNIX partition.

             V_GETPARMS
                   Gets information about the current drive configuration.
                   The argument to the ioctl is the address of the
                   following structure, defined in sys/vtoc.h, which are
                   filled in by the ioctl:
                   struct disk_parms {
                     char  dp_type;    /* Disk type (see below) */
                     unchar            dp_heads;/* No. of heads */
                     ushort            dp_cyls;/* No. of cylinders */
                     unchar            dp_sectors;/* No. of sectors/track */
                     ushort            dp_secsiz;/* No. of bytes/sector */
                     ushort            dp_ptag;/* Currently not used */
                     ushort            dp_pflag;/* Currently not used */
                     daddr_t           dp_pstartsec;/* Starting abs. sector no. */
                     daddr_t           dp_pnumsec;/* Currently not used */
                   }
                   /* Disk types */
                   #define        DPT_NOTDISK0/* Not a disk device */
                   #define        DPT_WINI1/* Winchester disk */
                   #define        DPT_FLOPPY2/* Floppy */
                   #define        DPT_OTHER3/* Other type of disk */
                   #define        DPT_SCSI_HD4/* SCSI hard disk */
                   #define        DPT_SCSI_OD5/* SCSI optical disk */
                   /* Partition tag */
                   #define        V_BOOT1/* Bootable partition */
                   #define        V_ROOT2/* Root filesystem */
                   #define        V_SWAP3/* Swap slice */
                   #define        V_USR4/* User filesystem */
                   #define        V_BACKUP5/* Entire disk */
                   #define        V_ALTS6/* Alternate sectors
                                          (SVR4.0 and earlier)  */
                   #define        V_OTHER7/* Non-UNIX System partition */
                   #define        V_ALTTRK8/* Alternate tracks
                                          (SVR4.0 and earlier) */
                   #define        V_STAND9/* stand (BFS) filesystem */
                   #define        V_VAR0A/* Var filesystem */
                   #define        V_HOME0B/* Home filesystem */
                   #define        V_DUMP0C/* Dump slice */
                   #define        V_ALTSCTR0D/* Alternate sectors (SVR4.2) */
                   /* Partition flag */
                   #define        V_UNMNT0x001/* Unmountable partition */
                   #define        V_RONLY0x010/* Read only partition */
                   #define        V_OPEN0x100/* Partition open */
                   #define        V_VALID0x200/* Partition valid to use */


                           Copyright 1994 Novell, Inc.               Page 7













      sd01(7)                                                      sd01(7)


                  For SCSI disks the disk type is DPT_SCSI_HD.  For
                  ESDI/ST506/IDE disks the disk type is DPT_WINI.

            V_PDLOC
                  Returns the logical sector address of the pdinfo
                  structure.  The value is returned in pdloc.
                      unsigned    longpdloc;

                  Note that this call will not work with a disk that does
                  not have a UNIX partition.

            V_RDABS/V_WRABS
                  Used as a means for 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 abs_sec.
                  The data for the sector is read to or written from
                  abs_buf.  The size of abs_buf should be
                  disk_parms.dp_secsize for the current drive.  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.  The absio structure is
                  defined in sys/vtoc.h.
                  struct absio {
                      daddr_t  abs_sec;     /* Absolute sector no. (from 0) */
                      char    *abs_buf;     /* Sector buffer */
                  };

            V_PREAD/V_PWRITE
                  Used to read or write any size data block on the disk,
                  regardless of the physical sector size.  Only users with
                  root privilege can use these calls.  The starting
                  logical sector address to be written to or read from is
                  placed in sectst, the number of bytes to be transferred
                  is placed in datasz, the data to be transferred is
                  placed in memaddr, and 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 */


                          Copyright 1994 Novell, Inc.               Page 8













       sd01(7)                                                      sd01(7)


                       unsigned    long datasz;   /* Transfer size in bytes */
                   };

             V_PDREAD/V_PDWRITE
                   Used to read or write the Physical Description sector on
                   the disk, regardless of this sector's location.  Only
                   users with root privilege can use these calls.  The
                   starting logical sector address to be written to or read
                   from 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, and the phyio
                   structure is defined in sys/vtoc.h.

             SD_PDLOC
                   Returns the physical sector address of the pdinfo
                   structure.  The value is returned in pdloc.
                     unsigned  long  pdloc;

             SDI_RESERVE
                   Reserves a SCSI disk for a processor.

             SDI_RELEASE
                   Releases a SCSI disk from a processor.

             SDI_RESTAT
                   Returns device reservation status.

             The following ioctl commands are used to identify a target
             driver and to get pass-through major and minor numbers for a
             target device:

             B_GETTYPE
                   Returns the bus name (for example, scsi) and device
                   driver name (for example, sd01) of a specific device.

             B_GETDEV
                   Returns the pass-through major and minor numbers to the
                   calling utility, allowing creation of a pass-through
                   special device file.

          Files
             /dev/dsk/*
             /dev/rdsk/*
             /usr/include/sys/scsi.h
             /usr/include/sys/sdi.h
             /usr/include/sys/sdi_edt.h


                           Copyright 1994 Novell, Inc.               Page 9













      sd01(7)                                                      sd01(7)


            /usr/include/sys/vtoc.h

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

            The VTOC and second-stage bootstrap require that no bad
            sectors occur in the first 30 sectors of the UNIX System
            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.

            The sd01 disk target driver allows access to non-UNIX
            partitions on a disk, even if there is no UnixWare
            partition/VTOC.  It does so by using the information in the
            fdisk table and the /dsk/cCbBtTdDp[0-4] special device nodes.

            The nodes called /dev/[r]dsk/1s[0-9-] will exist only when
            there is actually a second disk on the system. In the past,
            these nodes were always created. It is no longer possible to
            create these nodes when the second disk does not exist because
            it is not possible to predict the correct minor number for
            them.

      REFERENCES
            adsc(7), disksetup(1M), dpt(7), edvtoc(1M), fdisk(1M),
            intro(7), ioctl(2) mcis(7) mount(1M), prtvtoc(1M), sc01(7),
            st01(7), sw01(7), wd7000(7)

















                          Copyright 1994 Novell, Inc.              Page 10








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