From owner-freebsd-current Sat Jun 15 03:44:34 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id DAA15671 for current-outgoing; Sat, 15 Jun 1996 03:44:34 -0700 (PDT) Received: from silvia.HIP.Berkeley.EDU (silvia.HIP.Berkeley.EDU [136.152.64.181]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id DAA15666 for ; Sat, 15 Jun 1996 03:44:30 -0700 (PDT) Received: (from asami@localhost) by silvia.HIP.Berkeley.EDU (8.7.5/8.6.9) id DAA00936; Sat, 15 Jun 1996 03:44:28 -0700 (PDT) Date: Sat, 15 Jun 1996 03:44:28 -0700 (PDT) Message-Id: <199606151044.DAA00936@silvia.HIP.Berkeley.EDU> To: current@freebsd.org Subject: how to find size of special file From: asami@cs.berkeley.edu (Satoshi Asami) Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Stupid question du jour: How do you find out a size of a raw or cooked disk partition? Neither the obvious int fd ; struct stat sb ; fd = open(filename, ...) ; stat(fd, &sb) ; size = sb.st_size ; nor the less obvious int fd ; struct stat sb ; fd = open(filename, ...) ; size = lseek(fd, 0, SEEK_END) ; work on special files, even if they are disk partitions. (They both work on regular files....) Satoshi