removed
This commit is contained in:
parent
12fdfd7b84
commit
e8c03de42b
2 changed files with 0 additions and 365 deletions
177
man/man3/disk.3
177
man/man3/disk.3
|
|
@ -1,177 +0,0 @@
|
||||||
.TH DISK 3
|
|
||||||
.SH NAME
|
|
||||||
opendisk, Disk \- generic disk device interface
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.ft L
|
|
||||||
#include <u.h>
|
|
||||||
#include <libc.h>
|
|
||||||
#include <disk.h>
|
|
||||||
.ft
|
|
||||||
.PP
|
|
||||||
.ft L
|
|
||||||
typedef struct Disk {
|
|
||||||
char *prefix;
|
|
||||||
char part[NAMELEN];
|
|
||||||
int fd, wfd, ctlfd, rdonly;
|
|
||||||
int type;
|
|
||||||
vlong secs, secsize, size, offset;
|
|
||||||
int c, h, s;
|
|
||||||
} Disk;
|
|
||||||
.ft
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
Disk* opendisk(char *file, int rdonly, int noctl)
|
|
||||||
.SH DESCRIPTION
|
|
||||||
These routines provide a simple way to gather
|
|
||||||
and use information about
|
|
||||||
disks and disk partitions,
|
|
||||||
as well as plain files.
|
|
||||||
.PP
|
|
||||||
.I Opendisk
|
|
||||||
opens
|
|
||||||
.I file
|
|
||||||
for reading and stores the file descriptor in
|
|
||||||
the
|
|
||||||
.B fd
|
|
||||||
field of the
|
|
||||||
.B Disk
|
|
||||||
structure.
|
|
||||||
If
|
|
||||||
.I rdonly
|
|
||||||
is not set,
|
|
||||||
.I opendisk
|
|
||||||
also opens
|
|
||||||
.I file
|
|
||||||
for writing and stores that file descriptor in
|
|
||||||
.BR wfd .
|
|
||||||
The two file descriptors are kept separate to
|
|
||||||
help prevent accidents.
|
|
||||||
.PP
|
|
||||||
If
|
|
||||||
.I noctl
|
|
||||||
is not set,
|
|
||||||
.I opendisk
|
|
||||||
looks for a
|
|
||||||
.B ctl
|
|
||||||
file in the same directory as the
|
|
||||||
disk file;
|
|
||||||
if it finds one, it declares
|
|
||||||
the disk to be
|
|
||||||
an
|
|
||||||
.I sd
|
|
||||||
device,
|
|
||||||
setting the
|
|
||||||
.B type
|
|
||||||
field in the
|
|
||||||
.B Disk
|
|
||||||
structure
|
|
||||||
to
|
|
||||||
.BR Tsd .
|
|
||||||
If the passed
|
|
||||||
.I file
|
|
||||||
is named
|
|
||||||
.BI fd n disk \fR,
|
|
||||||
it looks for a file
|
|
||||||
.BI fd n ctl \fR,
|
|
||||||
and if it finds that,
|
|
||||||
declares the disk to be
|
|
||||||
a floppy disk, of type
|
|
||||||
.BR Tfloppy .
|
|
||||||
If either
|
|
||||||
control
|
|
||||||
file is found, it is opened for reading
|
|
||||||
and writing, and the resulting file descriptor
|
|
||||||
is saved as
|
|
||||||
.BR ctlfd .
|
|
||||||
Otherwise the returned disk
|
|
||||||
has type
|
|
||||||
.BR Tfile .
|
|
||||||
.PP
|
|
||||||
.I Opendisk
|
|
||||||
then stats the file and stores its length in
|
|
||||||
.BR size .
|
|
||||||
If the disk is an
|
|
||||||
.I sd
|
|
||||||
partition,
|
|
||||||
.I opendisk
|
|
||||||
reads the sector size from the
|
|
||||||
control
|
|
||||||
file and stores it in
|
|
||||||
.BR secsize ;
|
|
||||||
otherwise the sector size is assumed to be 512,
|
|
||||||
as is the case for floppy disks.
|
|
||||||
.I Opendisk
|
|
||||||
then stores the disk size measured in sectors in
|
|
||||||
.BR secs .
|
|
||||||
.PP
|
|
||||||
If the disk is an
|
|
||||||
.I sd
|
|
||||||
partition,
|
|
||||||
.I opendisk
|
|
||||||
parses the
|
|
||||||
control
|
|
||||||
file to find the partition's offset
|
|
||||||
within its disk;
|
|
||||||
otherwise it sets
|
|
||||||
.B offset
|
|
||||||
to zero.
|
|
||||||
If the disk is an ATA disk,
|
|
||||||
.I opendisk
|
|
||||||
reads
|
|
||||||
the disk geometry (number of cylinders, heads, and sectors)
|
|
||||||
from the
|
|
||||||
.B geometry
|
|
||||||
line in the
|
|
||||||
.I sd
|
|
||||||
control file;
|
|
||||||
otherwise it sets these to zero as well.
|
|
||||||
.B Name
|
|
||||||
is initialized with the base name of
|
|
||||||
the disk partition, and is useful for forming messages to the
|
|
||||||
.I sd
|
|
||||||
control file.
|
|
||||||
.B Prefix
|
|
||||||
is set to the passed filename without
|
|
||||||
the
|
|
||||||
.B name
|
|
||||||
suffix.
|
|
||||||
.PP
|
|
||||||
The IBM PC BIOS interface allocates
|
|
||||||
10 bits for the number of cylinders, 8 for
|
|
||||||
the number of heads, and 6 for the number of sectors per track.
|
|
||||||
Disk geometries are not quite so simple
|
|
||||||
anymore, but to keep the interface useful,
|
|
||||||
modern disks and BIOSes present geometries
|
|
||||||
that still fit within these constraints.
|
|
||||||
These numbers are still used when partitioning
|
|
||||||
and formatting disks.
|
|
||||||
.I Opendisk
|
|
||||||
employs a number of heuristics to discover this
|
|
||||||
supposed geometry and store it in the
|
|
||||||
.BR c ,
|
|
||||||
.BR h ,
|
|
||||||
and
|
|
||||||
.B s
|
|
||||||
fields.
|
|
||||||
Disk offsets in partition tables and
|
|
||||||
in FAT descriptors are stored in a form
|
|
||||||
dependent upon these numbers, so
|
|
||||||
.I opendisk
|
|
||||||
works hard to report numbers that
|
|
||||||
agree with those used by other operating
|
|
||||||
systems; the numbers bear little or no resemblance
|
|
||||||
to reality.
|
|
||||||
.SH SOURCE
|
|
||||||
.B \*9/src/libdisk/disk.c
|
|
||||||
.SH SEE ALSO
|
|
||||||
Plan 9's
|
|
||||||
\fIfloppy\fR(3) and \fIsd\fR(3)
|
|
||||||
.SH BUGS
|
|
||||||
Disks on Unix systems do not present the interface
|
|
||||||
that
|
|
||||||
.I opendisk
|
|
||||||
expects, so
|
|
||||||
.I opendisk
|
|
||||||
will give them type
|
|
||||||
.BR Tfile .
|
|
||||||
188
man/man3/scsi.3
188
man/man3/scsi.3
|
|
@ -1,188 +0,0 @@
|
||||||
.TH SCSI 3
|
|
||||||
.SH NAME
|
|
||||||
openscsi, scsiready, scsi, scsicmd, scsierror \- SCSI device operations
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.nf
|
|
||||||
.ft L
|
|
||||||
#include <u.h>
|
|
||||||
#include <libc.h>
|
|
||||||
#include <disk.h>
|
|
||||||
.ft
|
|
||||||
.PP
|
|
||||||
.ft L
|
|
||||||
typedef struct Scsi {
|
|
||||||
char *inquire;
|
|
||||||
int rawfd;
|
|
||||||
int nchange;
|
|
||||||
ulong changetime;
|
|
||||||
};
|
|
||||||
.ft
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
Scsi* openscsi(char *devdir)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
void closescsi(Scsi *s)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int scsiready(Scsi *s)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int scsi(Scsi *s, uchar *cmd, int ncmd,
|
|
||||||
.br
|
|
||||||
void *data, int ndata, int dir)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int scsicmd(Scsi *s, uchar *cmd, int ncmd,
|
|
||||||
.br
|
|
||||||
void *data, int ndata, int dir)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
char* scsierror(int asc, int ascq)
|
|
||||||
.PP
|
|
||||||
.B
|
|
||||||
int scsiverbose;
|
|
||||||
.SH DESCRIPTION
|
|
||||||
These routines provide an interface
|
|
||||||
to a SCSI or ATAPI device via Plan 9's
|
|
||||||
\fIsd\fR(3).
|
|
||||||
.PP
|
|
||||||
.I Openscsi
|
|
||||||
attempts to open the file
|
|
||||||
.IB devdir /raw
|
|
||||||
and use it to send raw SCSI commands.
|
|
||||||
On success, it reads the device's inquiry
|
|
||||||
string and stores it in in returned
|
|
||||||
.B Scsi
|
|
||||||
structure.
|
|
||||||
.I Closescsi
|
|
||||||
closes the connection and frees the
|
|
||||||
.B Scsi
|
|
||||||
structure.
|
|
||||||
.PP
|
|
||||||
.I Scsiready
|
|
||||||
sends the ``unit ready'' command up to three times,
|
|
||||||
returning zero if the unit responds that it is ready,
|
|
||||||
or \-1 on error.
|
|
||||||
.PP
|
|
||||||
.I Scsierror
|
|
||||||
returns a textual description of the SCSI status
|
|
||||||
denoted by the ASC and ASCQ sense codes.
|
|
||||||
The description is found by consulting
|
|
||||||
.BR /sys/lib/scsicodes .
|
|
||||||
The returned string will be overwritten by
|
|
||||||
the next call to
|
|
||||||
.IR scsierror .
|
|
||||||
.PP
|
|
||||||
.I Scsi
|
|
||||||
and
|
|
||||||
.I scsicmd
|
|
||||||
execute a single SCSI command on the named device.
|
|
||||||
There should be
|
|
||||||
.I ncmd
|
|
||||||
bytes of
|
|
||||||
command data in
|
|
||||||
.IR cmd ;
|
|
||||||
if
|
|
||||||
.I dir
|
|
||||||
is
|
|
||||||
.BR Sread ,
|
|
||||||
a successful operation
|
|
||||||
will store up to
|
|
||||||
.I ndata
|
|
||||||
bytes into
|
|
||||||
.IR data ,
|
|
||||||
returning the number of bytes stored.
|
|
||||||
If
|
|
||||||
.I dir
|
|
||||||
is
|
|
||||||
.BR Swrite ,
|
|
||||||
the
|
|
||||||
.I ndata
|
|
||||||
bytes beginning at
|
|
||||||
.I data
|
|
||||||
are transmitted as the data argument to
|
|
||||||
the command, and the
|
|
||||||
number of bytes written is returned.
|
|
||||||
If
|
|
||||||
.I dir
|
|
||||||
is
|
|
||||||
.BR Snone ,
|
|
||||||
.I data
|
|
||||||
and
|
|
||||||
.I ndata
|
|
||||||
are ignored.
|
|
||||||
On error,
|
|
||||||
.I scsi
|
|
||||||
and
|
|
||||||
.I scsicmd
|
|
||||||
return \-1.
|
|
||||||
.I Scsicmd
|
|
||||||
simply issues the command and
|
|
||||||
returns the result;
|
|
||||||
.I scsi
|
|
||||||
works a bit harder and
|
|
||||||
is the more commonly used routine.
|
|
||||||
.I Scsi
|
|
||||||
attempts to send the command;
|
|
||||||
if it is successful,
|
|
||||||
.I scsi
|
|
||||||
returns what
|
|
||||||
.I scsicmd
|
|
||||||
returned.
|
|
||||||
Otherwise,
|
|
||||||
.I scsi
|
|
||||||
sends a request sense command to
|
|
||||||
obtain the reason for the failure,
|
|
||||||
sends a unit ready command in
|
|
||||||
an attempt to bring the unit out of any
|
|
||||||
inconsistent states, and tries again.
|
|
||||||
If the second try fails,
|
|
||||||
.I scsi
|
|
||||||
sends the request
|
|
||||||
sense and unit ready commands
|
|
||||||
again
|
|
||||||
and then uses
|
|
||||||
.I scsierror
|
|
||||||
to set
|
|
||||||
.I errstr
|
|
||||||
with a reason for failure.
|
|
||||||
.PP
|
|
||||||
The
|
|
||||||
.B nchange
|
|
||||||
and
|
|
||||||
.B changetime
|
|
||||||
fields
|
|
||||||
in the
|
|
||||||
.B Scsi
|
|
||||||
structure
|
|
||||||
record the number of times a media
|
|
||||||
change has been detected, and the
|
|
||||||
time when the current media was
|
|
||||||
inserted into the drive (really the
|
|
||||||
first time a SCSI command was issued
|
|
||||||
after it was inserted).
|
|
||||||
They are maintained by
|
|
||||||
.IR scsi .
|
|
||||||
.PP
|
|
||||||
If
|
|
||||||
.I scsiverbose
|
|
||||||
is set,
|
|
||||||
these commands will produce a fair
|
|
||||||
amount of debugging output on file descriptor 2
|
|
||||||
when SCSI commands fail.
|
|
||||||
.SH FILES
|
|
||||||
.TP
|
|
||||||
.B /sys/lib/scsicodes
|
|
||||||
List of textual messages corresponding to SCSI error codes;
|
|
||||||
consulted by
|
|
||||||
.BR scsierror .
|
|
||||||
.SH SOURCE
|
|
||||||
.B \*9/src/libdisk/scsi.c
|
|
||||||
.SH SEE ALSO
|
|
||||||
Plan 9's
|
|
||||||
\fIsd\fR(3) and
|
|
||||||
\fIscuzz\fR(8)
|
|
||||||
.SH BUGS
|
|
||||||
SCSI devices on Unix do not present the interface expected by
|
|
||||||
these routines.
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue