From owner-freebsd-hackers Fri May 10 04:00:27 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id EAA09624 for hackers-outgoing; Fri, 10 May 1996 04:00:27 -0700 (PDT) Received: from eac.iafrica.com (h196-7-192-136.iafrica.com [196.7.192.136]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id EAA09616 for ; Fri, 10 May 1996 04:00:20 -0700 (PDT) Received: (from rnordier@localhost) by eac.iafrica.com (8.6.12/8.6.12) id MAA00520; Fri, 10 May 1996 12:49:55 +0200 From: Robert Nordier Message-Id: <199605101049.MAA00520@eac.iafrica.com> Subject: Re: [Q] Raw interface to block devices To: bde@zeta.org.au (Bruce Evans) Date: Fri, 10 May 1996 12:49:54 +0200 (SAT) Cc: hackers@freebsd.org In-Reply-To: <199605100747.RAA02365@godzilla.zeta.org.au> from "Bruce Evans" at May 10, 96 05:47:24 pm X-Mailer: ELM [version 2.4 PL24 ME8a] Content-Type: text Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Bruce Evans wrote: > > >> devname(3) seems to be almost what you want. You can stat the first name > >> to get the dev number and then call devname() to get the other name. It > >> searches quickly through all the names in /var/run/dev.db. > > >I've just tried that, and it seems to be _exactly_ what I want. :-) > > Actually, it is no help. It just does a fast search through /dev. It > doesn't support going from the bdev to the cdev or vice versa. It can't > support this because even the kernel barely knows the correspondence > between bdevs and cdevs. In -current, the bdevsw and cdevsw entries > contain pointers to each other. In -stable there is only the poorly > maintained chrtoblk() routine. Yes, it's a shame about to bdev <-> cdev mapping. Anyway, devname(3) does hand off some of the task to a library routine, and may allow the rest to be handled in a simple lookup table. Though, for portability, I suppose there is still something to be said for fiddling with the names themselves: /dev/[r]sd0a /dev/[r]dsk/0s0 -- Robert Nordier