问题是,当我使用NSTask卸载当前的USB驱动器时,它会给我以下错误:
2013-06-03 09:39:41.096 NAME[1028:303] in moving file view controller
dyld: DYLD_ environment variables being ignored because main executable
(/usr/sbin/diskutil) has __RESTRICT/__restrict section
Unmount of disk1 failed: at least one volume could not be unmounted
我有我的mac的分区所以disk1我认为是mac os。 这是我用来卸载驱动器的功能:
//When I call this function by passing all of these arguments:
NSArray* arrayForCloseUSBDrive = [[NSArray arrayWithObjects:@"diskutil", @"unmountDisk",@"/Volumes/AAA/",nil]autorelease];
[Utility handleDrive:@"/usr/bin/env" arrayArguments:arrayForCloseUSBDrive];
//It will start run this function in Utility class:
+(void)handleDrive:(NSString*)launchPath arrayArguments:(NSArray*)array
{
NSTask *task = [NSTask new];
[task setLaunchPath:launchPath];
[task setArguments:array];
NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput:pipe];
[task launch];
[task waitUntilExit];
}
答案 0 :(得分:1)
找出无法卸载的原因:
当前用户是否安装了卷?
该卷中是否还有任何文件已打开?在终端中,fuser -uc /Volumes/MyMountPoint
将向您显示进程以及拥有该文件系统上已打开文件的用户。只要打开任何文件,就无法卸载文件系统。