worm(7) — SPECIAL FILES AND DEVICES
NAME
worm − WORM device support
DESRIPTION
WORM drives perform like hard disk drives except for the following:
A block may only be written once.
Each block on the medium may only be written once. An attempt to write an already written block should result in a error being returned with an errno of ENOENT. Some WORM devices behave differently. Check the devices manual closely.
Reading a block that hasn’t been written results in an error.
An attempt to read a block that hasn’t been written will result in a error being returned with an errno of ENOENT.
Variable block sizes
WORM drives may have block sizes of 512 or 1024 bytes depending on the drive and medium being used. All raw transfers must be aligned on physical block boundaries and have a transfer byte count that is a multiple of the physical block size. If either of these conditions is not met, the I/O results in an error (EIO).
Slicing
The VTOC is automatically created by the SCSI driver and consists of two slices: slice zero and slice seven. Slice seven represents the whole disk as it does on all other disk type devices. Slice zero also represents the whole disk but is the slice of choice when manipulating data.
Door Locking
When no process currently has the WORM drive open and it is being opened for the first time, the media-eject button on the drive becomes disabled until the last close, if the WORM drive has a locking door.
Presence of Media
If there is no WORM in the drive, an open attempt results in an error (ENXIO).
IOCTL COMMANDS
WORMs support several ioctl(2) functions on the character or raw devices. These functions permit control beyond the normal open(2), close(2), read(2), and write(2) system calls. All ioctl(2) operations take the form ioctl (fildes, command, ∗arg). Any attempt to utilize ioctl(2) functions not listed below cause an EINVAL error to be returned.
The operations supported by WORMs are listed below in alphabetical order.
DKGETCFG
Get parameters associated with the disk and store them in the dkconfig structure referenced by arg. The disk is not accessed by this command.
DKGETINFO
Get parameters associated with the disk and store them in the dkblk0 structure referenced by arg. The disk is not accessed by this command.
DKGETSLC
Get the VTOC information for a disk and return the information in a structure of type struct motorola_vtoc (defined in sys/vtoc.h) referenced by arg. The disk is not accessed by this command.
DKINQUIRY
Return the SCSI INQUIRY data for the device; it is only valid for SCSI WORMs. This ioctl can be done on any device that the calling process has open. The SCSI INQUIRY data for the device is copied into the struct inquiry structure pointed to by arg. The struct inquiry structure is defined in sys/dk.h.
DKREADCAP
Return the SCSI READ CAPACITY data for the device; it is only valid for SCSI WORMs. This ioctl can be done on any disk or WORM device that the calling process has open. The SCSI READ CAPACITY data for the device is copied into the struct readcap structure pointed to by arg. The struct readcap structure is defined in sys/dk.h. Note that the SCSI READ CAPACITY command returns the number of the last logical block on the media.
DKTRAY_OPEN
Cause the WORM door to open after processing the last close (when no process has the drive open). The arg parameter is not used.
V_GETSSZ
Return the physical sector size of the WORM. The arg parameter specifies a structure of type io_arg (defined in sys/vtoc.h). The sectst and datasz members of the io_arg structure are ignored. The memaddr member of the structure points to the address of an integer which contains the sector size after a successful operation.
V_PDREAD
Read the Physical Description Area of the disk. The arg parameter specifies a structure of type io_arg (defined in sys/vtoc.h). The sectst and datasz members of the io_arg structure are ignored. The memaddr member of the io_arg structure points to the address of a structure of type pdsector (defined in sys/vtoc.h) which contain the requested data upon successful completion.
V_PDWRITE
Write the Physical Description Area of the disk. This command always returns EINVAL.
V_PREAD
Read physical sectors. This interface assumes that sectors are 512 bytes in length so the driver is responsible for mapping the requested block(s) to the correct portion of the correct sector on the WORM regardless of the actual physical sector size. The arg parameter specifies a structure of type io_arg (defined in sys/vtoc.h). The sectst member of the io_arg structure contains the starting sector number and the datasz member contains the number of sectors. The memaddr member of the io_arg structure points to the address of a sufficiently large area which contains the requested data upon successful completion.
V_PWRITE
Write physical sectors. This command always returns EROFS. The arg parameter specifies a structure of type io_arg (defined in sys/vtoc.h).
V_RVTOC
Read the VTOC from the disk. The arg parameter specifies a structure of type io_arg (defined in sys/vtoc.h). The sectst and datasz members of the io_arg structure are ignored. The memaddr member of the io_arg structure points to the address of a structure of type vtoc (defined in sys/vtoc.h) which contains the requested data upon successful completion.
V_WVTOC
Write the VTOC to the disk. This command always returns EINVAL. The arg parameter specifies a structure of type vtoc (defined in sys/vtoc.h).