1.\" Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.Dd August 3, 2017 26.Dt MAKEDEV 3 27.Os 28.Sh NAME 29.Nm makedev , 30.Nm major , 31.Nm minor 32.Nd device number conversion 33.Sh SYNOPSIS 34.In sys/types.h 35.Ft dev_t 36.Fn makedev "int major" "int minor" 37.Ft int 38.Fn major "dev_t dev" 39.Ft int 40.Fn minor "dev_t dev" 41.Sh DESCRIPTION 42The 43.Fn makedev 44macro returns a device number created from the provided 45.Fa major 46and 47.Fa minor 48number. 49The 50.Fn major 51and 52.Fn minor 53macros return the original numbers from the device number 54.Fa dev . 55In other words, for a value 56.Va dev 57of the type 58.Vt dev_t , 59and values 60.Va ma , mi 61of the type 62.Vt int , 63the assertions 64.Dl dev == makedev(major(dev), minor(dev)) 65.Dl ma == major(makedev(ma, mi)) 66.Dl mi == minor(makedev(ma, mi)) 67are valid. 68.Pp 69In previous implementations of 70.Fx 71all block and character devices were uniquely identified by a pair of 72stable major and minor numbers. 73The major number referred to a certain device class (e.g. disks, TTYs) 74while the minor number identified an instance within the device class. 75Later versions of 76.Fx 77automatically generate a unique device number for each character device 78visible in 79.Pa /dev/ . 80These numbers are not divided in device classes and are not guaranteed 81to be stable upon reboot or driver reload. 82.Pp 83On 84.Fx 85these macros are only used by utilities that need to exchange numbers 86with other operating systems that may use different encodings for 87.Vt dev_t , 88but also applications that present these numbers to the user in a more 89conventional way. 90.Sh RETURN VALUES 91The 92.Fn major 93and 94.Fn minor 95macros return numbers whose value can span the complete range of an 96.Vt int . 97.Sh SEE ALSO 98.Xr mknod 2 , 99.Xr devname 3 , 100.Xr devfs 5 101