1*0c3983b2SBen Gras.\" $NetBSD: opendisk.3,v 1.11 2008/04/30 13:10:52 martin Exp $ 2*0c3983b2SBen Gras.\" 3*0c3983b2SBen Gras.\" Copyright (c) 1997, 2001 The NetBSD Foundation, Inc. 4*0c3983b2SBen Gras.\" All rights reserved. 5*0c3983b2SBen Gras.\" 6*0c3983b2SBen Gras.\" This code is derived from software contributed to The NetBSD Foundation 7*0c3983b2SBen Gras.\" by Luke Mewburn. 8*0c3983b2SBen Gras.\" 9*0c3983b2SBen Gras.\" Redistribution and use in source and binary forms, with or without 10*0c3983b2SBen Gras.\" modification, are permitted provided that the following conditions 11*0c3983b2SBen Gras.\" are met: 12*0c3983b2SBen Gras.\" 1. Redistributions of source code must retain the above copyright 13*0c3983b2SBen Gras.\" notice, this list of conditions and the following disclaimer. 14*0c3983b2SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright 15*0c3983b2SBen Gras.\" notice, this list of conditions and the following disclaimer in the 16*0c3983b2SBen Gras.\" documentation and/or other materials provided with the distribution. 17*0c3983b2SBen Gras.\" 18*0c3983b2SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19*0c3983b2SBen Gras.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20*0c3983b2SBen Gras.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21*0c3983b2SBen Gras.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22*0c3983b2SBen Gras.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*0c3983b2SBen Gras.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*0c3983b2SBen Gras.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*0c3983b2SBen Gras.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*0c3983b2SBen Gras.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*0c3983b2SBen Gras.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*0c3983b2SBen Gras.\" POSSIBILITY OF SUCH DAMAGE. 29*0c3983b2SBen Gras.\" 30*0c3983b2SBen Gras.Dd December 11, 2001 31*0c3983b2SBen Gras.Dt OPENDISK 3 32*0c3983b2SBen Gras.Os 33*0c3983b2SBen Gras.Sh NAME 34*0c3983b2SBen Gras.Nm opendisk 35*0c3983b2SBen Gras.Nd open a disk partition 36*0c3983b2SBen Gras.Sh LIBRARY 37*0c3983b2SBen Gras.Lb libutil 38*0c3983b2SBen Gras.Sh SYNOPSIS 39*0c3983b2SBen Gras.In util.h 40*0c3983b2SBen Gras.Ft int 41*0c3983b2SBen Gras.Fo opendisk 42*0c3983b2SBen Gras.Fa "const char *path" 43*0c3983b2SBen Gras.Fa "int flags" 44*0c3983b2SBen Gras.Fa "char *buf" 45*0c3983b2SBen Gras.Fa "size_t buflen" 46*0c3983b2SBen Gras.Fa "int iscooked" 47*0c3983b2SBen Gras.Fc 48*0c3983b2SBen Gras.Sh DESCRIPTION 49*0c3983b2SBen Gras.Fn opendisk 50*0c3983b2SBen Grasopens 51*0c3983b2SBen Gras.Fa path , 52*0c3983b2SBen Grasfor reading and/or writing as specified by the argument 53*0c3983b2SBen Gras.Fa flags 54*0c3983b2SBen Grasusing 55*0c3983b2SBen Gras.Xr open 2 , 56*0c3983b2SBen Grasand the file descriptor is returned to the caller. 57*0c3983b2SBen Gras.Fa buf 58*0c3983b2SBen Grasis used to store the resultant filename. 59*0c3983b2SBen Gras.Fa buflen 60*0c3983b2SBen Grasis the size, in bytes, of the array referenced by 61*0c3983b2SBen Gras.Fa buf 62*0c3983b2SBen Gras(usually 63*0c3983b2SBen Gras.Dv MAXPATHLEN 64*0c3983b2SBen Grasbytes). 65*0c3983b2SBen Gras.Fa iscooked 66*0c3983b2SBen Grascontrols which paths in 67*0c3983b2SBen Gras.Pa /dev 68*0c3983b2SBen Grasare tried. 69*0c3983b2SBen Gras.Pp 70*0c3983b2SBen Gras.Fn opendisk 71*0c3983b2SBen Grasattempts to open the following variations of 72*0c3983b2SBen Gras.Fa path , 73*0c3983b2SBen Grasin order: 74*0c3983b2SBen Gras.Bl -tag -width "/dev/rpathX" 75*0c3983b2SBen Gras.It Pa path 76*0c3983b2SBen GrasThe pathname as given. 77*0c3983b2SBen Gras.It Pa path Ns Em X 78*0c3983b2SBen Gras.Fa path 79*0c3983b2SBen Graswith a suffix of 80*0c3983b2SBen Gras.Sq Em X , 81*0c3983b2SBen Graswhere 82*0c3983b2SBen Gras.Sq Em X 83*0c3983b2SBen Grasrepresents the raw partition of the device, as determined by 84*0c3983b2SBen Gras.Xr getrawpartition 3 , 85*0c3983b2SBen Grasusually 86*0c3983b2SBen Gras.Dq c . 87*0c3983b2SBen Gras.El 88*0c3983b2SBen Gras.Pp 89*0c3983b2SBen GrasIf 90*0c3983b2SBen Gras.Fa path 91*0c3983b2SBen Grasdoes not contain a 92*0c3983b2SBen Grasslash 93*0c3983b2SBen Gras.Pq Dq / , 94*0c3983b2SBen Grasthe following variations are attempted: 95*0c3983b2SBen Gras.Pp 96*0c3983b2SBen Gras.Bl -dash -offset indent 97*0c3983b2SBen Gras.It 98*0c3983b2SBen GrasIf 99*0c3983b2SBen Gras.Fa iscooked 100*0c3983b2SBen Grasis zero: 101*0c3983b2SBen Gras.Pp 102*0c3983b2SBen Gras.Bl -tag -width "/dev/rpathX" 103*0c3983b2SBen Gras.It Pa /dev/rpath 104*0c3983b2SBen Gras.Fa path 105*0c3983b2SBen Graswith a prefix of 106*0c3983b2SBen Gras.Dq Pa /dev/r . 107*0c3983b2SBen Gras.It Pa /dev/rpath Ns Em X 108*0c3983b2SBen Gras.Fa path 109*0c3983b2SBen Graswith a prefix of 110*0c3983b2SBen Gras.Dq Pa /dev/r 111*0c3983b2SBen Grasand a suffix of 112*0c3983b2SBen Gras.Sq Em X 113*0c3983b2SBen Gras(q.v.). 114*0c3983b2SBen Gras.El 115*0c3983b2SBen Gras.It 116*0c3983b2SBen GrasIf 117*0c3983b2SBen Gras.Fa iscooked 118*0c3983b2SBen Grasis non-zero: 119*0c3983b2SBen Gras.Bl -tag -width "/dev/rpathX" 120*0c3983b2SBen Gras.It Pa /dev/path 121*0c3983b2SBen Gras.Fa path 122*0c3983b2SBen Graswith a prefix of 123*0c3983b2SBen Gras.Dq Pa /dev/ . 124*0c3983b2SBen Gras.It Pa /dev/path Ns Em X 125*0c3983b2SBen Gras.Fa path 126*0c3983b2SBen Graswith a prefix of 127*0c3983b2SBen Gras.Dq Pa /dev/ 128*0c3983b2SBen Grasand a suffix of 129*0c3983b2SBen Gras.Sq Em X 130*0c3983b2SBen Gras(q.v.). 131*0c3983b2SBen Gras.El 132*0c3983b2SBen Gras.El 133*0c3983b2SBen Gras.Sh RETURN VALUES 134*0c3983b2SBen GrasAn open file descriptor, or -1 if the 135*0c3983b2SBen Gras.Xr open 2 136*0c3983b2SBen Grasfailed. 137*0c3983b2SBen Gras.Sh ERRORS 138*0c3983b2SBen Gras.Fn opendisk 139*0c3983b2SBen Grasmay set 140*0c3983b2SBen Gras.Va errno 141*0c3983b2SBen Grasto one of the following values: 142*0c3983b2SBen Gras.Bl -tag -width Er 143*0c3983b2SBen Gras.It Bq Er EINVAL 144*0c3983b2SBen Gras.Dv O_CREAT 145*0c3983b2SBen Graswas set in 146*0c3983b2SBen Gras.Fa flags , 147*0c3983b2SBen Grasor 148*0c3983b2SBen Gras.Xr getrawpartition 3 149*0c3983b2SBen Grasdidn't return a valid partition. 150*0c3983b2SBen Gras.It Bq Er EFAULT 151*0c3983b2SBen Gras.Fa buf 152*0c3983b2SBen Graswas the 153*0c3983b2SBen Gras.Dv NULL 154*0c3983b2SBen Graspointer. 155*0c3983b2SBen Gras.El 156*0c3983b2SBen Gras.Pp 157*0c3983b2SBen GrasThe 158*0c3983b2SBen Gras.Fn opendisk 159*0c3983b2SBen Grasfunction 160*0c3983b2SBen Grasmay also set 161*0c3983b2SBen Gras.Va errno 162*0c3983b2SBen Grasto any value specified by the 163*0c3983b2SBen Gras.Xr open 2 164*0c3983b2SBen Grasfunction. 165*0c3983b2SBen Gras.Sh SEE ALSO 166*0c3983b2SBen Gras.Xr open 2 , 167*0c3983b2SBen Gras.Xr getrawpartition 3 168*0c3983b2SBen Gras.Sh HISTORY 169*0c3983b2SBen GrasThe 170*0c3983b2SBen Gras.Fn opendisk 171*0c3983b2SBen Grasfunction first appeared in 172*0c3983b2SBen Gras.Nx 1.3 . 173