开发者

Unmount a network volume?

开发者 https://www.devze.com 2023-04-07 13:32 出处:网络
How do I unmount a network volume? NSWorkspace thinks they\'re neither remo开发者_如何学编程vable nor unmountable. unmountAndEjectDeviceAtPath: @\"/Volumes/the network volume in question\" causes no

How do I unmount a network volume?

NSWorkspace thinks they're neither remo开发者_如何学编程vable nor unmountable. unmountAndEjectDeviceAtPath: @"/Volumes/the network volume in question" causes nothing whatsoever to happen. There's probably some easy way to do this, sitting right under my nose, but I can't find it.

I don't want to resort to making an Applescript telling the Finder to Eject network volumes and calling it from Cocoa because that's just incredibly icky.

(my dev platform is Tiger, by the way)


Is calling unmount(2) fair-game? (How odd, most Unix systems name the system call umount(), not unmount(), and the manpage frequently calls it umount() despite the name and Synopsis sections fairly clearly using unmount().)

Is the mount in use by anything else? Check lsof(1) or fuser(1) output to see which processes, if any, have that filesystem currently open. (Maybe adding a simple chdir("/"); just before your unmount call would do it?)


You can also use diskutil which handles more situations than unmount():

std::string command = std::string("diskutil unmount \"") + currentMountPoint + "\"";
int ret = system( command.c_str() );

Note the double quotes around the mount point, most likely something like /Volumes/Untitled, but also something like /Volumes/NO NAME

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号