HFS+ 之间的区别 和 HFS 标准卷
IOKit 和 DiskArbitration 框架可以告诉我很多有关 Mac 上已安装卷的信息,但它们似乎无法区分 HFS+ 和 HFS 标准卷。
对于 HFS 标准卷和 HFS+ 卷,IOKit/DA 键 Content
、DAVolumeKind
和 DAMediaContent
始终为 Apple_HFS 和 hfs。
diskutil 和 DiskUtility.app可以区分,但我认为它们似乎没有被 Apple 开源。
ps statfs(2) 不区分
IOKit and the DiskArbitration framework can tell me a lot of things about mounted volumes on a mac, but they don't seem to be able to differentiate between HFS+ and HFS Standard volumes.
The IOKit/DA keys Content
, DAVolumeKind
and DAMediaContent
are always Apple_HFS and hfs for both HFS Standard and HFS+ volumes.
diskutil and DiskUtility.app can tell the difference, but I they don't seem to have been open sourced by Apple.
p.s. statfs (2) does not differentiate
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
除了返回包含
signature
和filesystemID
字段的 CarbonFSGetVolumeInfo()
之外,还有 Cocoa < code>-getFileSystemInfoForPath:类NSWorkspace
的方法,返回文件系统类型的字符串表示形式:例如,hfs
用于HFS+和msdos
对于 DOS FAT。In addition to Carbon
FSGetVolumeInfo()
which returns aFSVolumeInfo
containingsignature
andfilesystemID
fields, there is the Cocoa-getFileSystemInfoForPath:
method of classNSWorkspace
which returns a string representation of filesystem type: e.g.,hfs
for HFS+ andmsdos
for DOS FAT.如果您尝试直接读取分区映射,可能会遇到的另一个问题是,从历史上看,HFS+ 卷嵌套在 HFS 包装器中。 这样做是为了让任何尝试在旧操作系统上使用 HFS+ 磁盘的人都可以在驱动器上看到一个文件,解释所有其余数据的位置。
The other problem you can run into should you ever try your hand at reading partition maps directly is that, historically, HFS+ volumes were nested inside HFS wrappers. This was done so that anyone trying to use an HFS+ disk with an older OS would see a single file on the drive explaining where all the rest of their data was.
有两种方法可以执行此操作:
getattrlist()
检索卷装载路径的ATTR_VOL_SIGNATURE
属性。signature
字段。卷的签名是一个 16 位值,通常解释为两个 ASCII 字符。 HFS 的签名是“BD”,HFS+ 是“H+”,区分大小写的 HFS+ 是“HX”。
getattrlist 的手册页说该字段是 u_int32,但 FSVolumeInfo 结构中的等效字段只有 16 位,因此我不确定 32 中的哪 16 位填充有签名当使用 getattrlist 时,如果您想走非 Carbon 路线,您可能只需要进行一些尝试。
getattrlist 手册页
HFS Plus 卷格式参考
FSGetVolumeInfo
There are two ways to do this:
getattrlist()
to retrieve theATTR_VOL_SIGNATURE
attribute for the mount path of the volume.signature
field of the returned struct.The signature of a volume is a 16 bit value, usually interpreted as two ASCII characters. The signature for HFS is 'BD', HFS+ is 'H+', and case sensitive HFS+ is 'HX'.
The man page for
getattrlist
says the field is a u_int32, but the equivalent field in the FSVolumeInfo struct is only 16 bits, so I'm not sure which 16 bits of the 32 are filled in with the signature when usinggetattrlist
, you'll probably have to just experiment a bit if you want to go the non-Carbon route.getattrlist man page
HFS Plus Volume Format reference
FSGetVolumeInfo