1.\" $OpenBSD: opendev.3,v 1.17 2007/05/31 19:19:38 jmc Exp $ 2.\" 3.\" Copyright (c) 2000, Todd C. Miller. All rights reserved. 4.\" Copyright (c) 1996, Jason Downs. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS 16.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18.\" DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, 19.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25.\" SUCH DAMAGE. 26.\" 27.Dd $Mdocdate: May 31 2007 $ 28.Dt OPENDEV 3 29.Os 30.Sh NAME 31.Nm opendev 32.Nd short form device open routine 33.Sh SYNOPSIS 34.Fd #include <util.h> 35.Ft int 36.Fn opendev "char *path" "int oflags" "int dflags" "char **realpath" 37.Sh DESCRIPTION 38The 39.Fn opendev 40function opens a device using the 41.Dq short form 42name. 43This is typically 44.Dq sd0 45or 46.Dq sd0c , 47for instance, which will be expanded to 48.Pa /dev/rsd0c 49on most architectures. 50.Pp 51Device name lookup is done by first checking 52.Fa path 53for a 54.Dq / 55and if one is found attempting to open that file. 56Otherwise 57.Fa /dev 58is searched for a matching device. 59.Pp 60The 61.Fa oflags 62are the same as the 63.Fa flags 64passed to 65.Xr open 2 . 66.Pp 67The 68.Fa dflags 69are specified by 70.Tn OR Ns 'ing 71the following values: 72.Bd -literal -offset indent 73OPENDEV_PART attempt to open the raw partition during expansion 74OPENDEV_BLCK open the block device (default is character device) 75.Ed 76.Pp 77If 78.Fa realpath 79is not 80.Dv NULL , 81it is modified to point at the fully expanded device name. 82.Sh RETURN VALUES 83The 84.Fn opendev 85return value and errors are the same as the return value and errors of 86.Xr open 2 . 87.Sh WARNINGS 88If 89.Fa realpath 90is not 91.Dv NULL , 92on return it will point to internal 93static storage space that will be overwritten by subsequent calls. 94.Sh SEE ALSO 95.Xr open 2 , 96.Xr getrawpartition 3 97.Sh HISTORY 98The 99.Fn opendev 100function first appeared in 101.Ox 1.2 . 102