Date: Thu, 22 Jun 2006 17:01:27 -0500 From: Dan Nelson <dnelson@allantgroup.com> To: Mike Meyer <mwm-keyword-freebsdhackers2.e313df@mired.org> Cc: freebsd-hackers@freebsd.org, Andrew <andrew.chace@gmail.com> Subject: Re: Coding question: finding the size of a block device Message-ID: <20060622220127.GE74589@dan.emsphone.com> In-Reply-To: <17563.3550.496244.953904@bhuda.mired.org> References: <1151008839.2360.30.camel@LatitudeFC5.network> <17563.3550.496244.953904@bhuda.mired.org>
next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Jun 22), Mike Meyer said: > In <1151008839.2360.30.camel@LatitudeFC5.network>, Andrew <andrew.chace@gmail.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060622220127.GE74589>