From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 22 22:53:13 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DBA7416A6ED for ; Thu, 22 Jun 2006 22:53:13 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2449544FF3 for ; Thu, 22 Jun 2006 22:01:29 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.1/8.13.4) id k5MM1RHW050642; Thu, 22 Jun 2006 17:01:27 -0500 (CDT) (envelope-from dan) Date: Thu, 22 Jun 2006 17:01:27 -0500 From: Dan Nelson To: Mike Meyer Message-ID: <20060622220127.GE74589@dan.emsphone.com> References: <1151008839.2360.30.camel@LatitudeFC5.network> <17563.3550.496244.953904@bhuda.mired.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17563.3550.496244.953904@bhuda.mired.org> X-OS: FreeBSD 5.5-PRERELEASE X-message-flag: Outlook Error User-Agent: Mutt/1.5.11 Cc: freebsd-hackers@freebsd.org, Andrew Subject: Re: Coding question: finding the size of a block device X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jun 2006 22:53:14 -0000 In the last episode (Jun 22), Mike Meyer said: > In <1151008839.2360.30.camel@LatitudeFC5.network>, Andrew typed: > > So I guess my question is: is there a POSIX compatible function that > > will allow me to check the size of a given block device? > > I'd be surprised - POSIX doesn't seem to deal with block devices at all. > > Checking the sources to df, it uses statfs to get the > information. Linux appears to have it as well, so it may be portable. statfs only works on mounted filesystems, not arbitrary block devices. /usr/sbin/diskinfo uses ioctl(fd, DIOCGMEDIASIZE, &mediasize), where mediasize is an off_t. -- Dan Nelson dnelson@allantgroup.com