From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 22 21:15:56 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 3A97E16A526 for ; Thu, 22 Jun 2006 21:15:56 +0000 (UTC) (envelope-from andrew.chace@gmail.com) Received: from nz-out-0102.google.com (nz-out-0102.google.com [64.233.162.195]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3DD7D4552E for ; Thu, 22 Jun 2006 20:41:03 +0000 (GMT) (envelope-from andrew.chace@gmail.com) Received: by nz-out-0102.google.com with SMTP id 16so493161nzp for ; Thu, 22 Jun 2006 13:41:02 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:subject:from:to:content-type:date:message-id:mime-version:x-mailer:content-transfer-encoding; b=F8iBpRBvlnkB60mFFPBh4itFmiutnY2OQ37tJWDhDfNhJoOObxSyn/orpRZXb1MF5/Kz/XgQiFMtV4ADcML2isnIswCO7V4jGjZuKk3LS2O6gxIwPM/l+ymfunYKcCqENlQTwRuLDUAlazU5OH2Frwg0XlPe+EYz30erzTZYtfs= Received: by 10.37.22.68 with SMTP id z68mr2626356nzi; Thu, 22 Jun 2006 13:41:02 -0700 (PDT) Received: from ?192.168.0.6? ( [70.56.10.145]) by mx.gmail.com with ESMTP id 14sm1879195nzp.2006.06.22.13.41.01; Thu, 22 Jun 2006 13:41:02 -0700 (PDT) From: Andrew To: freebsd-hackers@freebsd.org Content-Type: text/plain Date: Thu, 22 Jun 2006 15:40:39 -0500 Message-Id: <1151008839.2360.30.camel@LatitudeFC5.network> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 (2.6.1-1.fc5.2) Content-Transfer-Encoding: 7bit Subject: 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 21:15:56 -0000 Hello, First off, is this the appropriate list for coding questions? I read questions@, but I do not often see discussions about code there, so I thought I might ask here instead. If not, please correct me. I need to know the size of a block device in some code that I'm writing. I checked the man pages, and I was thinking that I could use fstat(), but after I call it on the device, stat->st_size is still 0. I tested fstat()'s return value, and it's correct; there are no errors. So, I'm thinking that this is not the correct way to do this. 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? Thanks, -Andrew