*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->OpenBSD man pages -> bounds_check_with_label (9)              
Title
Content
Arch
Section
 

DISKLABEL(9)

Contents


NAME    [Toc]    [Back]

     disklabel, readdisklabel, writedisklabel, setdisklabel,
     bounds_check_with_label - disk label management routines

SYNOPSIS    [Toc]    [Back]

     char *
     readdisklabel(dev_t dev, void (*strat)(struct buf *),
             struct disklabel *lp, struct cpu_disklabel *osdep,
             int spoofonly);

     int
     writedisklabel(dev_t dev, void (*strat)(struct buf *),
             struct disklabel *lp, struct cpu_disklabel *osdep);

     int
     setdisklabel(struct disklabel *olp, struct disklabel *nlp,
             u_long openmask, struct cpu_disklabel *osdep);

     int
     bounds_check_with_label(struct  buf  *bp,  struct  disklabel
*lp,
             struct cpu_disklabel *osdep, int wlabel);

DESCRIPTION    [Toc]    [Back]

     This  collection of routines provides a disklabel management
interface to
     kernel device drivers.  These routines are classified as machine- or architecture-dependent
  because of restrictions imposed by the
machine architecture
 and boot-strapping code on the  location  of  the
label, or because
 cooperation with other operating systems requires specialized conversion
 code.

     readdisklabel() attempts to read a disklabel from the device
identified
     by  dev,  using the device strategy routine passed in strat.
Note that a
     buffer structure is required to pass to  the  strategy  routine; it needs to
     be acquired and parametrized for the intended I/O operation,
and disposed
     of when the operation has completed.   Some  fields  in  the
disklabel passed
     in  lp may be pre-initialized by the caller in order to meet
device driver
     requirements for the I/O operation initiated to get  to  the
disklabel data
     on  the  medium.  In particular, the field ``d_secsize'', if
non-zero, is
     used by readdisklabel() to get an appropriately sized buffer
to pass to
     the  device  strategy  routine.   Unspecified  fields  in lp
should be set to
     zero.  If the medium does not  contain  a  native  disklabel
that can be read
     in   directly   or  spoofonly  argument  is  a  true  value,
readdisklabel() may
     resort to constructing a label from other  machine-dependent
information
     using  the provided buffer passed in the osdep argument.  If
a disk label
     can not be found or constructed, a string containing an  approximated description
  of  the  failure mode is returned.  Otherwise the
NULL string is
     returned.

     writedisklabel() stores disk label information contained  in
the disk label
  structure  given by lp on the device identified by dev.
Like
     readdisklabel(), it acquires and sets up an  I/O  buffer  to
pass to the
     strategy  routine strat.  writedisklabel() may elect to do a
machine-dependent
 conversion of the native disk label structure (using
the buffer
     pointed at by osdep), to store the disk label onto the medium in a format
     complying with architectural constraints.   writedisklabel()
returns 0 on
     success  and  EINVAL  if the disk label specifies invalid or
unconvertible
     values.  Otherwise, any error condition reported by the  device strategy
     routine in the buffer's ``b_error'' field is returned.

     setdisklabel()  checks  a  proposed new disk label passed in
nlp for some
     amount of basic sanity.  This includes a check  on  attempts
to change the
     location,  or reduce the size, of an existing disk partition
that is currently
 in use by the system.  The current disposition of the
disk partitions
 is made available through olp and openmask, which provide, respectively,
 the existing disk label and a bit  mask  identifying
the partitions
     that are currently in use.  Failure to pass on ``basic sanity'', results
     in a EINVAL return value, while a vetoed update of the  partition layout
     is  signalled  by a EBUSY return value.  Otherwise, 0 is returned.

     bounds_check_with_label() is used to check whether a  device
transfer described
  by  bp to the device identified by dev, is properly
contained
     within a disk partition of the disk with label lp.  If  this
check fails,
     bounds_check_with_label()   sets  the  buffer's  ``b_error''
field to EINVAL
     and sets the B_ERROR flag in ``b_flags''.  If  the  argument
wlabel is zero,
  and  the transfer is a write operation, a check is done
if the transfer
 would overwrite (a portion of) the disklabel area on the
medium.  If
     that  is the case, EROFS is set in ``b_error'' and the B_ERROR flag is set
     in ``b_flags''.  Note that wlabel should be set to a non-zero value if
     the  intended operation is expected to install or update the
disk label.
     Programs that intend to do so using the raw device interface
should notify
  the driver by using a DIOCWLABEL ioctl function.  A zero
value is returned
 if any of the bound checks failed or transfer was attempted exactly
  at  the end of disk partition.  Otherwise the value of 1
is returned.

SEE ALSO    [Toc]    [Back]

      
      
     disklabel(5), disklabel(8), fdisk(8)

OpenBSD     3.6                        December     26,      1996
[ Back ]
 Similar pages
Name OS Title
disklabel Tru64 Reads and writes a disk pack label and formats disk partitions
createlabel Tru64 creates a disk label structure for a disk device
set_usage Tru64 checks whether a disk partition is in use and sets the fstype of the partition in the disk label
disklabel Tru64 Disk pack label
disklabel OpenBSD disk pack label
disklabel FreeBSD read and write disk pack label
disklabel OpenBSD read and write disk pack label
bsdlabel FreeBSD read and write disk pack label
amutil HP-UX controls various disk array management functions
gbde FreeBSD operation and management utility for Geom Based Disk Encryption
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service