From owner-freebsd-stable Mon Nov 22 20:58:25 1999 Delivered-To: freebsd-stable@freebsd.org Received: from overcee.netplex.com.au (overcee.netplex.com.au [202.12.86.7]) by hub.freebsd.org (Postfix) with ESMTP id 1337514BE2; Mon, 22 Nov 1999 20:58:14 -0800 (PST) (envelope-from peter@netplex.com.au) Received: from netplex.com.au (localhost [127.0.0.1]) by overcee.netplex.com.au (Postfix) with ESMTP id C76D71C6D; Tue, 23 Nov 1999 12:57:36 +0800 (WST) (envelope-from peter@netplex.com.au) X-Mailer: exmh version 2.1.1 10/15/1999 To: Bjoern Fischer Cc: freebsd-hackers@FreeBSD.ORG, freebsd-stable@FreeBSD.ORG Subject: Re: stat(2) weirdness In-Reply-To: Message from Bjoern Fischer of "Tue, 23 Nov 1999 05:20:09 +0100." <19991123051328.A292@frolic.no-support.loc> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Tue, 23 Nov 1999 12:57:36 +0800 From: Peter Wemm Message-Id: <19991123045736.C76D71C6D@overcee.netplex.com.au> Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Bjoern Fischer wrote: > Hello, > > recently while debugging a problem in wwwoffle-2.5b I realized, > that stat(2) behaves at least extremely strange on 3.3-STABLE: > > This small example... > > #include > #include > #include > > int main(int argc, char *argv[]) { > > char *fname = argv[0]; > struct stat sb; > int res = stat(argv[0], &sb); > > printf("filename : %s\n" \ > "st_size : %d\n" \ > "st_blocks : %d\n" \ > "st_blksize : %d\n", > fname, sb.st_size, sb.st_blocks, sb.st_blksize); > > return res; > > } > > would emerge this when run: > > filename : ./a.out > st_size : 3342 > st_blocks : 0 > st_blksize : 8 > > Any idea why st_blocks is always zero? This can't be correct. > st_blksize seems to be the number of blocks allocated for > filename, although assuming a blocksize of 512 the object > would fit into 7 blocks. Maybe that's the result of the > underlying FFS's fsize (1024). > > Björn > > -- > -----BEGIN GEEK CODE BLOCK----- > GCS d--(+) s++: a- C+++(-) UB++++OSI++++$ P+++(-) L---(++) !E W- N+ o>+ > K- !w !O !M !V PS++ PE- PGP++ t+++ !5 X++ tv- b+++ D++ G e+ h-- y+ > ------END GEEK CODE BLOCK------ > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message peter@overcee[12:55pm]/tmp-158> cc -Wall -o stat stat.c stat.c: In function `main': stat.c:15: warning: int format, different type arg (arg 3) stat.c:15: warning: int format, different type arg (arg 4) You are mixing int and 'long long' arg types. If it's fixed, eg: printf("filename : %s\n" \ "st_size : %lld\n" \ "st_blocks : %lld\n" \ "st_blksize : %d\n", fname, sb.st_size, sb.st_blocks, sb.st_blksize); Then: peter@overcee[12:56pm]/tmp-162> cc -Wall -o xx xx.c peter@overcee[12:56pm]/tmp-163> ./xx filename : ./xx st_size : 3522 st_blocks : 7 st_blksize : 4096 Cheers, -Peter -- Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message