delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/10/20/07:04:10

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
X-Originating-IP: [140.77.128.64]
From: "Guillaume Melquiond" <soltatis AT hotmail DOT com>
To: <cygwin AT cygwin DOT com>
Subject: Problem with stat.st_blksize
Date: Sun, 20 Oct 2002 13:05:15 +0200
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <OE58BlF3a5iHLvqSHsf000034b1@hotmail.com>
X-OriginalArrivalTime: 20 Oct 2002 11:03:56.0998 (UTC) FILETIME=[62B6FE60:01C27828]

Hi,

Some times ago, when I used the command 'du' to get the size of a directory,
I got a value that was in accordance with the value given by Windows.
However, it isn't the case anymore now; 'du' returns a size less than the
files space usage.

So I had a glance to the source code and I saw that the field 'st_blksize'
from the system call 'stat' was initialized with 'S_BLKSIZE' (which is a
macro set to 1024). But my filesystem uses 4096 bytes blocks. I looked at
the winsup cvs to see why it worked before; but unless I did a mistake, it
seems 'S_BLKSIZE' has always been here.

Why is this field not set to a proper value? One moment, I thought Windows
was returning a wrong value. But I tried with 'statfs' and the value was
correct. So maybe 'st_blksize' should be computed the same way than
'f_bsize'.

Regards,

Guillaume

PS: Since I'm not suscribed to this mailing-list, please cc me if you expect
an answer that cleanly inserts in a thread. Otherwise, I will follow the
discussion through the archive.

PPS: Here is an exemple to show the behavior difference between 'stat' and
'statfs'.

$ cat test.c
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/vfs.h>
#include <unistd.h>

int main(int argc, char *argv[]) {
  struct stat buf1;
  struct statfs buf2;
  stat(argv[1], &buf1);
  statfs(argv[1],&buf2);
  printf("st_blksize:\t%d\nf_bsize:\t%d\n", buf1.st_blksize, buf2.f_bsize);
  return 0;
}

$ gcc test.c -o test

$ ./test test.c
st_blksize:     1024
f_bsize:        4096

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.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