Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Dec 1999 10:21:06 +0200
From:      Sheldon Hearn <sheldonh@uunet.co.za>
To:        Mikhail Teterin <mi@kot.ne.mediaone.net>
Cc:        questions@FreeBSD.ORG, stable@FreeBSD.ORG
Subject:   Re: fstat(2) not filling st_blksize? 
Message-ID:  <74073.946023666@axl.noc.iafrica.com>
In-Reply-To: Your message of "Fri, 24 Dec 1999 00:24:25 EST." <199912240524.AAA18524@rtfm.newton> 

next in thread | previous in thread | raw e-mail | index | archive | help


On Fri, 24 Dec 1999 00:24:25 EST, Mikhail Teterin wrote:

> Whatever  the  filesystem I  try  (ufs,  nfs,  cd9660,  mfs) I  get  the
> st_blksize as zero after fstat(2)-ing the  file on it.

What version of FreeBSD are you using.  On a 4-day-old 4.0-CURRENT,
fstat(2) seems to fill st_bklsize correctly.  The following sample code
prints 8192 for every file I tested on my system.

Ciao,
Sheldon.

#include <sys/types.h>
#include <sys/stat.h>
#include <err.h>
#include <fcntl.h>
#include <stdio.h>

int
main(int argc, char *argv[])
{
	struct stat t;
	int fd;

	if (argc != 2) {
		(void)fprintf(stderr, "a single path argument is required\n");
		return 1;
	}
	if ((fd = open(argv[0], O_RDONLY)) == -1)
		err(1, NULL);
	if (fstat(fd, &t) == -1)
		err(1, NULL);

	printf("%d\n", t.st_blksize);

	return 0;
}


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?74073.946023666>