[illumos-Developer] Webrev for bug 561: Strange characters when executing "format"

Gary Mills mills at cc.umanitoba.ca
Fri Jul 8 06:20:35 PDT 2011


This is for illumos bug 561: Strange characters when executing
"format".  My webrev is at:

    http://cr.illumos.org/view/81gth4l7/illumos561/

I noticed this the other day when I ran `format' on my oi_148b
machine, installed directly from the oi_148b ISO. It messed up my
screen so badly that I had to use `tput rmacs' to recover:

    # format                                              
    Searching for disks...
    Failed to inquiry this logical diskdone
    
    
    AVAILABLE DISK SELECTIONS:
           0. c3d0 < /* garbage starts here */

Here's an excerpt from `truss':

    8140:	chdir("/dev/rdsk")				= 0
    8140:	ioctl(4, DKIOCGEXTVTOC, 0x08046720)		= 0
    8140:	ioctl(4, DKIOCINFO, 0x080466A0)			= 0
    8140:	ioctl(4, DKIOCGGEOM, 0x08046A30)		= 0
    8140:	ioctl(4, DKIOCINFO, 0x08046A60)			= 0
    8140:	ioctl(4, USCSICMD, 0x080469B0)			Err#25 ENOTTY
    8140:	write(1, "\n", 1)				= 1
    8140:	fstat64(2, 0x08045A40)				= 0
    8140:	write(2, 0x08098694, 35)			= 35
    8140:	   F a i l e d   t o   i n q u i r y   t h i s   l o g i c a l   d
    8140:	   i s k

The cause was obvious in the source: when `uscsi_inquiry()' failed, it
was printing uninitialized memory.  After my fix, it works like this:

    # /export/home/mills/Downloads/code/illumos-gate/usr/.../format
    Searching for disks...
    
    Inquiry failed - Inappropriate ioctl for device
    done
    
    
    AVAILABLE DISK SELECTIONS:
           0. c3d0 <Unknown-Unknown-0001 cyl 4843 alt 2 hd 255 sec 63>
              /pci at 0,0/pci-ide at 12/ide at 0/cmdk at 0,0
    Specify disk (enter its number): 0
    selecting c3d0
    NO Alt slice
    No defect list found
    [disk formatted, no defect list found]
    /dev/dsk/c3d0s0 is part of active ZFS pool rpool. Please see zpool(1M).
    
    
    FORMAT MENU:
            disk       - select a disk
    ...
            quit
    format> veri
    Warning: Primary label on disk appears to be different from
    current label.
    
    Warning: Check the current partitioning and 'label' the disk or use the
    	 'backup' command.
    
    Primary label contents:
    
    Volume name = <        >
    ascii name  = <DEFAULT cyl 4843 alt 2 hd 255 sec 63>
    pcyl        = 4845
    ncyl        = 4843
    acyl        =    2
    bcyl        =    0
    nhead       =  255
    nsect       =   63
    Part      Tag    Flag     Cylinders        Size            Blocks
      0       root    wm       1 - 4842       37.09GB    (4842/0/0) 77786730
      1 unassigned    wm       0               0         (0/0/0)           0
      2     backup    wu       0 - 4842       37.10GB    (4843/0/0) 77802795
      3 unassigned    wm       0               0         (0/0/0)           0
      4 unassigned    wm       0               0         (0/0/0)           0
      5 unassigned    wm       0               0         (0/0/0)           0
      6 unassigned    wm       0               0         (0/0/0)           0
      7 unassigned    wm       0               0         (0/0/0)           0
      8       boot    wu       0 -    0        7.84MB    (1/0/0)       16065
      9 unassigned    wm       0               0         (0/0/0)           0
    
    format> quit

The underlying problem seems to be that the USCSI ioctl returns
ENOTTY.  This error is not listed in the uscsi(7I) man page.

I understand that this bug was also fixed in a build of Oracle Solaris 11,
probably not in quite the same way.

-- 
-Gary Mills-        -Unix Group-        -Computer and Network Services-



More information about the Developer mailing list