View Single Post
Old 09-01-2007, 07:10 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 69
I think some versions of dumpfs or equivalent will emit this information, though the utility is filesystem-specific (e.g., for ext2, you could use “dumpe2fs -h /path/to/block/device”). I don’t think there is any standard utility that does this for any filesystem, although I’m not sure why not. For example, you could do this (which is portable across all POSIX systems):
Code:
#include <stdio.h>
#include <stdlib.h>
#include <sys/statvfs.h>

int main(int argc, char *argv[])
{
	struct statvfs buf;
	if(statvfs(argv[1], &buf))
		exit(EXIT_FAILURE);

	printf("File system block size: %lu\n", buf.f_bsize);
	printf("Fundamental file system block size: %lu\n", buf.f_frsize);

	exit(EXIT_SUCCESS);
}
Compile the program with “make blocks” (assuming you call it “blocks.c”). Then just run the program as “./blocks /path/to/mountpoint” (notice that the path is not to the block device, but to the mountpoint — e.g., instead of “/dev/sda1” use “/usr”).