0

这是问题所在,当我使用 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];
   }
4

1 回答 1

1

找出无法卸载它的原因:

  • 当前用户是否安装了卷?

  • 该卷中是否还有任何文件已打开?在终端中,fuser -uc /Volumes/MyMountPoint将向您显示在该文件系统上打开文件的进程和拥有它们的用户。只要打开任何文件,就无法卸载文件系统。

于 2013-06-17T18:27:36.617 回答