Question

How do I unmount a network volume?

NSWorkspace thinks they're neither removable 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)

Was it helpful?

Solution

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?)

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top