duがHFS +パーティションの一部の空でないファイルのサイズを0として報告するのはなぜですか?

duがHFS +パーティションの一部の空でないファイルのサイズを0として報告するのはなぜですか?

違いの説明は何ですか?

$ ls -l /Applications/Safari.app/Contents/Info.plist
-rw-r--r--  1 root  wheel  15730 11 jui 15:02 /Applications/Safari.app/Contents/Info.plist

$ du -sh /Applications/Safari.app/Contents/Info.plist
0B     /Applications/Safari.app/Contents/Info.plist

ファイルが自分のホームフォルダにコピーされると、同じ番号が報告されますlsdu

$ cp /Applications/Safari.app/Contents/Info.plist .
$ du -sh Info.plist; ls -l Info.plist
16K Info.plist
-rw-r--r--  1 ant  staff  15730 17 oct 16:53 Info.plist

どちらのディレクトリもこのパーティション(/)にあります。

diskutil  info /
Device Identifier:        disk0s2
Device Node:              /dev/disk0s2
Part of Whole:            disk0
Device / Media Name:      ml2013

Volume Name:              OSX.10.8
Escaped with Unicode:     OSX.10.8

Mounted:                  Yes
Mount Point:              /
Escaped with Unicode:     /

File System Personality:  Journaled HFS+
Type (Bundle):            hfs
Name (User Visible):      Mac OS Extended (Journaled)
Journal:                  Journal size 40960 KB at offset 0xc83000
Owners:                   Enabled

これはstatの出力です:

$ stat  Info.plist
16777218 8780020 -rw-r--r-- 1 root wheel 0 15730 "Oct 17 17:47:12 2013" \ 
"Jun 11 15:02:17 2013" "Jun 11 15:02:17 2013" "Apr 27 11:49:34 2013"\ 
4096 0 0x20 Info.plist

ベストアンサー1

私が何かを見つけたかもしれません:

OS Xのlsコマンドには、次のスイッチがあります。

  -O      Include the file flags in a long (-l) output.

結果:

$ ls -O Info.plist
-rw-r--r--  1 root  wheel  compressed 15730 11 jui 15:02 Info.plist

(実験的に)HFS +圧縮ファイルが常に報告duされていることを確認しました。0

du圧縮ファイルをコピーして解凍し、コピーされた圧縮されていないファイルの正しいファイルを論理的に報告します。

これは説明です次の動作の場合du:

HFS+ファイル圧縮

Mac OS X 10.6では、AppleはHFS +のファイル圧縮を導入しました。圧縮は、Mac OS X の一部としてインストールされたファイルに最もよく使用されます。ユーザーファイルは通常圧縮されません(もちろん可能です!)。圧縮ファイルの読み書きは、AppleのファイルシステムAPIに関する限り透明です。

圧縮ファイルに空のデータフォークがあります。これは、HFS +ファイル圧縮(4.0.0より前のTSKを含む)をサポートしていないフォレンジックツールが圧縮ファイルに関連するデータを表示できないことを意味します!

Mac OS X and iOS Internals: To the Apple's CoreJonathan Levinは、第16章:B(-Tree)で行うべきではありません - HFS +ファイルシステムでこのトピックについても議論します。

返品AFSCツールフォルダにどのファイルが圧縮されているかを確認するのに役立ちます。

$ afsctool -v /Applications/Safari.app/
/Applications/Safari.app/.:
Number of HFS+ compressed files: 1538
Total number of files: 2247
Total number of folders: 144
Total number of items (number of files + number of folders): 2391
Folder size (uncompressed; reported size by Mac OS 10.6+ Finder): 29950329 bytes / 34.7 MB (megabytes) / 33.1 MiB (mebibytes)
Folder size (compressed - decmpfs xattr; reported size by Mac OS 10.0-10.5 Finder): 21287197 bytes / 23.8 MB (megabytes) / 22.7 MiB (mebibytes)
Folder size (compressed): 22694835 bytes / 25.2 MB (megabytes) / 24 MiB (mebibytes)
Compression savings: 24.2%
Approximate total folder size (files + file overhead + folder overhead): 26353338 bytes / 26.4 MB (megabytes) / 25.1 MiB (mebibytes)

おすすめ記事