HFS+ 之间的区别 和 HFS 标准卷

发布于 2024-07-06 17:28:25 字数 318 浏览 14 评论 0原文

IOKit 和 DiskArbitration 框架可以告诉我很多有关 Mac 上已安装卷的信息,但它们似乎无法区分 HFS+ 和 HFS 标准卷。

对于 HFS 标准卷和 HFS+ 卷,IOKit/DA 键 ContentDAVolumeKindDAMediaContent 始终为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

别把无礼当个性 2024-07-13 17:28:26

除了返回包含 signaturefilesystemID 字段的 Carbon FSGetVolumeInfo() 之外,还有 Cocoa < code>-getFileSystemInfoForPath:类NSWorkspace的方法,返回文件系统类型的字符串表示形式:例如,hfs用于HFS+和msdos对于 DOS FAT。

In addition to Carbon FSGetVolumeInfo() which returns a FSVolumeInfo containing signature and filesystemID fields, there is the Cocoa -getFileSystemInfoForPath: method of class NSWorkspace which returns a string representation of filesystem type: e.g., hfs for HFS+ and msdos for DOS FAT.

德意的啸 2024-07-13 17:28:26

如果您尝试直接读取分区映射,可能会遇到的另一个问题是,从历史上看,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.

森林很绿却致人迷途 2024-07-13 17:28:25

有两种方法可以执行此操作:

  1. 使用 getattrlist() 检索卷装载路径的 ATTR_VOL_SIGNATURE 属性。
  2. 使用 Carbon 调用 FSGetVolumeInfo() 并查看返回结构的 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:

  1. Use getattrlist() to retrieve the ATTR_VOL_SIGNATURE attribute for the mount path of the volume.
  2. Use the Carbon call FSGetVolumeInfo() and look in the 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 using getattrlist, 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文