gpt4 book ai didi

objective-c - objective-c : Error when using NSTask to unmount a USB drive

转载 作者:行者123 更新时间:2023-12-03 17:53:55 24 4
gpt4 key购买 nike

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

最佳答案

找出无法卸载它的原因:

  • 该卷是否由当前用户安装?

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

关于objective-c - objective-c : Error when using NSTask to unmount a USB drive,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16898403/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com