filefragとstatのブロックの違い

filefragとstatのブロックの違い

sometext任意のデータで名前付きファイルを作成しました。複数のプログラムを使用してこのファイルのメタデータを確認したいと思います。私はそれを使っfilefragstatプログラムしました。

 kd@kd-VPCEB2S1E ~/Downloads $ stat sometext 
  File: 'sometext'
  Size: 16          Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d  Inode: 6298184     Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/  kd)   Gid: ( 1000/  kd)
Access: 2018-04-19 09:39:07.263246674 +0200
Modify: 2018-04-19 09:39:06.527234524 +0200
Change: 2018-04-19 09:39:06.527234524 +0200
 Birth: -
kd@kd-VPCEB2S1E ~/Downloads $ filefrag -v sometext 
Filesystem type is: ef53
File size of sometext is 16 (1 block of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..       0:   25369307..  25369307:      1:             last,eof
sometext: 1 extent found
kd@kd-VPCEB2S1E ~/Downloads $ 

どちらのプログラムもファイルサイズが16 bytesblockサイズが4096 bytes。これまでは素晴らしかったですが、ファイルstatを表示するには必要があり、ファイルを表示するには。8 blocksfilefrag1 block

なぜそんなに大きな違いがありますか?私が逃したものは何ですか?

ベストアンサー1

IOブロックはいブロックサイズブロックデバイスとの交換に使用されます。

詰まったstat)はファイルシステム番号です。セル(もちろん、ファイルシステムの種類に応じて)、ファイルを保存するために必要です。テストするのは簡単です:

$ stat shell
  File: ‘shell’
  Size: 4295        Blocks: 16         IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 16997503    Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1000/   yurij)   Gid: ( 1000/   yurij)
Access: 2018-04-11 18:17:38.614827347 +0300
Modify: 2018-04-11 18:17:34.359967012 +0300
Change: 2018-04-19 01:07:03.729000000 +0300
 Birth: - 

$ pwd
/home/yurij/develop/shell/usr/local/bin
$ sudo blockdev --getbsz /dev/mapper/cl-root
[sudo] password for yurij:
512 # cell size in bytes

8KB = 8192バイト

8192バイト/ 512バイト= 16ブロック

filefrag:

$ filefrag -v shell
Filesystem type is: 58465342
File size of shell is 4295 (2 blocks of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..       1:    1141480..   1141481:      2:             eof
shell: 1 extent found

ブロックデバイスからファイルを読み取るか、ブロックデバイスにファイルを書き込むには、2回の読み書き操作が必要です。

おすすめ記事