簡単なプログラムを作成し、そのプログラムを ext4 と xfs で実行しました。
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
int
main(int argc, char *argv[])
{
int fd;
char *file_name = argv[1];
struct stat buf;
fd = open (file_name, O_RDWR|O_CREAT);
if (fd == -1) {
printf ("Error: %s\n", strerror(errno));
return -1;
}
write (fd, "hello", sizeof ("hello"));
fstat (fd, &buf);
printf ("st_blocks: %lu\n", buf.st_blocks);
stat (file_name, &buf);
printf ("st_blocks: %lu\n", buf.st_blocks);
close (fd);
stat (file_name, &buf);
printf ("st_blocks: %lu\n", buf.st_blocks);
return 0;
}
ext4 の出力:
st_blocks: 8 st_blocks: 8 st_blocks: 8
xfs での出力:
st_blocks: 128 st_blocks: 128 st_blocks: 8
次に、xfs について調べたところ、mkfs.xfs の実行中にエクステント サイズを変更するオプションが見つかりました。
例: mkfs.xfs -r extsize=4096 /dev/sda1
それでも、XFS でも同じ出力が得られます。st_blocks を変更する方法について、誰でもより多くの洞察を提供できますか。前もって感謝します。