简体   繁体   中英

How to find the format of a disk volume

I am updating a backup utility I have written and have on the Mac App store.

In a Macintosh Cocoa application, how do I find how a disk volume is formatted? The only official thing I find, is doing a GetResourceValue: for 'NSURLVolumeLocalizedFormatDescriptionKey', but that is language dependent.

My utility does not support volumes formatted for FAT32. My utility needs to do special handling for XSan drives.

statfs(2) will give you a non-localized name:

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

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

See /System/Library/Filesystems for the names that will be returned in f_fstypename .

This question has been answered but I'll throw my 2 cents in...

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

This outputs

/Volumes/XsanVolumeName1
/Volumes/XsanVolumeName2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM