From owner-svn-src-head@freebsd.org Thu Aug 3 07:57:54 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 802CEDCF6A7; Thu, 3 Aug 2017 07:57:54 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 23F896C01C; Thu, 3 Aug 2017 07:57:53 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v737vmOh094754 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 3 Aug 2017 10:57:48 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v737vmOh094754 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v737vlGd094752; Thu, 3 Aug 2017 10:57:47 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 3 Aug 2017 10:57:47 +0300 From: Konstantin Belousov To: Bruce Evans Cc: Hans Petter Selasky , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r321920 - head/sys/sys Message-ID: <20170803075747.GJ1700@kib.kiev.ua> References: <201708021014.v72AEHEk061037@repo.freebsd.org> <37abc595-c80e-a8da-04a8-815f42c634de@selasky.org> <20170802135455.GG1700@kib.kiev.ua> <20170803122015.Q1093@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170803122015.Q1093@besplex.bde.org> User-Agent: Mutt/1.8.3 (2017-05-23) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Aug 2017 07:57:54 -0000 On Thu, Aug 03, 2017 at 01:21:56PM +1000, Bruce Evans wrote: > It would be better to remove the comments. > > makedev() actually has a man page (a FreeBSD addition makedev(3)). > This could have been better, and is now out of date. The largest error > is that major() is still documented to return a value between 0 and > 255. This reduction prevented makedev() being the inverse of > major()+minor() on arbitrary args. The man page doesn't claim that > it is, and barely gives a hint that makedev() can be used to synthesize > a dev_t from (x, y) provided 0 <= x <= 255. See below. diff --git a/share/man/man3/makedev.3 b/share/man/man3/makedev.3 index 87ca953dc79..a54d0590bc5 100644 --- a/share/man/man3/makedev.3 +++ b/share/man/man3/makedev.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 28, 2008 +.Dd August 3, 2017 .Dt MAKEDEV 3 .Os .Sh NAME @@ -54,11 +54,18 @@ and .Fn minor macros can be used to obtain the original numbers from the device number .Fa dev . +In other words, for a value +.Va dev +of the type +.Vt dev_t , +the assertion +.Dl dev == makedev(major(dev), minor(dev)) +is valid. .Pp In previous implementations of .Fx all block and character devices were uniquely identified by a pair of -major and minor numbers. +stable major and minor numbers. The major number referred to a certain device class (e.g. disks, TTYs) while the minor number identified an instance within the device class. Later versions of @@ -66,7 +73,8 @@ Later versions of automatically generate a unique device number for each character device visible in .Pa /dev/ . -These numbers are not divided in device classes. +These numbers are not divided in device classes and are not guaranteed +to be stable upon reboot or driver reload. .Pp On .Fx @@ -78,11 +86,9 @@ conventional way. .Sh RETURN VALUES The .Fn major -macro returns a device major number that has a value between 0 and 255. -The +and .Fn minor -macro returns a device minor number whose value can span the complete -range of an +macros return numbers whose value can span the complete range of an .Vt int . .Sh SEE ALSO .Xr mknod 2 , diff --git a/sys/sys/types.h b/sys/sys/types.h index 30a08724443..8ea6e146e08 100644 --- a/sys/sys/types.h +++ b/sys/sys/types.h @@ -364,9 +364,9 @@ __bitcount64(__uint64_t _x) #include -#define major(x) ((int)((dev_t)(x) >> 32)) /* major number */ -#define minor(x) ((int)((x) & 0xffffffff)) /* minor number */ -#define makedev(x, y) (((dev_t)(x) << 32) | (unsigned)(y)) /* create dev_t */ +#define major(x) ((int)((dev_t)(x) >> 32)) +#define minor(x) ((int)((x) & 0xffffffff)) +#define makedev(x, y) (((dev_t)(x) << 32) | (unsigned)(y)) /* * These declarations belong elsewhere, but are repeated here and in