delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/06/06/09:07:22

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Fri, 6 Jun 2003 09:07:14 -0400
From: Christopher Faylor <cgf AT redhat DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Sparse file criteria malfunction - binutils produces sparse .exe & .dll files
Message-ID: <20030606130714.GA26173@redhat.com>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <3EDF9E8D DOT AA452A2E AT ieee DOT org> <20030606081225 DOT GD12547 AT cygbert DOT vinschen DOT de> <002a01c32c05$bf79e040$78d96f83 AT pomello>
Mime-Version: 1.0
In-Reply-To: <002a01c32c05$bf79e040$78d96f83@pomello>
User-Agent: Mutt/1.4.1i

On Fri, Jun 06, 2003 at 09:29:28AM +0100, Max Bowsher wrote:
>Corinna Vinschen wrote:
>> I did the same here and I've added the block count which shows how much
>> blocks has been wasted by being a sparse file:
>>
>>  188 -rwxr-xr-x    1 corinna  root       191765 Jun  6 09:55 ./ftp/ftp.exe
>> Sparse bit 200
>>  497 -rwxr-xr-x    1 corinna  root       508186 Jun  6 09:55
>./ftpd/ftpd.exe
>> Sparse bit 200
>>  748 -rwxr-xr-x    1 corinna  root       765264 Jun  6 09:55
>./inetd/inetd.exe
>> Sparse bit 200
>...
>> So there's no waste of blocks at all.
>
>In my testing of sparse files, I found that the extra disc usage did not
>appear to be reported in Explorer File Properties "Size on Disc", but was
>visible in the overall Disc Properties, by looking at the change in free
>space.

I extended Pierre's program to report on disk space used versus size on disk.
AFAICT, the files produced by ld are actually consuming less space on disk
than reported by ls, thanks to their sparseness.

cgf

#include <windows.h>
#include <stdio.h>
main(int argc, char * argv[])
{
  DWORD i = (argc > 1)? GetFileAttributes(argv[1]) : INVALID_FILE_ATTRIBUTES;
  if (i == INVALID_FILE_ATTRIBUTES)
    printf("Error for %s %ld\n", argv[1], GetLastError());
  else
    {
      DWORD high, low;
      printf("Sparse bit %x\n", i & FILE_ATTRIBUTE_SPARSE_FILE);
      low = GetCompressedFileSize (argv[1], &high);
      printf("Compressed Size %d\n", low);
      HANDLE h = CreateFile (argv[1], GENERIC_READ,
			     FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
      if (h)
	{
	  low = GetFileSize (h, &high);
	  printf ("Size %d\n", low);
	}
    }
}


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019