如何查找磁盘卷的格式

时间:2013-02-21 10:12:40

标签: macos cocoa disk

我正在更新我编写的备份实用程序,并在Mac App Store上。

在Macintosh Cocoa应用程序中,如何查找磁盘卷的格式?我找到的唯一正式的事情是做一个GetResourceValue:对于'NSURLVolumeLocalizedFormatDescriptionKey',但这取决于语言。

我的实用程序不支持为FAT32格式化的卷。我的实用程序需要对XSan驱动器进行特殊处理。

2 个答案:

答案 0 :(得分:5)

statfs(2)会为您提供非本地化名称:

struct statfs volinfo;
if(statfs("/path/to/your/volume", &volinfo) != 0)
{
  perror("statfs");
  return -1;
}

fprintf(stderr, "%s\n", volinfo.f_fstypename);

有关将在/System/Library/Filesystems中返回的姓名,请参阅f_fstypename

答案 1 :(得分:0)

这个问题已经得到解答,但我会把我的2美分投入......

/sbin/mount | grep acfs | awk '{print $3}'

此输出

/Volumes/XsanVolumeName1
/Volumes/XsanVolumeName2
相关问题