Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 May 1996 11:21:39 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        hackers@FreeBSD.ORG, rnordier@iafrica.com
Subject:   Re: [Q] Raw interface to block devices
Message-ID:  <199605100121.LAA20111@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>I have a function

>   int process(const char *fs);

>which expects 'fs' to refer to a device which may hold a filesystem.

>The function actually works with the raw device, but allows the
>user some flexibility.  Eg:

>   process("/dev/rfd0"); or
>   process("/dev/fd0");

>An obvious, though clumsy, approach is:

>   stat()
>   if {S_IFCHR, S_IFBLK}
>      derive the other name by deleting/inserting an 'r' somewhere
>      stat()
>      check for (reversed) {S_IFCHR, S_IFBLK}

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.

devname() seems to be used only in ps and pstat.  It should be used in
badsect, fsck ... (fsck has its own functions rawname() and unrawname()).

ps has a bogus private copy of /usr/src/lib/libc/gen/devname.c.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605100121.LAA20111>