From owner-freebsd-hackers Thu May 9 14:16:12 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id OAA19352 for hackers-outgoing; Thu, 9 May 1996 14:16:12 -0700 (PDT) Received: from eac.iafrica.com (slipper119229.iafrica.com [196.7.119.229]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id OAA19259 for ; Thu, 9 May 1996 14:15:46 -0700 (PDT) Received: (from rnordier@localhost) by eac.iafrica.com (8.6.12/8.6.12) id XAA02591 for hackers@freebsd.org; Thu, 9 May 1996 23:14:49 +0200 From: Robert Nordier Message-Id: <199605092114.XAA02591@eac.iafrica.com> Subject: [Q] Raw interface to block devices To: hackers@freebsd.org Date: Thu, 9 May 1996 23:14:48 +0200 (SAT) X-Mailer: ELM [version 2.4 PL24 ME8a] Content-Type: text Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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} This tries to ensure we are not dealing with (say) '/dev/tty'; and to come up with the device name needed. However, something like ln -s /dev/fd0 floppy causes problems. There must be a better way to do this. The stuff I've looked at either trustingly waits forever on '/dev/tty', or refuses to even consider 'floppy'. Surely a library function is needed (or already exists). -- Robert Nordier