Date: Sat, 27 Jun 1998 06:45:26 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: jasone@canonware.com (Jason Evans) Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: raw devices (min transfer size, detection) Message-ID: <199806270645.XAA21564@usr08.primenet.com> In-Reply-To: <Pine.BSF.3.96.980626001654.18178B-100000@orkan.canonware.com> from "Jason Evans" at Jun 26, 98 00:47:26 am
next in thread | previous in thread | raw e-mail | index | archive | help
> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806270645.XAA21564>