Hello,
I'd like to know if there is a way to get this properties(like the image below) of a USB thumb drive from a mount point(/Volumes/mydrive) in a generic kernel extension? Thanks!
https://www.dropbox.com/s/5ykusvrlz7apzzs/IORegistryExplorer.png?raw=1
I decide to check the volume type in user space.
Wise choice!
Could you please take a look at my code. Is it correct?
You can do this more easily by calling
statfs
and then passing
f_mntfromname
to
DADiskCreateFromBSDName
.
Also, it’s a lot easier to wrangle dictionaries from Objective-C (or Objective-C++, if you’re so inclined). For example:
struct statfs stfs;
int err = statfs("/", &stfs);
… check error …
if ( !(stfs.f_flags & MNT_LOCAL) ) {
… bail out …
}
DASessionRef session = DASessionCreate(NULL);
CFAutorelease(session);
DADiskRef disk = DADiskCreateFromBSDName(NULL, session, stfs.f_mntfromname);
CFAutorelease(disk);
NSDictionary * diskInfo = CFBridgingRelease( DADiskCopyDescription(disk) );
BOOL isRemovable = [diskInfo[(__bridge NSString *) kDADiskDescriptionMediaRemovableKey] boolValue];
NSLog(@"removable: %@", isRemovable ? @"YES" : @"NO");
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"