From owner-freebsd-questions@FreeBSD.ORG Tue Feb 19 08:43:26 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D05616A41B for ; Tue, 19 Feb 2008 08:43:25 +0000 (UTC) (envelope-from on@cs.ait.ac.th) Received: from mail.cs.ait.ac.th (mail.cs.ait.ac.th [192.41.170.16]) by mx1.freebsd.org (Postfix) with ESMTP id 62DF313C4E7 for ; Tue, 19 Feb 2008 08:43:23 +0000 (UTC) (envelope-from on@cs.ait.ac.th) Received: from banyan.cs.ait.ac.th (banyan.cs.ait.ac.th [192.41.170.5]) by mail.cs.ait.ac.th (8.13.1/8.12.11) with ESMTP id m1J4WVUs045926 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 19 Feb 2008 11:32:31 +0700 (ICT) Received: (from on@localhost) by banyan.cs.ait.ac.th (8.13.6/8.12.11) id m1J4WTgW080030; Tue, 19 Feb 2008 11:32:29 +0700 (ICT) Date: Tue, 19 Feb 2008 11:32:29 +0700 (ICT) Message-Id: <200802190432.m1J4WTgW080030@banyan.cs.ait.ac.th> From: Olivier Nicole To: kamikaze@bsdforen.de In-reply-to: <47B95F78.2060604@bsdforen.de> (message from Dominic Fandrey on Mon, 18 Feb 2008 11:35:36 +0100) References: <200802181025.m1IAPdHc060834@banyan.cs.ait.ac.th> <47B95F78.2060604@bsdforen.de> X-Virus-Scanned: on CSIM by amavisd-milter (http://www.amavis.org/) Cc: freebsd-questions@freebsd.org Subject: Re: Get the empty space on a file system X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Feb 2008 08:43:26 -0000 > > 2) knowing the file system from 1), how to check the remaining space > > in the file system? > > You normally just start writing and deal with the errors that come from full > file systems when they show up. The C functions set errno accordingly. > > The reason is that the system lies about the remainig space. Weather there > is any space left you may use, depends on the user you're running your > program as. It would be kinda stupid if your program didn't work because the > disk was full, even when you're running as root and are permitted to use the > remaining safety space (8% by default). In my case, I am writing log files, so I would start with removing older logs to make space for the newer ones. That is why I refer to know before hand how much space is available, to allow some cleaning, rather than waiting for a problem. It seems that statfs is the answer. Bests, Olivier