format(1M) format(1M)
NAME
format - format a disk
SYNOPSIS
/sbin/format [-fprsw] [-d datafile] /dev/rdsk/c?d?s?
DESCRIPTION
The format command formats a disk device while also creating a block
which describes the physical layout of the disk (the pdsector).
format exec's a lower-level format program relating to the device
driver for that particular device, passing on all the arguments
given. The lower-level format program lives in
/usr/lib/disk_formats/bus/controller_type/format. The
bus/controller_type part of the pathname is generated by issuing a
BGETTYPE ioctl.
Each low-level format program can have one or more datafiles
associated with it (in the same directory), holding details of the
fields of the pdsector or formatting parameters for a given disk
type.
The /dev/rdsk/c?d?s? file must be the character special file of the
device to be formatted.
OPTIONS
The following options are recommended to apply to the lower-level
format program:
-f read the pdsector, format the device, and write a pdsector to
the disk
-p print out the data file name associated with the disk that is
going to be opened and then exit. This is useful for debugging
purposes when adding a new disk to a given bus/controller_type
-r display the current contents of the pdsector
-s set the pdsector in the device driver - that is, the pdsector
is not written
-w set the pdsector in the device driver and also write the
pdsector to the disk
-d datafile
override default data file and use the named datafile instead
The data file contains one specification line for each individual
parameter to be set. Each line is delimited by a new line character
(\n). If the first character of a line is a hash character (#), the
line is treated as a comment. An example of an entry in a datafile
would be:
8/91 Page 1
format(1M) format(1M)
bytespersector = 512
Parsing of the datafile is up to the implementor of the low-level
format program; however, a parsing routine called getdiskinfo() is
provided:
#include "gfdefs.h"
getdiskinfo(char *datafile, struct diskformatdesc *diskdes)
The arguments are:
datafile
the name of the datafile file
diskdes
a pointer to an array of structures containing a list of which
fields are to be read from the datafile
The diskformatdesc structure has the following elements:
char *dffieldname
the name of the field to be updated - for example,
bytespersector
int dfformat
field type - HEX, DECIMAL, OCTAL or STRING
union dfident dfident
holds either an integer value or a pointer to a string for the
field name
int dfstatus
a status value which is set to VALSTAT(1) if the parsing
routine managed to fill in the value correctly. If the value
to be used is expected to be in the data file, dfstatus should
be initialized to INVALSTAT(0).
An example declaration of the parsing structures would be:
struct diskformatdesc ddatades[] = {
"bytespersector", DECIMAL, 0, INVALSTAT,
""
};
After a format has been issued, it will necessary to run setvtoc in
order for the disk to be populated with a VTOC (volume table of
contents) defining partitions of the disk, etc.
Page 2 8/91
format(1M) format(1M)
SEE ALSO
prtvtoc(1M), setvtoc(1M), ioctl(2)
NOTES
In /usr/lib/diskformats there is source for an example format
program that can be used when designing a new format program for a
particular device (if the implementor so wishes). The header file
gfdefs.h is also located there.
8/91 Page 3