From owner-freebsd-questions@FreeBSD.ORG Thu Jun 14 00:18:42 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 44F1E1065670 for ; Thu, 14 Jun 2012 00:18:42 +0000 (UTC) (envelope-from dmtilbrook@gmail.com) Received: from mail-ob0-f182.google.com (mail-ob0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 0B5798FC1A for ; Thu, 14 Jun 2012 00:18:41 +0000 (UTC) Received: by obcni5 with SMTP id ni5so2021478obc.13 for ; Wed, 13 Jun 2012 17:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=N/FySXuBoYBcjPPywK0iNgj/XU9Z27ZuG0WTCmHMdWA=; b=eMfeNYu5sVx2H8IaBgHle3nzKe4x/fKntQiLW2tn3Xqw0/UINsULKKB45BhMq/Iv+L PjT56NHXW2A3nduR2NeOnp8fQfr1frs5c1PuYMact50SMtwSasBAG5rE70l8mm5qdB5H Dah+N7wskJaF8l4nqx1BpN2OCoUDsDzbcTHytQFbF1xu+9k7OswmQXbm3HrK4sN7KgsR NUzNzB3q9LjKOpPbiFm3NoPv+qEMozFSjsgQrYtLCND+8wBnAWGd/2ZZkaxbQ86K3eKZ y2gvcc3pjlT+n9JckEpGq1uxCuEs5FoWhfciWrgSUC7SchVdUgvjedEAOjQzu32FxKNv 5/fA== MIME-Version: 1.0 Received: by 10.60.1.202 with SMTP id 10mr26741566oeo.15.1339633121598; Wed, 13 Jun 2012 17:18:41 -0700 (PDT) Received: by 10.182.133.2 with HTTP; Wed, 13 Jun 2012 17:18:41 -0700 (PDT) In-Reply-To: <20120613202325.GC5800@external.screwed.box> References: <20120613202325.GC5800@external.screwed.box> Date: Wed, 13 Jun 2012 20:18:41 -0400 Message-ID: From: David Tilbrook To: Peter Vereshagin Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-questions@freebsd.org Subject: Re: `ls -l` shows size of file other than of the folder? 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: Thu, 14 Jun 2012 00:18:42 -0000 What you have are sparse files. The size listed by ls -l is the length of the files as if all the file from start to end contain data, but unix allows one to seek beyond the end of a file and add more data, thus leaving unused blocks. A common example of sparse files is the *.pag file in a dbm database as created by Ken (Thompson). The ls -s flag will show you how many real blocks are used. The program stat(1) will also show you the number of blocks used. The following creates a file with a size of 1024000002 (a gig), that actually contains only 2 chars. #include main() { fwrite("a", 1, 1, stdout); fseek(stdout, 1000000*1024, SEEK_END); fwrite("b", 1, 1, stdout); } cc foo.c ; ./a.out > ,z ; ls -ls ,z You can od ,z Old codger story from the distant past (circa 1975): When we were using rk05s as our disks, we had to watch for programs that used to fill-in the holes as we often had files that had sizes that were bigger than the amount of storage on an rk05 (5 Meg). Yes people used to live that way. >From the not so distant past (1985): The Andrew File system at CMU used to fill in the holes as it copied files from the file servers to the local host, and back again -- ycccch. -- david On Wed, Jun 13, 2012 at 4:23 PM, Peter Vereshagin wr= ote: > Hello. > > I have the directory in the file system with 2 regular files each =A0of = =A0which =A0is > sized as 700M according to 'ls -l'. =A0But the torrent client and 'du -s'= and =A0'ls > -l's 'total' show that the directory size is 300M. > > How can that be? =A0Are there different file sizes =A0stored =A0on =A0a = =A0ufs1 =A0in =A0their > metadata? > > ot the least how could I see the 'real' size of each of those files, both= =A0~150M > actulally, with a system command? > > Thank you. > > -- > Peter Vereshagin (http://vereshagin.org) pgp: A0E2= 6627 > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.o= rg"