From owner-freebsd-hackers Fri Jun 26 23:45:51 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id XAA23487 for freebsd-hackers-outgoing; Fri, 26 Jun 1998 23:45:51 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from smtp02.primenet.com (daemon@smtp02.primenet.com [206.165.6.132]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA23458 for ; Fri, 26 Jun 1998 23:45:39 -0700 (PDT) (envelope-from tlambert@usr08.primenet.com) Received: (from daemon@localhost) by smtp02.primenet.com (8.8.8/8.8.8) id XAA22290; Fri, 26 Jun 1998 23:45:37 -0700 (MST) Received: from usr08.primenet.com(206.165.6.208) via SMTP by smtp02.primenet.com, id smtpd022258; Fri Jun 26 23:45:28 1998 Received: (from tlambert@localhost) by usr08.primenet.com (8.8.5/8.8.5) id XAA21564; Fri, 26 Jun 1998 23:45:26 -0700 (MST) From: Terry Lambert Message-Id: <199806270645.XAA21564@usr08.primenet.com> Subject: Re: raw devices (min transfer size, detection) To: jasone@canonware.com (Jason Evans) Date: Sat, 27 Jun 1998 06:45:26 +0000 (GMT) Cc: freebsd-hackers@FreeBSD.ORG In-Reply-To: from "Jason Evans" at Jun 26, 98 00:47:26 am X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 1) I need to know the minimum transfer size for the underlying device so > that I can intelligently write only the physical blocks that need > written, rather than an entire "logical" block as my code sees the > data. I've looked through physio() and friends, and it appears that > this information is deriveable from the buf struct that is passed in to > physio(). The problem is that this is all done behind the scenes. Can > I directly get at this info? > > I've got a workaround, which involves trying to read 1, 2, 4, ..., 2^n > bytes, until the read succeeds. This seems kind of gross though. > > 2) How can I programmatically (in C) know that a file is a device, and > more specifically a raw device? I've browsed a large number of > manpages, but I still haven't found the answer. I'll eventually find > it, but perhaps someone can point me in the right direction? =) stat(2) the device: The size-related fields of the struct stat are as follows: st_blksize The optimal I/O block size for the file. The status information word st_mode has the following bits: #define S_IFMT 0170000 /* type of file */ #define S_IFIFO 0010000 /* named pipe (fifo) */ #define S_IFCHR 0020000 /* character special */ #define S_IFDIR 0040000 /* directory */ #define S_IFBLK 0060000 /* block special */ #define S_IFREG 0100000 /* regular */ #define S_IFLNK 0120000 /* symbolic link */ #define S_IFSOCK 0140000 /* socket */ #define S_IFWHT 0160000 /* whiteout */ Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message