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 に答える